fixed model code

0.19
Benjamin Hansen 2 months ago
parent 8bb1b080b4
commit 5eacaf4e9c

@ -28,6 +28,7 @@ pub const OPENGL_TO_WGPU_MATRIX: cgmath::Matrix4<f32> = cgmath::Matrix4::new(
const NUM_INSTANCES_PER_ROW: u32 = 10; const NUM_INSTANCES_PER_ROW: u32 = 10;
#[derive(Debug)]
struct Camera { struct Camera {
eye: cgmath::Point3<f32>, eye: cgmath::Point3<f32>,
target: cgmath::Point3<f32>, target: cgmath::Point3<f32>,
@ -47,7 +48,7 @@ impl Camera {
} }
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] #[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
struct CameraUniform { struct CameraUniform {
view_proj: [[f32; 4]; 4], view_proj: [[f32; 4]; 4],
} }
@ -506,10 +507,10 @@ impl<'a> State<'a> {
fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) { fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) {
if new_size.width > 0 && new_size.height > 0 { if new_size.width > 0 && new_size.height > 0 {
self.camera.aspect = self.config.width as f32 / self.config.height as f32;
self.size = new_size;
self.config.width = new_size.width; self.config.width = new_size.width;
self.config.height = new_size.height; self.config.height = new_size.height;
self.size = new_size;
self.camera.aspect = self.config.width as f32 / self.config.height as f32;
self.surface.configure(&self.device, &self.config); self.surface.configure(&self.device, &self.config);
self.depth_texture = self.depth_texture =
texture::Texture::create_depth_texture(&self.device, &self.config, "depth_texture"); texture::Texture::create_depth_texture(&self.device, &self.config, "depth_texture");
@ -521,7 +522,9 @@ impl<'a> State<'a> {
fn update(&mut self) { fn update(&mut self) {
self.camera_controller.update_camera(&mut self.camera); self.camera_controller.update_camera(&mut self.camera);
log::info!("{:?}", self.camera);
self.camera_uniform.update_view_proj(&self.camera); self.camera_uniform.update_view_proj(&self.camera);
log::info!("{:?}", self.camera_uniform);
self.queue.write_buffer( self.queue.write_buffer(
&self.camera_buffer, &self.camera_buffer,
0, 0,

@ -144,7 +144,7 @@ pub async fn load_model(
usage: wgpu::BufferUsages::INDEX, usage: wgpu::BufferUsages::INDEX,
}); });
log::info!("{}", m.name); log::info!("Mesh: {}", m.name);
model::Mesh { model::Mesh {
name: file_name.to_string(), name: file_name.to_string(),
vertex_buffer, vertex_buffer,

@ -623,10 +623,10 @@ impl<'a> State<'a> {
fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) { fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) {
if new_size.width > 0 && new_size.height > 0 { if new_size.width > 0 && new_size.height > 0 {
self.camera.aspect = self.config.width as f32 / self.config.height as f32;
self.size = new_size;
self.config.width = new_size.width; self.config.width = new_size.width;
self.config.height = new_size.height; self.config.height = new_size.height;
self.size = new_size;
self.camera.aspect = self.config.width as f32 / self.config.height as f32;
self.surface.configure(&self.device, &self.config); self.surface.configure(&self.device, &self.config);
self.depth_texture = self.depth_texture =
texture::Texture::create_depth_texture(&self.device, &self.config, "depth_texture"); texture::Texture::create_depth_texture(&self.device, &self.config, "depth_texture");

@ -674,10 +674,10 @@ impl<'a> State<'a> {
fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) { fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) {
if new_size.width > 0 && new_size.height > 0 { if new_size.width > 0 && new_size.height > 0 {
self.camera.aspect = self.config.width as f32 / self.config.height as f32;
self.size = new_size;
self.config.width = new_size.width; self.config.width = new_size.width;
self.config.height = new_size.height; self.config.height = new_size.height;
self.size = new_size;
self.camera.aspect = self.config.width as f32 / self.config.height as f32;
self.surface.configure(&self.device, &self.config); self.surface.configure(&self.device, &self.config);
self.depth_texture = self.depth_texture =
texture::Texture::create_depth_texture(&self.device, &self.config, "depth_texture"); texture::Texture::create_depth_texture(&self.device, &self.config, "depth_texture");

Loading…
Cancel
Save