Skip to content

Commit

Permalink
refactor(spatial): use clearer to understand global transform
Browse files Browse the repository at this point in the history
  • Loading branch information
technobaboo committed Feb 6, 2024
1 parent dfc7f03 commit 5f88cd7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/nodes/spatial/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ impl Spatial {
*self.transform.lock()
}
pub fn global_transform(&self) -> Mat4 {
match self.get_parent() {
Some(parent) => parent.global_transform() * *self.transform.lock(),
None => *self.transform.lock(),
}
let parent_transform = self
.get_parent()
.as_deref()
.map(Self::global_transform)
.unwrap_or_default();
parent_transform * self.local_transform()
}
pub fn set_local_transform(&self, transform: Mat4) {
*self.transform.lock() = transform;
Expand Down

0 comments on commit 5f88cd7

Please sign in to comment.