Added Global Inverse Matrix for SHRig
This commit is contained in:
parent
a543f6cc3a
commit
62f104a535
|
@ -166,7 +166,7 @@ namespace SHADE
|
||||||
const int BONE_MTX_IDX = rig->GetNodeIndex(node);
|
const int BONE_MTX_IDX = rig->GetNodeIndex(node);
|
||||||
if (BONE_MTX_IDX >= 0)
|
if (BONE_MTX_IDX >= 0)
|
||||||
{
|
{
|
||||||
boneMatrices[BONE_MTX_IDX] = boneMatrices[BONE_MTX_IDX] * transformMatrix * node->OffsetMatrix;
|
boneMatrices[BONE_MTX_IDX] = rig->GetGlobalInverseMatrix() * transformMatrix * node->OffsetMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply pose to children
|
// Apply pose to children
|
||||||
|
|
|
@ -34,6 +34,10 @@ namespace SHADE
|
||||||
|
|
||||||
// Do a recursive depth first traversal to populate the rig
|
// Do a recursive depth first traversal to populate the rig
|
||||||
rootNode = recurseCreateNode(asset, asset.root);
|
rootNode = recurseCreateNode(asset, asset.root);
|
||||||
|
if (rootNode)
|
||||||
|
{
|
||||||
|
globalInverseMatrix = rootNode->OffsetMatrix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
@ -82,7 +86,7 @@ namespace SHADE
|
||||||
|
|
||||||
// Fill the node with data
|
// Fill the node with data
|
||||||
const auto& NODE_DATA = asset.nodeDataCollection.at(sourceNode->idRef);
|
const auto& NODE_DATA = asset.nodeDataCollection.at(sourceNode->idRef);
|
||||||
newNode->OffsetMatrix = NODE_DATA.transform;
|
newNode->OffsetMatrix = SHMatrix::Inverse(NODE_DATA.transform);
|
||||||
|
|
||||||
// Populate maps
|
// Populate maps
|
||||||
if (!NODE_DATA.name.empty())
|
if (!NODE_DATA.name.empty())
|
||||||
|
|
|
@ -80,6 +80,7 @@ namespace SHADE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Handle to the root node of the rig.</returns>
|
/// <returns>Handle to the root node of the rig.</returns>
|
||||||
Handle<SHRigNode> GetRootNode() const noexcept { return rootNode; }
|
Handle<SHRigNode> GetRootNode() const noexcept { return rootNode; }
|
||||||
|
const SHMatrix& GetGlobalInverseMatrix() const noexcept { return globalInverseMatrix; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves a node via name.
|
/// Retrieves a node via name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -108,6 +109,7 @@ namespace SHADE
|
||||||
std::unordered_map<std::string, Handle<SHRigNode>> nodesByName;
|
std::unordered_map<std::string, Handle<SHRigNode>> nodesByName;
|
||||||
std::vector<Handle<SHRigNode>> nodes;
|
std::vector<Handle<SHRigNode>> nodes;
|
||||||
std::unordered_map<Handle<SHRigNode>, int> nodeIndexMap;
|
std::unordered_map<Handle<SHRigNode>, int> nodeIndexMap;
|
||||||
|
SHMatrix globalInverseMatrix;
|
||||||
SHResourceLibrary<SHRigNode> nodeStore;
|
SHResourceLibrary<SHRigNode> nodeStore;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
Loading…
Reference in New Issue