summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-12-10 23:11:49 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-12-10 23:11:49 +0000
commit74a7aab843040e30c2bc50cc47f294ba7672fcd2 (patch)
tree175206c3bcc3fbb07a4672e664e19d4ea1d16164
parentGLTF Loader: added (diff)
downloadDiligentTools-74a7aab843040e30c2bc50cc47f294ba7672fcd2.tar.gz
DiligentTools-74a7aab843040e30c2bc50cc47f294ba7672fcd2.zip
GLTFLoader: updated node transforms handling
-rw-r--r--AssetLoader/interface/GLTFLoader.hpp2
-rw-r--r--AssetLoader/src/GLTFLoader.cpp26
2 files changed, 12 insertions, 16 deletions
diff --git a/AssetLoader/interface/GLTFLoader.hpp b/AssetLoader/interface/GLTFLoader.hpp
index 81c7a96..aba68c3 100644
--- a/AssetLoader/interface/GLTFLoader.hpp
+++ b/AssetLoader/interface/GLTFLoader.hpp
@@ -240,7 +240,7 @@ struct Node
float4x4 LocalMatrix() const;
float4x4 GetMatrix() const;
- void Update();
+ void UpdateTransforms();
};
diff --git a/AssetLoader/src/GLTFLoader.cpp b/AssetLoader/src/GLTFLoader.cpp
index 1adc4a6..5a1ec56 100644
--- a/AssetLoader/src/GLTFLoader.cpp
+++ b/AssetLoader/src/GLTFLoader.cpp
@@ -221,7 +221,7 @@ float4x4 Node::GetMatrix() const
return mat;
}
-void Node::Update()
+void Node::UpdateTransforms()
{
if (pMesh)
{
@@ -243,7 +243,7 @@ void Node::Update()
for (auto& child : Children)
{
- child->Update();
+ child->UpdateTransforms();
}
}
@@ -1684,13 +1684,14 @@ void Model::LoadFromFile(IRenderDevice* pDevice,
{
node->pSkin = Skins[node->SkinIndex].get();
}
+ }
- // Initial pose
- if (node->pMesh)
- {
- node->Update();
- }
+ // Initial pose
+ for (auto& root_node : Nodes)
+ {
+ root_node->UpdateTransforms();
}
+ CalculateSceneDimensions();
Extensions = gltf_model.extensionsUsed;
@@ -1770,8 +1771,6 @@ void Model::LoadFromFile(IRenderDevice* pDevice,
{
PrepareGPUResources(pDevice, pContext);
}
-
- CalculateSceneDimensions();
}
void Model::CalculateBoundingBox(Node* node, const Node* parent)
@@ -1897,7 +1896,7 @@ void Model::UpdateAnimation(Uint32 index, float time)
{
for (auto& node : Nodes)
{
- node->Update();
+ node->UpdateTransforms();
}
}
}
@@ -1905,12 +1904,9 @@ void Model::UpdateAnimation(Uint32 index, float time)
void Model::Transform(const float4x4& Matrix)
{
for (auto& root_node : Nodes)
- root_node->Matrix *= Matrix;
-
- for (auto* node : LinearNodes)
{
- if (node->pMesh)
- node->Update();
+ root_node->Matrix *= Matrix;
+ root_node->UpdateTransforms();
}
CalculateSceneDimensions();