(&mut self, camera: &Camera, viewport_width: u32, viewport_height: u32)
| 14 | |
| 15 | impl CameraUniform { |
| 16 | pub(crate) fn update(&mut self, camera: &Camera, viewport_width: u32, viewport_height: u32) { |
| 17 | self.view_proj = camera.build_view_projection_matrix().to_cols_array_2d(); |
| 18 | |
| 19 | // For screen-space sizing (markers): convert pixels to clip space |
| 20 | let pixel_to_clip_x = 2.0 / viewport_width as f32; |
| 21 | let pixel_to_clip_y = 2.0 / viewport_height as f32; |
| 22 | self.pixel_to_clip = [pixel_to_clip_x, pixel_to_clip_y, 0.0, 0.0]; |
| 23 | |
| 24 | // For world-space patterns (lines): convert pixels to world units |
| 25 | let world_units_per_pixel_x = (2.0 * camera.half_extents.x) / viewport_width as f64; |
| 26 | let world_units_per_pixel_y = (2.0 * camera.half_extents.y) / viewport_height as f64; |
| 27 | self.pixel_to_world = [ |
| 28 | world_units_per_pixel_x as f32, |
| 29 | world_units_per_pixel_y as f32, |
| 30 | 0.0, |
| 31 | 0.0, |
| 32 | ]; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | impl Default for CameraUniform { |
nothing calls this directly
no test coverage detected