From 13c446f2556c96247fbbe8242122b4f1e6eb3b1c Mon Sep 17 00:00:00 2001 From: Harald Reingruber Date: Thu, 12 May 2022 16:25:58 +0200 Subject: [PATCH] Fix update of model matrix --- includes/learnopengl/entity.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/includes/learnopengl/entity.h b/includes/learnopengl/entity.h index cd9e266..8455e0d 100644 --- a/includes/learnopengl/entity.h +++ b/includes/learnopengl/entity.h @@ -38,11 +38,13 @@ public: void computeModelMatrix() { m_modelMatrix = getLocalModelMatrix(); + m_isDirty = false; } void computeModelMatrix(const glm::mat4& parentGlobalModelMatrix) { m_modelMatrix = parentGlobalModelMatrix * getLocalModelMatrix(); + m_isDirty = false; } void setLocalPosition(const glm::vec3& newPosition) @@ -439,10 +441,15 @@ public: //Update transform if it was changed void updateSelfAndChild() { - if (!transform.isDirty()) + if (transform.isDirty()) { + forceUpdateSelfAndChild(); return; - - forceUpdateSelfAndChild(); + } + + for (auto&& child : children) + { + child->updateSelfAndChild(); + } } //Force update of transform even if local space don't change