From c2236dc8a1040db80cbfee196b70c63126406a1e Mon Sep 17 00:00:00 2001 From: Mate Kovacs Date: Tue, 28 Nov 2023 20:31:05 +0900 Subject: [PATCH] optimize a bit --- crates/viewer/src/camera.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/viewer/src/camera.rs b/crates/viewer/src/camera.rs index c068510b..fff7c036 100644 --- a/crates/viewer/src/camera.rs +++ b/crates/viewer/src/camera.rs @@ -100,9 +100,11 @@ impl OrbitCamera { }; let local_frame = self.get_local_frame(); - let upward = local_frame.y_axis; let position = self.target + effective_radius * local_frame.z_axis; - let view = Mat4::look_at_rh(position, self.target, upward); + + // NOTE(mkovaxx): This is computing inverse(translation * orientation), but more efficiently + let view = + Mat4::from_quat(self.orientation.conjugate()) * Mat4::from_translation(-position); proj * view }