From 9dffd6797c5fb551f695a925a920c5975c3986a5 Mon Sep 17 00:00:00 2001 From: mitchellhansen Date: Thu, 4 Feb 2021 19:18:14 -0800 Subject: [PATCH] and the problem was a query that I mis-typed. damn --- src/light.rs | 5 +++-- src/render.rs | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/light.rs b/src/light.rs index 6ceef42..f3b1b52 100644 --- a/src/light.rs +++ b/src/light.rs @@ -1,6 +1,7 @@ use bytemuck::__core::ops::Range; use bytemuck::{Zeroable, Pod}; use crate::{OPENGL_TO_WGPU_MATRIX, DirectionalLight, Position}; +use cgmath::Point3; #[repr(C)] @@ -16,10 +17,10 @@ unsafe impl Pod for LightRaw {} unsafe impl Zeroable for LightRaw {} impl DirectionalLight { - pub fn to_raw(&self, pos: Position) -> LightRaw { + pub fn to_raw(&self, pos: Point3) -> LightRaw { use cgmath::{Deg, EuclideanSpace, Matrix4, PerspectiveFov, Point3, Vector3}; - let pos = cgmath::Point3::new(pos.x, pos.y, pos.z); + //let pos = cgmath::Point3::new(pos.x, pos.y, pos.z); let mx_view = Matrix4::look_at(pos, Point3::origin(), Vector3::unit_z()); let projection = PerspectiveFov { fovy: Deg(self.fov).into(), diff --git a/src/render.rs b/src/render.rs index 232af00..7864456 100644 --- a/src/render.rs +++ b/src/render.rs @@ -118,8 +118,8 @@ pub fn render_test(world: &mut SubWorld, #[resource] renderer: &mut Renderer) { // Update the entity uniforms for (pos, mesh, color) in query.iter_mut(world) { - // let rotation = cgmath::Matrix4::from_angle_x(cgmath::Deg(1.0)); - // pos.mx = pos.mx * rotation; + let rotation = cgmath::Matrix4::from_angle_x(cgmath::Deg(2.0)); + pos.mx = pos.mx * rotation; let data = EntityUniforms { model: pos.mx.into(), @@ -139,7 +139,7 @@ pub fn render_test(world: &mut SubWorld, #[resource] renderer: &mut Renderer) { if renderer.lights_are_dirty { //renderer.lights_are_dirty = false; - let mut query = <(&mut DirectionalLight, &mut Position)>::query(); + let mut query = <(&mut DirectionalLight, &mut Point3)>::query(); for (i, (light, pos)) in query.iter_mut(world).enumerate() { renderer.queue.write_buffer( &renderer.light_uniform_buf,