Skip to content

Commit

Permalink
Main: SubEntity - provide correct bone matrices for binding pose
Browse files Browse the repository at this point in the history
when object space bones are in use
  • Loading branch information
paroj committed Feb 23, 2024
1 parent f05165f commit 671ba5b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions OgreMain/src/OgreSubEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,27 +177,29 @@ namespace Ogre {
mSubMesh->parent->sharedBlendIndexToBoneIndexMap : mSubMesh->blendIndexToBoneIndexMap;
assert(indexMap.size() <= mParentEntity->mNumBoneMatrices);

if (MeshManager::getBonesUseObjectSpace())
{
*xform++ = mParentEntity->_getParentNodeFullTransform();
}

if (mParentEntity->_isSkeletonAnimated())
{
// Bones, use cached matrices built when Entity::_updateRenderQueue was called
auto boneMatrices = MeshManager::getBonesUseObjectSpace() ? mParentEntity->mBoneMatrices
: mParentEntity->mBoneWorldMatrices;
assert(boneMatrices);

if (MeshManager::getBonesUseObjectSpace())
{
*xform++ = mParentEntity->_getParentNodeFullTransform();
}

for (auto idx : indexMap)
{
*xform++ = boneMatrices[idx];
}
}
else
{
auto& value = MeshManager::getBonesUseObjectSpace() ? Affine3::IDENTITY
: mParentEntity->_getParentNodeFullTransform();
// All animations disabled, use parent entity world transform only
std::fill_n(xform, indexMap.size(), mParentEntity->_getParentNodeFullTransform());
std::fill_n(xform, indexMap.size(), value);
}
}
}
Expand Down

0 comments on commit 671ba5b

Please sign in to comment.