diff --git a/SHADE_Engine/src/Animation/SHAnimatorComponent.cpp b/SHADE_Engine/src/Animation/SHAnimatorComponent.cpp
index 26f6b83e..bd6228bd 100644
--- a/SHADE_Engine/src/Animation/SHAnimatorComponent.cpp
+++ b/SHADE_Engine/src/Animation/SHAnimatorComponent.cpp
@@ -143,7 +143,7 @@ namespace SHADE
{
// Check if there is a channel for this node
const std::string& BONE_NAME = rig->GetName(node);
- SHMatrix transformMatrix = SHMatrix::Identity;
+ SHMatrix transformMatrix = node->TransformMatrix;
if (channelMap.contains(BONE_NAME))
{
const auto CHANNEL = channelMap[BONE_NAME];
@@ -154,19 +154,15 @@ namespace SHADE
getInterpolatedValue(CHANNEL->ScaleKeyFrames, closestFrameIndex, poseTime)
);
}
- else
- {
- transformMatrix = SHMatrix::Inverse(node->OffsetMatrix); // TODO: Use TransformMatrix for the bone
- }
// Apply parent's transformation
- transformMatrix = parentMatrix * transformMatrix;
+ transformMatrix = transformMatrix * parentMatrix;
// Apply transformations to this node
const int BONE_MTX_IDX = rig->GetNodeIndex(node);
if (BONE_MTX_IDX >= 0)
{
- boneMatrices[BONE_MTX_IDX] = rig->GetGlobalInverseMatrix() * transformMatrix * node->OffsetMatrix;
+ boneMatrices[BONE_MTX_IDX] = node->OffsetMatrix * transformMatrix * rig->GetGlobalInverseMatrix();
}
// Apply pose to children
diff --git a/SHADE_Engine/src/Animation/SHRig.cpp b/SHADE_Engine/src/Animation/SHRig.cpp
index 84117f77..306c9a00 100644
--- a/SHADE_Engine/src/Animation/SHRig.cpp
+++ b/SHADE_Engine/src/Animation/SHRig.cpp
@@ -86,7 +86,8 @@ namespace SHADE
// Fill the node with data
const auto& NODE_DATA = asset.nodeDataCollection.at(sourceNode->idRef);
- newNode->OffsetMatrix = SHMatrix::Inverse(NODE_DATA.transform);
+ newNode->OffsetMatrix = SHMatrix::Transpose(NODE_DATA.offset);
+ newNode->TransformMatrix = SHMatrix::Transpose(NODE_DATA.transform);
// Populate maps
if (!NODE_DATA.name.empty())
diff --git a/SHADE_Engine/src/Animation/SHRig.h b/SHADE_Engine/src/Animation/SHRig.h
index f28c628b..0329dc6e 100644
--- a/SHADE_Engine/src/Animation/SHRig.h
+++ b/SHADE_Engine/src/Animation/SHRig.h
@@ -43,6 +43,10 @@ namespace SHADE
///
SHMatrix OffsetMatrix;
///
+ /// Matrix that performs a transformation from bone (node) space to local space.
+ ///
+ SHMatrix TransformMatrix;
+ ///
/// Child nodes of this node.
///
std::vector> Children;