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_ApplyAdditive.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
// FAnimNode_ApplyAdditive
|
|
|
|
|
|
|
|
|
|
void FAnimNode_ApplyAdditive::Initialize(const FAnimationInitializeContext& Context)
|
|
|
|
|
{
|
2015-09-03 09:55:41 -04:00
|
|
|
FAnimNode_Base::Initialize(Context);
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
Base.Initialize(Context);
|
|
|
|
|
Additive.Initialize(Context);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-01 14:45:04 -04:00
|
|
|
void FAnimNode_ApplyAdditive::CacheBones(const FAnimationCacheBonesContext& Context)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
Base.CacheBones(Context);
|
|
|
|
|
Additive.CacheBones(Context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FAnimNode_ApplyAdditive::Update(const FAnimationUpdateContext& Context)
|
|
|
|
|
{
|
|
|
|
|
EvaluateGraphExposedInputs.Execute(Context);
|
|
|
|
|
|
|
|
|
|
Base.Update(Context);
|
|
|
|
|
const float ActualAlpha = AlphaScaleBias.ApplyTo(Alpha);
|
|
|
|
|
if (ActualAlpha > ZERO_ANIMWEIGHT_THRESH)
|
|
|
|
|
{
|
|
|
|
|
Additive.Update(Context.FractionalWeight(ActualAlpha));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FAnimNode_ApplyAdditive::Evaluate(FPoseContext& Output)
|
|
|
|
|
{
|
|
|
|
|
//@TODO: Could evaluate Base into Output and save a copy
|
|
|
|
|
const float ActualAlpha = AlphaScaleBias.ApplyTo(Alpha);
|
|
|
|
|
if (ActualAlpha > ZERO_ANIMWEIGHT_THRESH)
|
|
|
|
|
{
|
|
|
|
|
FPoseContext AdditiveEvalContext(Output);
|
|
|
|
|
|
2015-05-20 18:27:57 -04:00
|
|
|
Base.Evaluate(Output);
|
2014-03-14 14:13:41 -04:00
|
|
|
Additive.Evaluate(AdditiveEvalContext);
|
|
|
|
|
|
2015-06-26 12:27:57 -04:00
|
|
|
FAnimationRuntime::AccumulateAdditivePose(Output.Pose, AdditiveEvalContext.Pose, Output.Curve, AdditiveEvalContext.Curve, ActualAlpha, AAT_LocalSpaceBase);
|
2015-05-20 18:27:57 -04:00
|
|
|
Output.Pose.NormalizeRotations();
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Base.Evaluate(Output);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FAnimNode_ApplyAdditive::FAnimNode_ApplyAdditive()
|
|
|
|
|
: Alpha(1.0f)
|
|
|
|
|
{
|
|
|
|
|
}
|
2014-04-23 18:35:21 -04:00
|
|
|
|
|
|
|
|
void FAnimNode_ApplyAdditive::GatherDebugData(FNodeDebugData& DebugData)
|
|
|
|
|
{
|
|
|
|
|
const float ActualAlpha = AlphaScaleBias.ApplyTo(Alpha);
|
|
|
|
|
|
|
|
|
|
FString DebugLine = DebugData.GetNodeName(this);
|
|
|
|
|
DebugLine += FString::Printf(TEXT("(Alpha: %.1f%%)"), ActualAlpha*100.f);
|
|
|
|
|
|
|
|
|
|
DebugData.AddDebugItem(DebugLine);
|
|
|
|
|
Base.GatherDebugData(DebugData.BranchFlow(1.f));
|
|
|
|
|
Additive.GatherDebugData(DebugData.BranchFlow(ActualAlpha));
|
|
|
|
|
}
|