Add support for using animated model with anim graph using different skinned model

This commit is contained in:
Wojtek Figat
2021-05-13 11:59:47 +02:00
parent 9fcac44faf
commit 389eee22e3
5 changed files with 42 additions and 40 deletions

View File

@@ -175,7 +175,7 @@ AnimGraphExecutor::AnimGraphExecutor(AnimGraph& graph)
_perGroupProcessCall[16] = (ProcessBoxHandler)&AnimGraphExecutor::ProcessGroupFunction;
}
const Matrix* AnimGraphExecutor::Update(AnimGraphInstanceData& data, float dt)
void AnimGraphExecutor::Update(AnimGraphInstanceData& data, float dt)
{
ASSERT(data.Parameters.Count() == _graph.Parameters.Count());
@@ -185,7 +185,6 @@ const Matrix* AnimGraphExecutor::Update(AnimGraphInstanceData& data, float dt)
ANIM_GRAPH_PROFILE_EVENT("Init");
// Prepare graph data for the evaluation
_skeletonBonesCount = skeleton.Bones.Count();
_skeletonNodesCount = skeleton.Nodes.Count();
_graphStack.Clear();
_graphStack.Push((Graph*)&_graph);
@@ -265,23 +264,19 @@ const Matrix* AnimGraphExecutor::Update(AnimGraphInstanceData& data, float dt)
_data->RootMotion = animResult->RootMotion;
}
// Calculate the final bones transformations
{
ANIM_GRAPH_PROFILE_EVENT("Final Pose");
_bonesTransformations.Resize(_skeletonBonesCount, false);
for (int32 boneIndex = 0; boneIndex < _skeletonBonesCount; boneIndex++)
{
auto& bone = skeleton.Bones[boneIndex];
_bonesTransformations[boneIndex] = bone.OffsetMatrix * _data->NodesPose[bone.NodeIndex];
}
}
// Cleanup
_data = nullptr;
}
return _bonesTransformations.Get();
void AnimGraphExecutor::GetInputValue(Box* box, Value& result)
{
result = eatBox(box->GetParent<Node>(), box->FirstConnection());
}
void AnimGraphExecutor::ResetBucket(int32 bucketIndex)
{
auto& stateBucket = _data->State[bucketIndex];
_graph._bucketInitializerList[bucketIndex](stateBucket);
}
void AnimGraphExecutor::ResetBuckets(AnimGraphBase* graph)