Files
UnrealEngineUWP/Engine/Source/Editor/AnimGraph/Private/AnimGraphNode_BlendSpaceBase.cpp
Thomas Sarkanen d9c2b172f7 Skeleton compatibility improvements
Skeleton compatibility is now bi-directional. Specifying a compatible skeleton A -> B now implies B -> A.
Skeleton compatibility is now an editor-only concern. The runtime will attempt to do the 'best it can' via name -> name mappings. Only the editor will prevent assigning incompatible skeletons in (e.g.) asset pickers etc.
Skeleton compatibility checks in editor can now be disabled in the editor preferences (and each asset picker now has a checkbox option in its view settings that allows for quick access to this).

Moves FSkeletonRemapping to its own file (which is now private).
Skeleton remappings are now generated on demand on worker threads just before animation decompression and stored in a registry, guarded by FRWScopeLock for thread-safety.

Fixed some anim BP compiler edge cases where asset references on pins were not getting preloaded correctly, causing skeletons to be erroneously reported as missing.

Exposed the current asset registry filter in SAssetView so that menu extensions can access it (and use it to provide context)

#jira UE-166054
#jira UE-167355
#rb Jurre.deBaare,John.vanderBerg
#preflight 635902602e6690262afa86f9

[CL 22878911 by Thomas Sarkanen in ue5-main branch]
2022-11-01 06:25:59 -04:00

131 lines
3.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "AnimGraphNode_BlendSpaceBase.h"
#include "EdGraphSchema_K2_Actions.h"
#include "AnimGraphNode_BlendSpacePlayer.h"
#include "AnimGraphNode_RotationOffsetBlendSpace.h"
#include "Animation/AimOffsetBlendSpace.h"
#include "Animation/BlendSpace1D.h"
#include "Animation/AimOffsetBlendSpace1D.h"
#include "Animation/AnimRootMotionProvider.h"
#include "DetailLayoutBuilder.h"
#include "DetailCategoryBuilder.h"
#define LOCTEXT_NAMESPACE "AnimGraphNode_BlendSpaceBase"
/////////////////////////////////////////////////////
// UAnimGraphNode_BlendSpaceBase
UAnimGraphNode_BlendSpaceBase::UAnimGraphNode_BlendSpaceBase(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
FLinearColor UAnimGraphNode_BlendSpaceBase::GetNodeTitleColor() const
{
return FLinearColor(0.2f, 0.8f, 0.2f);
}
FSlateIcon UAnimGraphNode_BlendSpaceBase::GetIconAndTint(FLinearColor& OutColor) const
{
return FSlateIcon(FAppStyle::GetAppStyleSetName(), "ClassIcon.BlendSpace");
}
void UAnimGraphNode_BlendSpaceBase::CustomizePinData(UEdGraphPin* Pin, FName SourcePropertyName, int32 ArrayIndex) const
{
UBlendSpace * BlendSpace = GetBlendSpace();
if (BlendSpace != NULL)
{
if (SourcePropertyName == TEXT("X"))
{
Pin->PinFriendlyName = FText::FromString(BlendSpace->GetBlendParameter(0).DisplayName);
}
else if (SourcePropertyName == TEXT("Y"))
{
Pin->PinFriendlyName = FText::FromString(BlendSpace->GetBlendParameter(1).DisplayName);
Pin->bHidden = BlendSpace->IsA<UBlendSpace1D>() ? 1 : 0;
}
else if (SourcePropertyName == TEXT("Z"))
{
Pin->PinFriendlyName = FText::FromString(BlendSpace->GetBlendParameter(2).DisplayName);
}
}
}
void UAnimGraphNode_BlendSpaceBase::PreloadRequiredAssets()
{
PreloadRequiredAssetsHelper(GetBlendSpace(), FindPin(GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_BlendSpacePlayer, BlendSpace)));
Super::PreloadRequiredAssets();
}
void UAnimGraphNode_BlendSpaceBase::PostProcessPinName(const UEdGraphPin* Pin, FString& DisplayName) const
{
if(Pin->Direction == EGPD_Input)
{
UBlendSpace * BlendSpace = GetBlendSpace();
if(BlendSpace != NULL)
{
if(Pin->PinName == TEXT("X"))
{
DisplayName = BlendSpace->GetBlendParameter(0).DisplayName;
}
else if(Pin->PinName == TEXT("Y"))
{
DisplayName = BlendSpace->GetBlendParameter(1).DisplayName;
}
else if(Pin->PinName == TEXT("Z"))
{
DisplayName = BlendSpace->GetBlendParameter(2).DisplayName;
}
}
}
Super::PostProcessPinName(Pin, DisplayName);
}
void UAnimGraphNode_BlendSpaceBase::GetOutputLinkAttributes(FNodeAttributeArray& OutAttributes) const
{
Super::GetOutputLinkAttributes(OutAttributes);
if (UE::Anim::IAnimRootMotionProvider::Get())
{
OutAttributes.Add(UE::Anim::IAnimRootMotionProvider::AttributeName);
}
}
void UAnimGraphNode_BlendSpaceBase::CustomizeDetails(IDetailLayoutBuilder& InDetailBuilder)
{
const UBlendSpace* BlendSpace = GetBlendSpace();
if (BlendSpace)
{
TSharedRef<IPropertyHandle> XHandle = InDetailBuilder.GetProperty(TEXT("Node.X"), GetClass());
XHandle->SetPropertyDisplayName(FText::FromString(BlendSpace->GetBlendParameter(0).DisplayName));
TSharedRef<IPropertyHandle> YHandle = InDetailBuilder.GetProperty(TEXT("Node.Y"), GetClass());
if (BlendSpace->IsA<UBlendSpace1D>())
{
InDetailBuilder.HideProperty(YHandle);
}
else
{
YHandle->SetPropertyDisplayName(FText::FromString(BlendSpace->GetBlendParameter(1).DisplayName));
}
}
}
FText UAnimGraphNode_BlendSpaceBase::GetMenuCategory() const
{
return LOCTEXT("BlendSpaceCategory_Label", "Animation|Blend Spaces");
}
bool UAnimGraphNode_BlendSpaceBase::IsAimOffsetBlendSpace(const UClass* BlendSpaceClass)
{
return BlendSpaceClass->IsChildOf(UAimOffsetBlendSpace::StaticClass()) ||
BlendSpaceClass->IsChildOf(UAimOffsetBlendSpace1D::StaticClass());
}
#undef LOCTEXT_NAMESPACE