git.s-ol.nu ~forks/DiligentTools / 74a7aab
GLTFLoader: updated node transforms handling assiduous 11 months ago
2 changed file(s) with 14 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
239239
240240 float4x4 LocalMatrix() const;
241241 float4x4 GetMatrix() const;
242 void Update();
242 void UpdateTransforms();
243243 };
244244
245245
220220 return mat;
221221 }
222222
223 void Node::Update()
223 void Node::UpdateTransforms()
224224 {
225225 if (pMesh)
226226 {
242242
243243 for (auto& child : Children)
244244 {
245 child->Update();
245 child->UpdateTransforms();
246246 }
247247 }
248248
16831683 {
16841684 node->pSkin = Skins[node->SkinIndex].get();
16851685 }
1686
1687 // Initial pose
1688 if (node->pMesh)
1689 {
1690 node->Update();
1691 }
1692 }
1686 }
1687
1688 // Initial pose
1689 for (auto& root_node : Nodes)
1690 {
1691 root_node->UpdateTransforms();
1692 }
1693 CalculateSceneDimensions();
16931694
16941695
16951696 Extensions = gltf_model.extensionsUsed;
17691770 {
17701771 PrepareGPUResources(pDevice, pContext);
17711772 }
1772
1773 CalculateSceneDimensions();
17741773 }
17751774
17761775 void Model::CalculateBoundingBox(Node* node, const Node* parent)
18961895 {
18971896 for (auto& node : Nodes)
18981897 {
1899 node->Update();
1898 node->UpdateTransforms();
19001899 }
19011900 }
19021901 }
19041903 void Model::Transform(const float4x4& Matrix)
19051904 {
19061905 for (auto& root_node : Nodes)
1906 {
19071907 root_node->Matrix *= Matrix;
1908
1909 for (auto* node : LinearNodes)
1910 {
1911 if (node->pMesh)
1912 node->Update();
1908 root_node->UpdateTransforms();
19131909 }
19141910
19151911 CalculateSceneDimensions();