You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
71 lines
2.6 KiB
C++
71 lines
2.6 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "AnimGraphPrivatePCH.h"
|
|
#include "AnimGraphNode_LookAt.h"
|
|
|
|
/////////////////////////////////////////////////////
|
|
// UAnimGraphNode_LookAt
|
|
|
|
#define LOCTEXT_NAMESPACE "AnimGraph_LookAt"
|
|
|
|
UAnimGraphNode_LookAt::UAnimGraphNode_LookAt(const FPostConstructInitializeProperties& PCIP)
|
|
: Super(PCIP)
|
|
{
|
|
}
|
|
|
|
FText UAnimGraphNode_LookAt::GetControllerDescription() const
|
|
{
|
|
return LOCTEXT("LookAtNode", "Look At");
|
|
}
|
|
|
|
FString UAnimGraphNode_LookAt::GetKeywords() const
|
|
{
|
|
return TEXT("Look At, Follow, Trace, Track");
|
|
}
|
|
|
|
FText UAnimGraphNode_LookAt::GetTooltipText() const
|
|
{
|
|
return LOCTEXT("AnimGraphNode_LookAt_Tooltip", "This node allow a bone to trace or follow another bone");
|
|
}
|
|
|
|
FText UAnimGraphNode_LookAt::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
|
{
|
|
if ((TitleType == ENodeTitleType::ListView || TitleType == ENodeTitleType::MenuTitle) && (Node.BoneToModify.BoneName == NAME_None))
|
|
{
|
|
return GetControllerDescription();
|
|
}
|
|
// @TODO: the bone can be altered in the property editor, so we have to
|
|
// choose to mark this dirty when that happens for this to properly work
|
|
else //if (!CachedNodeTitles.IsTitleCached(TitleType))
|
|
{
|
|
FFormatNamedArguments Args;
|
|
Args.Add(TEXT("ControllerDescription"), GetControllerDescription());
|
|
Args.Add(TEXT("BoneName"), FText::FromName(Node.BoneToModify.BoneName));
|
|
|
|
// FText::Format() is slow, so we cache this to save on performance
|
|
if (TitleType == ENodeTitleType::ListView || TitleType == ENodeTitleType::MenuTitle)
|
|
{
|
|
CachedNodeTitles.SetCachedTitle(TitleType, FText::Format(LOCTEXT("AnimGraphNode_LookAt_ListTitle", "{ControllerDescription} - Bone: {BoneName}"), Args));
|
|
}
|
|
else
|
|
{
|
|
CachedNodeTitles.SetCachedTitle(TitleType, FText::Format(LOCTEXT("AnimGraphNode_LookAt_Title", "{ControllerDescription}\nBone: {BoneName}"), Args));
|
|
}
|
|
}
|
|
return CachedNodeTitles[TitleType];
|
|
}
|
|
|
|
void UAnimGraphNode_LookAt::Draw(FPrimitiveDrawInterface* PDI, USkeletalMeshComponent* SkelMeshComp) const
|
|
{
|
|
// this is not accurate debugging
|
|
// since i can't access the transient data of run-time instance, I have to calculate data from other way
|
|
// this technically means a frame delay, but it would be sufficient for debugging purpose.
|
|
FVector BoneLocation = SkelMeshComp->GetSocketLocation(Node.BoneToModify.BoneName);
|
|
FVector TargetLocation = (Node.LookAtBone.BoneName != NAME_None)? SkelMeshComp->GetSocketLocation(Node.LookAtBone.BoneName) : Node.LookAtLocation;
|
|
|
|
DrawWireStar(PDI, TargetLocation, 5.f, FLinearColor(1, 0, 0), SDPG_Foreground);
|
|
DrawDashedLine(PDI, BoneLocation, TargetLocation, FLinearColor(1, 1, 0), 2.f, SDPG_Foreground);
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|