mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-02 04:37:54 +08:00
Fix update of model matrix
This commit is contained in:
@@ -38,11 +38,13 @@ public:
|
|||||||
void computeModelMatrix()
|
void computeModelMatrix()
|
||||||
{
|
{
|
||||||
m_modelMatrix = getLocalModelMatrix();
|
m_modelMatrix = getLocalModelMatrix();
|
||||||
|
m_isDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void computeModelMatrix(const glm::mat4& parentGlobalModelMatrix)
|
void computeModelMatrix(const glm::mat4& parentGlobalModelMatrix)
|
||||||
{
|
{
|
||||||
m_modelMatrix = parentGlobalModelMatrix * getLocalModelMatrix();
|
m_modelMatrix = parentGlobalModelMatrix * getLocalModelMatrix();
|
||||||
|
m_isDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLocalPosition(const glm::vec3& newPosition)
|
void setLocalPosition(const glm::vec3& newPosition)
|
||||||
@@ -439,10 +441,15 @@ public:
|
|||||||
//Update transform if it was changed
|
//Update transform if it was changed
|
||||||
void updateSelfAndChild()
|
void updateSelfAndChild()
|
||||||
{
|
{
|
||||||
if (!transform.isDirty())
|
if (transform.isDirty()) {
|
||||||
|
forceUpdateSelfAndChild();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
forceUpdateSelfAndChild();
|
|
||||||
|
for (auto&& child : children)
|
||||||
|
{
|
||||||
|
child->updateSelfAndChild();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Force update of transform even if local space don't change
|
//Force update of transform even if local space don't change
|
||||||
|
|||||||
Reference in New Issue
Block a user