Files
UnrealEngineUWP/Engine/Source/Runtime/AnimGraphRuntime/Private/AnimNodes/AnimNode_RotateRootBone.cpp
marc audy 311f7464bf Updated ../Engine/Source/Runtime/... to inline gen.cpp files
Before:
3648 unity files
Total CPU Time: 47886.140625 s
Total time in Parallel executor: 498.81 seconds

After:
3548 unity files
Total CPU Time: 46643.828125 s
Total time in Parallel executor: 486.06 seconds

#jira
#preflight

[CL 22173263 by marc audy in ue5-main branch]
2022-09-24 13:57:58 -04:00

88 lines
2.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "AnimNodes/AnimNode_RotateRootBone.h"
#include "Animation/AnimTrace.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(AnimNode_RotateRootBone)
/////////////////////////////////////////////////////
// FAnimNode_RotateRootBone
void FAnimNode_RotateRootBone::Initialize_AnyThread(const FAnimationInitializeContext& Context)
{
DECLARE_SCOPE_HIERARCHICAL_COUNTER_ANIMNODE(Initialize_AnyThread)
FAnimNode_Base::Initialize_AnyThread(Context);
BasePose.Initialize(Context);
PitchScaleBiasClamp.Reinitialize();
YawScaleBiasClamp.Reinitialize();
}
void FAnimNode_RotateRootBone::CacheBones_AnyThread(const FAnimationCacheBonesContext& Context)
{
DECLARE_SCOPE_HIERARCHICAL_COUNTER_ANIMNODE(CacheBones_AnyThread)
BasePose.CacheBones(Context);
}
void FAnimNode_RotateRootBone::Update_AnyThread(const FAnimationUpdateContext& Context)
{
DECLARE_SCOPE_HIERARCHICAL_COUNTER_ANIMNODE(Update_AnyThread)
GetEvaluateGraphExposedInputs().Execute(Context);
BasePose.Update(Context);
ActualPitch = PitchScaleBiasClamp.ApplyTo(Pitch, Context.GetDeltaTime());
ActualYaw = YawScaleBiasClamp.ApplyTo(Yaw, Context.GetDeltaTime());
TRACE_ANIM_NODE_VALUE(Context, TEXT("Pitch"), ActualPitch);
TRACE_ANIM_NODE_VALUE(Context, TEXT("Yaw"), ActualYaw);
}
void FAnimNode_RotateRootBone::Evaluate_AnyThread(FPoseContext& Output)
{
DECLARE_SCOPE_HIERARCHICAL_COUNTER_ANIMNODE(Evaluate_AnyThread)
// Evaluate the input
BasePose.Evaluate(Output);
checkSlow(!FMath::IsNaN(ActualYaw) && FMath::IsFinite(ActualYaw));
checkSlow(!FMath::IsNaN(ActualPitch) && FMath::IsFinite(ActualPitch));
if (!FMath::IsNearlyZero(ActualPitch, KINDA_SMALL_NUMBER) || !FMath::IsNearlyZero(ActualYaw, KINDA_SMALL_NUMBER))
{
// Build our desired rotation
const FRotator DeltaRotation(ActualPitch, ActualYaw, 0.f);
const FQuat DeltaQuat(DeltaRotation);
const FQuat MeshToComponentQuat(MeshToComponent);
// Convert our rotation from Component Space to Mesh Space.
const FQuat MeshSpaceDeltaQuat = MeshToComponentQuat.Inverse() * DeltaQuat * MeshToComponentQuat;
// Apply rotation to root bone.
FCompactPoseBoneIndex RootBoneIndex(0);
Output.Pose[RootBoneIndex].SetRotation(Output.Pose[RootBoneIndex].GetRotation() * MeshSpaceDeltaQuat);
Output.Pose[RootBoneIndex].NormalizeRotation();
}
}
void FAnimNode_RotateRootBone::GatherDebugData(FNodeDebugData& DebugData)
{
DECLARE_SCOPE_HIERARCHICAL_COUNTER_ANIMNODE(GatherDebugData)
FString DebugLine = DebugData.GetNodeName(this);
DebugLine += FString::Printf(TEXT("Pitch(%.2f) Yaw(%.2f)"), ActualPitch, ActualYaw);
DebugData.AddDebugItem(DebugLine);
BasePose.GatherDebugData(DebugData);
}
FAnimNode_RotateRootBone::FAnimNode_RotateRootBone()
: Pitch(0.0f)
, Yaw(0.0f)
, MeshToComponent(FRotator::ZeroRotator)
, ActualPitch(0.f)
, ActualYaw(0.f)
{
}