2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2015-07-22 14:37:24 -04:00
|
|
|
#include "AnimGraphRuntimePrivatePCH.h"
|
|
|
|
|
#include "AnimNodes/AnimNode_SaveCachedPose.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
// FAnimNode_SaveCachedPose
|
|
|
|
|
|
|
|
|
|
FAnimNode_SaveCachedPose::FAnimNode_SaveCachedPose()
|
|
|
|
|
: LastInitializedContextCounter(INDEX_NONE)
|
|
|
|
|
, LastCacheBonesContextCounter(INDEX_NONE)
|
|
|
|
|
, LastUpdatedContextCounter(INDEX_NONE)
|
|
|
|
|
, LastEvaluatedContextCounter(INDEX_NONE)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FAnimNode_SaveCachedPose::Initialize(const FAnimationInitializeContext& Context)
|
|
|
|
|
{
|
2015-09-03 09:55:41 -04:00
|
|
|
FAnimNode_Base::Initialize(Context);
|
|
|
|
|
|
2015-03-11 17:54:38 -04:00
|
|
|
if (LastInitializedContextCounter != Context.AnimInstance->GetGraphTraversalCounter())
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-03-11 17:54:38 -04:00
|
|
|
LastInitializedContextCounter = Context.AnimInstance->GetGraphTraversalCounter();
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
// Initialize the subgraph
|
|
|
|
|
Pose.Initialize(Context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-01 14:45:04 -04:00
|
|
|
void FAnimNode_SaveCachedPose::CacheBones(const FAnimationCacheBonesContext& Context)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-03-11 17:54:38 -04:00
|
|
|
if (LastCacheBonesContextCounter != Context.AnimInstance->GetGraphTraversalCounter())
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-03-11 17:54:38 -04:00
|
|
|
LastCacheBonesContextCounter = Context.AnimInstance->GetGraphTraversalCounter();
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
// Initialize the subgraph
|
|
|
|
|
Pose.CacheBones(Context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FAnimNode_SaveCachedPose::Update(const FAnimationUpdateContext& Context)
|
|
|
|
|
{
|
2015-03-11 17:54:38 -04:00
|
|
|
if (LastUpdatedContextCounter != Context.AnimInstance->GetGraphTraversalCounter())
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-03-11 17:54:38 -04:00
|
|
|
LastUpdatedContextCounter = Context.AnimInstance->GetGraphTraversalCounter();
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
// Update the subgraph
|
|
|
|
|
Pose.Update(Context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FAnimNode_SaveCachedPose::Evaluate(FPoseContext& Output)
|
|
|
|
|
{
|
2015-03-11 17:54:38 -04:00
|
|
|
if (LastEvaluatedContextCounter != Output.AnimInstance->GetGraphTraversalCounter())
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-03-11 17:54:38 -04:00
|
|
|
LastEvaluatedContextCounter = Output.AnimInstance->GetGraphTraversalCounter();
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
FPoseContext CachingContext(Output);
|
|
|
|
|
Pose.Evaluate(CachingContext);
|
2015-05-19 06:19:22 -04:00
|
|
|
CachedPose.MoveBonesFrom(CachingContext.Pose);
|
2015-06-26 12:27:57 -04:00
|
|
|
CachedCurve.MoveFrom(CachingContext.Curve);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return the cached result
|
2015-06-26 12:27:57 -04:00
|
|
|
Output.Pose.CopyBonesFrom(CachedPose);
|
|
|
|
|
Output.Curve.CopyFrom(CachedCurve);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
2014-04-23 18:35:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void FAnimNode_SaveCachedPose::GatherDebugData(FNodeDebugData& DebugData)
|
|
|
|
|
{
|
|
|
|
|
FString DebugLine = DebugData.GetNodeName(this);
|
|
|
|
|
DebugData.AddDebugItem(DebugLine);
|
|
|
|
|
|
|
|
|
|
Pose.GatherDebugData(DebugData);
|
|
|
|
|
}
|