Make sure LCTR bones are untransformed by RigInverter

This commit is contained in:
Jack Andersen 2016-04-08 17:10:50 -10:00
parent 27bc17a997
commit 6800b5ccf5
2 changed files with 24 additions and 5 deletions

View File

@ -13,11 +13,12 @@ RigInverter<CINFType>::Bone::Bone(const CINFType& cinf, const typename CINFType:
: m_origBone(origBone)
{
atUint32 parentIdx = cinf.getInternalBoneIdxFromId(origBone.parentId);
zeus::CVector3f naturalTail = zeus::CVector3f(origBone.origin) + zeus::CVector3f{0.f, 0.5f, 0.f};
zeus::CVector3f boneOrigin(origBone.origin);
zeus::CVector3f naturalTail = boneOrigin + zeus::CVector3f{0.f, 0.5f, 0.f};
if (parentIdx != -1)
{
const typename CINFType::Bone& pBone = cinf.bones[parentIdx];
m_parentDelta = zeus::CVector3f(origBone.origin) - zeus::CVector3f(pBone.origin);
m_parentDelta = boneOrigin - zeus::CVector3f(pBone.origin);
}
size_t actualChildren = 0;
@ -30,6 +31,11 @@ RigInverter<CINFType>::Bone::Bone(const CINFType& cinf, const typename CINFType:
++actualChildren;
}
const std::string* bName = cinf.getBoneNameFromId(origBone.id);
bool isLCTR = false;
if (bName)
isLCTR = bName->find("_LCTR") != std::string::npos;
if (parentIdx == -1)
{
/* Root will always use +Y tail */
@ -52,14 +58,27 @@ RigInverter<CINFType>::Bone::Bone(const CINFType& cinf, const typename CINFType:
m_tail /= float(actualChildren);
if (m_tail.magSquared() < 0.001f)
m_tail = naturalTail;
if (isLCTR)
m_tail = boneOrigin + zeus::CVector3f{0.f, 1.0f, 0.f} * (m_tail - boneOrigin).magnitude();
}
else if (parentIdx != -1)
{
/* Extrapolate by delta with parent */
const typename CINFType::Bone& pBone = cinf.bones[parentIdx];
m_tail = zeus::CVector3f(origBone.origin) * 2.f - zeus::CVector3f(pBone.origin);
m_tail = zeus::CVector3f(origBone.origin) + m_parentDelta;
if (m_tail.magSquared() < 0.001f)
m_tail = naturalTail;
float deltaMag = m_parentDelta.magnitude();
if (deltaMag > 0.5f)
{
/* Extreme bones capped to +0.5 value */
deltaMag = 0.5f;
m_tail = boneOrigin + m_parentDelta.normalized() * 0.5f;
}
if (isLCTR)
m_tail = boneOrigin + zeus::CVector3f{0.f, 1.0f, 0.f} * deltaMag;
}
else
{

2
hecl

@ -1 +1 @@
Subproject commit 50f43c48616e47408fc6e24c86c41156cc350a77
Subproject commit 3ed5345c08fa0e93c5ab57099fc4714c41cf8457