chore(glam): use camera-module projection API for deprecated Mat4 rh ctors

glam 0.33.2 deprecated Mat4::{orthographic,perspective,look_at}_rh in
favour of the glam::camera::rh::* functions. Switch the 7 call sites in
camera.rs and viewcube.rs to the equivalent camera-module functions
(directx orthographic/perspective = same [0,1] depth range; look_at_mat4
= same view matrix), silencing the deprecation warnings. No behaviour
change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-17 01:49:26 +03:00
1 parent 48e6d0d553
commit 3e34da4ac6
2 files changed
+10 -7

No files matched your search

+5 -4
View File
@@ -10,6 +10,7 @@
// with arcball orbit at all angles.
use bytemuck::{Pod, Zeroable};
use glam::camera::rh::proj::directx::orthographic;
use glam::{Mat4, Vec3, Vec4};
use iced::wgpu;
use iced::{Rectangle, Size};
@@ -208,7 +209,7 @@ impl CubeUniforms {
let inset = cube_half * NAV_INSET_F;
let cx = hw - inset - VIEWCUBE_PAD;
let cy = hh - inset - VIEWCUBE_PAD;
let view_proj = Mat4::orthographic_rh(-hw, hw, -hh, hh, -2000.0, 2000.0)
let view_proj = orthographic(-hw, hw, -hh, hh, -2000.0, 2000.0)
* Mat4::from_translation(Vec3::new(cx, cy, 0.0))
* Mat4::from_scale(Vec3::splat(cube_px as f32 * VIEWCUBE_SCALE));
Self {
@@ -580,7 +581,7 @@ impl ViewCubeText {
let cube_half = cube_px as f32 * VIEWCUBE_SCALE;
let inset = cube_half * NAV_INSET_F;
let (hw, hh) = (vw * 0.5, vh * 0.5);
let view_proj = Mat4::orthographic_rh(-hw, hw, -hh, hh, -2000.0, 2000.0)
let view_proj = orthographic(-hw, hw, -hh, hh, -2000.0, 2000.0)
* Mat4::from_translation(Vec3::new(
hw - inset - VIEWCUBE_PAD,
hh - inset - VIEWCUBE_PAD,
@@ -1349,7 +1350,7 @@ pub fn hit_test(
}
let (hw, hh) = (vp_w * 0.5, vp_h * 0.5);
let vp = Mat4::orthographic_rh(-hw, hw, -hh, hh, -2000.0, 2000.0)
let vp = orthographic(-hw, hw, -hh, hh, -2000.0, 2000.0)
* Mat4::from_translation(Vec3::new(
hw - inset - VIEWCUBE_PAD,
hh - inset - VIEWCUBE_PAD,
@@ -1431,7 +1432,7 @@ pub fn hit_test_cardinal(
}
let (hw, hh) = (vp_w * 0.5, vp_h * 0.5);
let vp = Mat4::orthographic_rh(-hw, hw, -hh, hh, -2000.0, 2000.0)
let vp = orthographic(-hw, hw, -hh, hh, -2000.0, 2000.0)
* Mat4::from_translation(Vec3::new(
hw - inset - VIEWCUBE_PAD,
hh - inset - VIEWCUBE_PAD,
+5 -3
View File
@@ -11,6 +11,8 @@
//
// Coordinate convention: Z-up world space (same as the rest of OpenCADStudio).
use glam::camera::rh::proj::directx::{orthographic, perspective};
use glam::camera::rh::view::look_at_mat4;
use glam::{DVec3, Mat4, Quat, Vec3};
use iced::{Point, Rectangle};
@@ -126,19 +128,19 @@ impl Camera {
let aspect = bounds.width / bounds.height;
let up_dir = self.rotation * Vec3::Y;
let mut view = Mat4::look_at_rh(self.eye().as_vec3(), self.target.as_vec3(), up_dir);
let mut view = look_at_mat4(self.eye().as_vec3(), self.target.as_vec3(), up_dir);
// Zero the translation column → pure rotation (world→view basis).
view.w_axis = glam::vec4(0.0, 0.0, 0.0, 1.0);
let proj = match self.projection {
Projection::Perspective => {
Mat4::perspective_rh(self.fov_y, aspect, self.distance * 0.001, self.distance * 1000.0)
perspective(self.fov_y, aspect, self.distance * 0.001, self.distance * 1000.0)
}
Projection::Orthographic => {
let h = self.ortho_size();
let w = h * aspect;
let (near, far) = self.ortho_depth_range();
Mat4::orthographic_rh(-w, w, -h, h, near, far)
orthographic(-w, w, -h, h, near, far)
}
};
OPENGL_TO_WGPU * proj * view