kitgit

tirbofish/dropbear · diff

060c236 · Thribhu K

feature: multisampling with MSAA4 feature: increase active camera speed with mouse wheel scroll fix: when TRS animation was run, it would rotate the entire model, making it look like it was standing on its nose jarvis, run github actions.

Unverified

diff --git a/crates/dropbear-engine/src/entity.rs b/crates/dropbear-engine/src/entity.rs
index 605e45f..01cd9d2 100644
--- a/crates/dropbear-engine/src/entity.rs
+++ b/crates/dropbear-engine/src/entity.rs
@@ -18,12 +18,18 @@ use egui::Ui;
 pub struct EntityTransform {
     local: Transform,
     world: Transform,
+    #[serde(default)]
+    animation: Transform,
 }
 
 impl EntityTransform {
     /// Creates a new [EntityTransform] from a local and world [Transform]
     pub fn new(local: Transform, world: Transform) -> Self {
-        Self { local, world }
+        Self {
+            local,
+            world,
+            animation: Transform::default(),
+        }
     }
 
     /// Creates a new [EntityTransform] from a world [Transform] and a default local transform.
@@ -33,6 +39,7 @@ impl EntityTransform {
         Self {
             world,
             local: Transform::default(),
+            animation: Transform::default(),
         }
     }
 
@@ -59,22 +66,26 @@ impl EntityTransform {
     /// Combines both transforms into one, propagating the local transform
     /// to the world transform and returning a uniform [Transform]
     pub fn sync(&self) -> Transform {
-        let scaled_pos = self.local.position * self.world.scale;
-        let rotated_pos = self.world.rotation * scaled_pos;
-        let position = self.world.position + rotated_pos;
+        let combined = self.world.matrix() * self.local.matrix() * self.animation.matrix();
+        let (scale, rotation, position) = combined.to_scale_rotation_translation();
 
         Transform {
             position,
-            rotation: self.world.rotation * self.local.rotation,
-            scale: self.world.scale * self.local.scale,
+            rotation,
+            scale,
         }
     }

Large diffs are not rendered by default. Showing the first 50 of 385 lines. Show full diff