| 71 | } |
| 72 | |
| 73 | pub(crate) fn build_view_projection_matrix(&self) -> Mat4 { |
| 74 | let proj = Mat4::orthographic_rh( |
| 75 | -self.half_extents.x as f32, |
| 76 | self.half_extents.x as f32, |
| 77 | -self.half_extents.y as f32, |
| 78 | self.half_extents.y as f32, |
| 79 | -1.0, |
| 80 | 1.0, |
| 81 | ); |
| 82 | // Subtract render_offset from camera position for high-precision rendering |
| 83 | let effective_position = self.position - self.render_offset; |
| 84 | let view = Mat4::from_translation(-Vec3::new( |
| 85 | effective_position.x as f32, |
| 86 | effective_position.y as f32, |
| 87 | 0.0, |
| 88 | )); |
| 89 | proj * view |
| 90 | } |
| 91 | |
| 92 | // Convert screen coordinates to world coordinates |
| 93 | pub fn screen_to_world(&self, screen_pos: DVec2, screen_size: DVec2) -> DVec2 { |