summaryrefslogtreecommitdiffstats
path: root/AssetLoader
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-12-03 01:53:34 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-12-03 01:53:34 +0000
commit20b0c1a588371cfaa1ae7aedb670b4e0101c9e3d (patch)
tree0e4303a6998c16442bfb6434a277159699df22af /AssetLoader
parentGLTF Loader: switched to using texture arrays (diff)
downloadDiligentTools-20b0c1a588371cfaa1ae7aedb670b4e0101c9e3d.tar.gz
DiligentTools-20b0c1a588371cfaa1ae7aedb670b4e0101c9e3d.zip
GLTF Loader: using dynamic array of joint transform matrices instead of the fixed one
Diffstat (limited to 'AssetLoader')
-rw-r--r--AssetLoader/interface/GLTFLoader.hpp7
-rw-r--r--AssetLoader/src/GLTFLoader.cpp13
2 files changed, 8 insertions, 12 deletions
diff --git a/AssetLoader/interface/GLTFLoader.hpp b/AssetLoader/interface/GLTFLoader.hpp
index 2d10900..a9858e8 100644
--- a/AssetLoader/interface/GLTFLoader.hpp
+++ b/AssetLoader/interface/GLTFLoader.hpp
@@ -186,11 +186,8 @@ struct Mesh
struct TransformData
{
- static constexpr Uint32 MaxNumJoints = 128u;
-
- float4x4 matrix;
- float4x4 jointMatrix[MaxNumJoints] = {};
- int jointcount = 0;
+ float4x4 matrix;
+ std::vector<float4x4> jointMatrices;
};
TransformData Transforms;
diff --git a/AssetLoader/src/GLTFLoader.cpp b/AssetLoader/src/GLTFLoader.cpp
index 6683066..6665b89 100644
--- a/AssetLoader/src/GLTFLoader.cpp
+++ b/AssetLoader/src/GLTFLoader.cpp
@@ -235,16 +235,15 @@ void Node::Update()
if (_Skin != nullptr)
{
// Update join matrices
- auto InverseTransform = _Mesh->Transforms.matrix.Inverse(); // TODO: do not use inverse tranform here
- size_t numJoints = std::min((uint32_t)_Skin->Joints.size(), Uint32{Mesh::TransformData::MaxNumJoints});
- for (size_t i = 0; i < numJoints; i++)
+ auto InverseTransform = _Mesh->Transforms.matrix.Inverse(); // TODO: do not use inverse tranform here
+ if (_Mesh->Transforms.jointMatrices.size() != _Skin->Joints.size())
+ _Mesh->Transforms.jointMatrices.resize(_Skin->Joints.size());
+ for (size_t i = 0; i < _Skin->Joints.size(); i++)
{
auto* JointNode = _Skin->Joints[i];
- auto JointMat = _Skin->InverseBindMatrices[i] * JointNode->GetMatrix() * InverseTransform;
-
- _Mesh->Transforms.jointMatrix[i] = JointMat;
+ _Mesh->Transforms.jointMatrices[i] =
+ _Skin->InverseBindMatrices[i] * JointNode->GetMatrix() * InverseTransform;
}
- _Mesh->Transforms.jointcount = static_cast<int>(numJoints);
}
}