Fix BlendShape output error

This commit is contained in:
Perfare 2020-08-24 22:00:53 +08:00
parent 344b675745
commit 03f74bac64
3 changed files with 9 additions and 9 deletions

View File

@ -941,22 +941,22 @@ AS_API(int32_t) AsFbxAnimGetCurrentBlendShapeChannelCount(AsFbxAnimContext* pAni
return 0; return 0;
} }
auto lGeometry = dynamic_cast<FbxGeometry*>(pNode->GetNodeAttribute()); auto pMesh = pNode->GetMesh();
pAnimContext->lGeometry = lGeometry; pAnimContext->pMesh = pMesh;
if (lGeometry == nullptr) if (pMesh == nullptr)
{ {
return 0; return 0;
} }
auto blendShapeDeformerCount = lGeometry->GetDeformerCount(FbxDeformer::eBlendShape); auto blendShapeDeformerCount = pMesh->GetDeformerCount(FbxDeformer::eBlendShape);
if (blendShapeDeformerCount <= 0) if (blendShapeDeformerCount <= 0)
{ {
return 0; return 0;
} }
auto lBlendShape = dynamic_cast<FbxBlendShape*>(lGeometry->GetDeformer(0, FbxDeformer::eBlendShape)); auto lBlendShape = (FbxBlendShape*)pMesh->GetDeformer(0, FbxDeformer::eBlendShape);
pAnimContext->lBlendShape = lBlendShape; pAnimContext->lBlendShape = lBlendShape;
if (lBlendShape == nullptr) if (lBlendShape == nullptr)
@ -991,12 +991,12 @@ AS_API(bool32_t) AsFbxAnimIsBlendShapeChannelMatch(AsFbxAnimContext* pAnimContex
AS_API(void) AsFbxAnimBeginBlendShapeAnimCurve(AsFbxAnimContext* pAnimContext, int32_t channelIndex) AS_API(void) AsFbxAnimBeginBlendShapeAnimCurve(AsFbxAnimContext* pAnimContext, int32_t channelIndex)
{ {
if (pAnimContext == nullptr || pAnimContext->lGeometry == nullptr || pAnimContext->lAnimLayer == nullptr) if (pAnimContext == nullptr || pAnimContext->pMesh == nullptr || pAnimContext->lAnimLayer == nullptr)
{ {
return; return;
} }
pAnimContext->lAnimCurve = pAnimContext->lGeometry->GetShapeChannel(0, channelIndex, pAnimContext->lAnimLayer, true); pAnimContext->lAnimCurve = pAnimContext->pMesh->GetShapeChannel(0, channelIndex, pAnimContext->lAnimLayer, true);
pAnimContext->lAnimCurve->KeyModifyBegin(); pAnimContext->lAnimCurve->KeyModifyBegin();
} }

View File

@ -21,7 +21,7 @@ AsFbxAnimContext::AsFbxAnimContext(bool32_t eulerFilter)
lCurveTY = nullptr; lCurveTY = nullptr;
lCurveTZ = nullptr; lCurveTZ = nullptr;
lGeometry = nullptr; pMesh = nullptr;
lBlendShape = nullptr; lBlendShape = nullptr;
lAnimCurve = nullptr; lAnimCurve = nullptr;
} }

View File

@ -22,7 +22,7 @@ struct AsFbxAnimContext
FbxAnimCurve* lCurveTY; FbxAnimCurve* lCurveTY;
FbxAnimCurve* lCurveTZ; FbxAnimCurve* lCurveTZ;
FbxGeometry* lGeometry; FbxMesh* pMesh;
FbxBlendShape* lBlendShape; FbxBlendShape* lBlendShape;
FbxAnimCurve* lAnimCurve; FbxAnimCurve* lAnimCurve;