Files
UnrealEngineUWP/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_ObserveBone.cpp
Matthew Griffin bb70b349ce Merging CL 2804086 from //UE4/Release-4.11 to Dev-Main (//UE4/Dev-Main) to isolate copyright update
#lockdown Nick.Penwarden

[CL 2819020 by Matthew Griffin in Main branch]
2016-01-07 08:17:16 -05:00

59 lines
2.0 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "AnimGraphRuntimePrivatePCH.h"
#include "BoneControllers/AnimNode_ObserveBone.h"
#include "AnimationRuntime.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)
{
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::EvaluateBoneTransforms(USkeletalMeshComponent* SkelComp, FCSPose<FCompactPose>& MeshBases, TArray<FBoneTransform>& OutBoneTransforms)
{
const FBoneContainer BoneContainer = MeshBases.GetPose().GetBoneContainer();
const FCompactPoseBoneIndex BoneIndex = BoneToObserve.GetCompactPoseIndex(BoneContainer);
FTransform BoneTM = MeshBases.GetComponentSpaceTransform(BoneIndex);
// Convert to the specific display space if necessary
FAnimationRuntime::ConvertCSTransformToBoneSpace(SkelComp, MeshBases, 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.IsValid(RequiredBones));
}
void FAnimNode_ObserveBone::InitializeBoneReferences(const FBoneContainer& RequiredBones)
{
BoneToObserve.Initialize(RequiredBones);
}