From f71ae3782133ff5574b50e8948d816211de79c68 Mon Sep 17 00:00:00 2001 From: Alberto Torres Date: Sat, 21 Sep 2024 02:16:39 +0200 Subject: [PATCH] GameObject: Fix rotation in `get_local_matrix`. --- src/objects/gameobject.nim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/objects/gameobject.nim b/src/objects/gameobject.nim index 00b0952..503fc20 100644 --- a/src/objects/gameobject.nim +++ b/src/objects/gameobject.nim @@ -241,10 +241,12 @@ proc get_world_matrix*(self: GameObject): Mat4 = return self.world_matrix proc get_local_matrix*(self: GameObject): Mat4 = - var (x,y,z,w) = self.rotation.toTuple - # if self.rotation_order != Quaternion: - # let q = fromEulerOrder(self.rotation, self.rotation_order) - # let (x,y,z,w) = q.toTuple + var q = if self.rotation_order == Quaternion: + self.rotation + else: + to_quat(self.rotation.xyz, self.rotation_order) + q = normalize(q) + var (x,y,z,w) = q.toTuple let scl = self.scale # TODO: test negative scales let pos = self.position