MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / build_view_projection_matrix

Method build_view_projection_matrix

src/camera.rs:73–90  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

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 {

Callers 1

updateMethod · 0.80

Calls 1

newFunction · 0.50

Tested by

no test coverage detected