Files
UnrealEngineUWP/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_ObserveBone.cpp
helge mathee a6a2a333c0 Final copy-up for Control Rig Task Stream.
Merging using Fortnite_Main<->Fortnite_ControlRig

#rb none


#ROBOMERGE-OWNER: helge.mathee
#ROBOMERGE-AUTHOR: helge.mathee
#ROBOMERGE-SOURCE: CL 7321580 via CL 7323175
#ROBOMERGE-BOT: (v371-7306989)

[CL 7323351 by helge mathee in Main branch]
2019-07-16 11:49:59 -04:00

63 lines
2.3 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "BoneControllers/AnimNode_ObserveBone.h"
#include "AnimationRuntime.h"
#include "Animation/AnimInstanceProxy.h"
/////////////////////////////////////////////////////
// FAnimNode_ObserveBone
FAnimNode_ObserveBone::FAnimNode_ObserveBone()
: DisplaySpace(BCS_ComponentSpace)
, bRelativeToRefPose(false)
, Translation(FVector::ZeroVector)
, Rotation(FRotator::ZeroRotator)
, Scale(FVector(1.0f))
{
}
void FAnimNode_ObserveBone::GatherDebugData(FNodeDebugData& DebugData)
{
DECLARE_SCOPE_HIERARCHICAL_COUNTER_ANIMNODE(GatherDebugData)
const FString DebugLine = FString::Printf(TEXT("(Bone: %s has T(%s), R(%s), S(%s))"), *BoneToObserve.BoneName.ToString(), *Translation.ToString(), *Rotation.Euler().ToString(), *Scale.ToString());
DebugData.AddDebugItem(DebugLine);
ComponentPose.GatherDebugData(DebugData);
}
void FAnimNode_ObserveBone::EvaluateSkeletalControl_AnyThread(FComponentSpacePoseContext& Output, TArray<FBoneTransform>& OutBoneTransforms)
{
DECLARE_SCOPE_HIERARCHICAL_COUNTER_ANIMNODE(EvaluateSkeletalControl_AnyThread)
const FBoneContainer& BoneContainer = Output.Pose.GetPose().GetBoneContainer();
const FCompactPoseBoneIndex BoneIndex = BoneToObserve.GetCompactPoseIndex(BoneContainer);
FTransform BoneTM = Output.Pose.GetComponentSpaceTransform(BoneIndex);
// Convert to the specific display space if necessary
FAnimationRuntime::ConvertCSTransformToBoneSpace(Output.AnimInstanceProxy->GetComponentTransform(), Output.Pose, BoneTM, BoneIndex, DisplaySpace);
// Convert to be relative to the ref pose if necessary
if (bRelativeToRefPose)
{
const FTransform& SourceOrigRef = BoneContainer.GetRefPoseArray()[BoneToObserve.BoneIndex];
BoneTM = BoneTM.GetRelativeTransform(SourceOrigRef);
}
// Cache off the values for display
Translation = BoneTM.GetTranslation();
Rotation = BoneTM.GetRotation().Rotator();
Scale = BoneTM.GetScale3D();
}
bool FAnimNode_ObserveBone::IsValidToEvaluate(const USkeleton* Skeleton, const FBoneContainer& RequiredBones)
{
return (BoneToObserve.IsValidToEvaluate(RequiredBones));
}
void FAnimNode_ObserveBone::InitializeBoneReferences(const FBoneContainer& RequiredBones)
{
DECLARE_SCOPE_HIERARCHICAL_COUNTER_ANIMNODE(InitializeBoneReferences)
BoneToObserve.Initialize(RequiredBones);
}