Skip to content

Commit

Permalink
Merge pull request #287 from naivisoftware/fix_transforms
Browse files Browse the repository at this point in the history
Fix transform updates
  • Loading branch information
cklosters committed Sep 14, 2023
2 parents 11a0be5 + a5abd66 commit ac8fc2f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions system_modules/napscene/src/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,19 +546,17 @@ namespace nap
*/
static void sUpdateTransformsRecursive(EntityInstance& entity, bool parentDirty, const glm::mat4& parentTransform)
{
glm::mat4 new_transform = parentTransform;

bool is_dirty = parentDirty;
TransformComponentInstance* transform = entity.findComponent<TransformComponentInstance>();
if (transform && (transform->isDirty() || parentDirty))
bool has_transform = (transform != nullptr);
bool is_dirty = parentDirty;
if (has_transform && (transform->isDirty() || is_dirty))
{
is_dirty = true;
transform->update(parentTransform);
new_transform = transform->getGlobalTransform();
}

const glm::mat4& next_parent = (has_transform) ? transform->getGlobalTransform() : parentTransform;
for (EntityInstance* child : entity.getChildren())
sUpdateTransformsRecursive(*child, is_dirty, new_transform);
sUpdateTransformsRecursive(*child, is_dirty, next_parent);
}

//////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit ac8fc2f

Please sign in to comment.