Files

77 lines
2.5 KiB
C++
Raw Permalink Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
#include "AnimNodes/AnimNode_MakeDynamicAdditive.h"
#include "AnimationRuntime.h"
#include "Animation/AnimStats.h"
#include "Animation/AnimTrace.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(AnimNode_MakeDynamicAdditive)
/////////////////////////////////////////////////////
// FAnimNode_MakeDynamicAdditive
FAnimNode_MakeDynamicAdditive::FAnimNode_MakeDynamicAdditive()
: bMeshSpaceAdditive(false)
{
}
void FAnimNode_MakeDynamicAdditive::Initialize_AnyThread(const FAnimationInitializeContext& Context)
{
DECLARE_SCOPE_HIERARCHICAL_COUNTER_ANIMNODE(Initialize_AnyThread)
FAnimNode_Base::Initialize_AnyThread(Context);
Base.Initialize(Context);
Additive.Initialize(Context);
}
void FAnimNode_MakeDynamicAdditive::CacheBones_AnyThread(const FAnimationCacheBonesContext& Context)
{
DECLARE_SCOPE_HIERARCHICAL_COUNTER_ANIMNODE(CacheBones_AnyThread)
Base.CacheBones(Context);
Additive.CacheBones(Context);
}
void FAnimNode_MakeDynamicAdditive::Update_AnyThread(const FAnimationUpdateContext& Context)
{
DECLARE_SCOPE_HIERARCHICAL_COUNTER_ANIMNODE(Update_AnyThread)
Base.Update(Context.FractionalWeight(1.f));
Additive.Update(Context.FractionalWeight(1.f));
TRACE_ANIM_NODE_VALUE(Context, TEXT("Mesh Space Additive"), bMeshSpaceAdditive);
}
void FAnimNode_MakeDynamicAdditive::Evaluate_AnyThread(FPoseContext& Output)
{
DECLARE_SCOPE_HIERARCHICAL_COUNTER_ANIMNODE(Evaluate_AnyThread)
ANIM_MT_SCOPE_CYCLE_COUNTER_VERBOSE(MakeDynamicAdditive, !IsInGameThread());
FScopedExpectsAdditiveOverride ScopedExpectsAdditiveOverride(Output, false);
FPoseContext BaseEvalContext(Output);
Base.Evaluate(BaseEvalContext);
Additive.Evaluate(Output);
if (bMeshSpaceAdditive)
{
FAnimationRuntime::ConvertPoseToMeshRotation(Output.Pose);
FAnimationRuntime::ConvertPoseToMeshRotation(BaseEvalContext.Pose);
}
FAnimationRuntime::ConvertPoseToAdditive(Output.Pose, BaseEvalContext.Pose);
Output.Curve.ConvertToAdditive(BaseEvalContext.Curve);
New Animation Attributes system, replacing Custom Attributes: + Attribute structures to UAnimDataModel * These are sampled/copied into AnimSequence whenever they change + Attribute related Notifies and Payloads + Controller API and Actions for Attribute related behaviour + Type traits (TAttributeTypeTraitsBase) to determine support functionality for user-defined attribute types + TAttributeContainer equivalent to TCustomAttributes, used for keeping track of attributes at runtime in a TMap similar fashion * Has two exported specializations FStack/Heap-AttributeContainer + IAttributeBlendOperator interface used for Attribute related operations in Anim graph * Allows for user-defined blending behaviour for their associated types + TAttributeBlendOperator providing out-of-the-box blending behaviour for user-defined types + FAttributeBlendData helper structure, this encapsulates and abstracts the blend / attribute operations * Exposes two iterators, allowing BlendOperator to loop through (type) overlapping Attributes and unique attributes + Float/Integer/String Animation Attribute structures used to support legacy TVariant CustomAttribute data types + Transform animation attribute structure to add support for single-FTransform based attributes + FAnimationAttributeIdentifier identifier used to reference an attribute in a script-friendly manor + AttributeTypes static API for registering Attribute types + FAttributeCurve providing a curve-type with an Attribute type as its underlying key-value + TWrappedAttribute helper structure to wrap end template operate on raw memory (TArray buffer) + Added tests for * Attribute related controller functionality and actions * Attribute curve key reduction * Evaluating attributes from AnimSequence * Attribute operations (blend, accumulate etc) * Functional testing for blendspace attribute evaluation and blending * Changed default attribute blend type to Blend vs Override * Updated FBX import/export paths to handle and use new Attribute data structures * Attribute data is now incorporated into animation source data DDC key * Deprecated Custom Attributes stored on AnimSequence get converted into their equivalent Attribute structures * Deprecated all previous CustomAttribute structures, APIs and files * Corrected some comments in UAnimDataController.h * Updated existing custom attribute tests to adhere to new blend expectations/behaviour * Updated AnimSequence resize tests to also incorporate an attribute curve * Changed layered bone blend to use .5 blend weight vs 1.0 to cover more behaviour * Added transform attribute used to compare against bone transform during pre-existing functional testing (blended only) - Deleted CustomAttributes details customization #rb Thomas.Sarkanen #fyi kiaran.ritchie, koray.hagen, timothy.daoust [CL 15568420 by Jurre deBaare in ue5-main branch]
2021-03-02 09:04:09 -04:00
UE::Anim::Attributes::ConvertToAdditive(BaseEvalContext.CustomAttributes, Output.CustomAttributes);
}
void FAnimNode_MakeDynamicAdditive::GatherDebugData(FNodeDebugData& DebugData)
{
DECLARE_SCOPE_HIERARCHICAL_COUNTER_ANIMNODE(GatherDebugData)
FString DebugLine = DebugData.GetNodeName(this);
DebugLine += FString::Printf(TEXT("(Mesh Space Additive: %s)"), bMeshSpaceAdditive ? TEXT("true") : TEXT("false"));
DebugData.AddDebugItem(DebugLine);
Base.GatherDebugData(DebugData.BranchFlow(1.f));
Additive.GatherDebugData(DebugData.BranchFlow(1.f));
}