You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Per-node constant data is now held on a generated struct as part of sparse class data. Per-node mutable data (i.e. pin links/property access mappings) is now held on a generated 'mutable data' struct that is compiled as part of the generated class. The anim BP compiler is now extended more conventionally using UAnimBlueprintExtension, derived from UBlueprintExtension. This directly replaces the older 'compiler handler' pattern that was added in an emergency fashion for 4.26. Anim graph nodes now request their required extensions and these are held on the UAnimBlueprint in the UBlueprint::Extensions array. The Extensions array is potentially refreshed with any node addition or removal. The Extensions array is force-refreshed each time an anim BP is compiled for the first time to deal with newly added or removed requirements. Const-corrected a bunch of UAnimInstance/FAnimInstanceProxy APIs that rely on (now truly) const data. Added a split state/constant version of FInputScaleBiasClamp to allow some of its data to be split into constants. Tweaked alignment/ordering of FPoseLinkBase to save a few bytes per pose link. Deprecated FAnimNode_Base::OverrideAsset in favor of a more UAnimGraphNode_Base-based approach. Individual nodes can still have runtime overrides via specific accessors. The new approach will also give us the oppurtunity to override multiple assets per node if required in the future. Moved property access into Engine module & removed event support from it - this was never used. Reworked property access compilation API a little - construction/lifetime was a bit confusing previously. Optimized path used to create UK2Node_StructMemberSet nodes in per-node custom events. When using mutable data, the structure used is large and very sparsely connected (i.e. only a few properties are written) so we only create pins that are actually going to be used, rather than creating all of them and conly connecting a few. Patched the following nodes to use the new data approach: - Asset players (sequences, blendspaces, aim offsets) - Blend lists - Ref poses - Roots #rb Jurre.deBaare, Martin.Wilson, Keith.Yerex [CL 16090510 by Thomas Sarkanen in ue5-main branch]
126 lines
4.5 KiB
C++
126 lines
4.5 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "AnimGraphNode_SaveCachedPose.h"
|
|
#include "Kismet2/BlueprintEditorUtils.h"
|
|
|
|
#include "BlueprintNodeSpawner.h"
|
|
#include "BlueprintActionDatabaseRegistrar.h"
|
|
#include "AnimBlueprintExtension_CachedPose.h"
|
|
|
|
/////////////////////////////////////////////////////
|
|
// FCachedPoseNameValidator
|
|
|
|
class FCachedPoseNameValidator : public FStringSetNameValidator
|
|
{
|
|
public:
|
|
FCachedPoseNameValidator(class UBlueprint* InBlueprint, const FString& InExistingName)
|
|
: FStringSetNameValidator(InExistingName)
|
|
{
|
|
TArray<UAnimGraphNode_SaveCachedPose*> Nodes;
|
|
FBlueprintEditorUtils::GetAllNodesOfClass<UAnimGraphNode_SaveCachedPose>(InBlueprint, Nodes);
|
|
|
|
for (auto Node : Nodes)
|
|
{
|
|
Names.Add(Node->CacheName);
|
|
}
|
|
}
|
|
};
|
|
|
|
/////////////////////////////////////////////////////
|
|
// UAnimGraphNode_ComponentToLocalSpace
|
|
|
|
#define LOCTEXT_NAMESPACE "A3Nodes"
|
|
|
|
UAnimGraphNode_SaveCachedPose::UAnimGraphNode_SaveCachedPose(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
bCanRenameNode = true;
|
|
}
|
|
|
|
FText UAnimGraphNode_SaveCachedPose::GetTooltipText() const
|
|
{
|
|
return LOCTEXT("SaveCachedPose_Tooltip", "Denotes an animation tree that can be referenced elsewhere in the blueprint, which will be evaluated at most once per frame and then cached.");
|
|
}
|
|
|
|
FText UAnimGraphNode_SaveCachedPose::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
|
{
|
|
if (TitleType == ENodeTitleType::EditableTitle)
|
|
{
|
|
return FText::FromString(CacheName);
|
|
}
|
|
else if ((TitleType == ENodeTitleType::MenuTitle) && CacheName.IsEmpty())
|
|
{
|
|
return LOCTEXT("NewSaveCachedPose", "New Save cached pose...");
|
|
}
|
|
else if (CachedNodeTitle.IsOutOfDate(this))
|
|
{
|
|
FFormatNamedArguments Args;
|
|
Args.Add(TEXT("NodeTitle"), FText::FromString(CacheName));
|
|
CachedNodeTitle.SetCachedText(FText::Format(LOCTEXT("AnimGraphNode_SaveCachedPose_Title", "Save cached pose '{NodeTitle}'"), Args), this);
|
|
}
|
|
return CachedNodeTitle;
|
|
}
|
|
|
|
FString UAnimGraphNode_SaveCachedPose::GetNodeCategory() const
|
|
{
|
|
return TEXT("Cached Poses");
|
|
}
|
|
|
|
void UAnimGraphNode_SaveCachedPose::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const
|
|
{
|
|
auto PostSpawnSetupLambda = [](UEdGraphNode* NewNode, bool bIsTemplateNode)
|
|
{
|
|
UAnimGraphNode_SaveCachedPose* CachedPoseNode = CastChecked<UAnimGraphNode_SaveCachedPose>(NewNode);
|
|
// we use an empty CacheName in GetNodeTitle() to relay the proper menu title
|
|
if (!bIsTemplateNode)
|
|
{
|
|
// @TODO: is the idea that this name is unique? what if Rand() hit twice? why not MakeUniqueObjectName()?
|
|
CachedPoseNode->CacheName = TEXT("SavedPose") + FString::FromInt(FMath::Rand());
|
|
}
|
|
};
|
|
|
|
// actions get registered under specific object-keys; the idea is that
|
|
// actions might have to be updated (or deleted) if their object-key is
|
|
// mutated (or removed)... here we use the node's class (so if the node
|
|
// type disappears, then the action should go with it)
|
|
UClass* ActionKey = GetClass();
|
|
// to keep from needlessly instantiating a UBlueprintNodeSpawner, first
|
|
// check to make sure that the registrar is looking for actions of this type
|
|
// (could be regenerating actions for a specific asset, and therefore the
|
|
// registrar would only accept actions corresponding to that asset)
|
|
if (ActionRegistrar.IsOpenForRegistration(ActionKey))
|
|
{
|
|
UBlueprintNodeSpawner* NodeSpawner = UBlueprintNodeSpawner::Create(GetClass());
|
|
NodeSpawner->CustomizeNodeDelegate = UBlueprintNodeSpawner::FCustomizeNodeDelegate::CreateStatic(PostSpawnSetupLambda);
|
|
|
|
ActionRegistrar.AddBlueprintAction(ActionKey, NodeSpawner);
|
|
}
|
|
}
|
|
|
|
bool UAnimGraphNode_SaveCachedPose::IsCompatibleWithGraph(const UEdGraph* TargetGraph) const
|
|
{
|
|
//EGraphType GraphType = TargetGraph->GetSchema()->GetGraphType(TargetGraph);
|
|
//bool const bIsNotStateMachine = (GraphType != GT_StateMachine);
|
|
|
|
bool const bIsNotStateMachine = TargetGraph->GetOuter()->IsA(UAnimBlueprint::StaticClass());
|
|
return bIsNotStateMachine && Super::IsCompatibleWithGraph(TargetGraph);
|
|
}
|
|
|
|
void UAnimGraphNode_SaveCachedPose::OnRenameNode(const FString& NewName)
|
|
{
|
|
CacheName = NewName;
|
|
FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(GetBlueprint());
|
|
}
|
|
|
|
TSharedPtr<class INameValidatorInterface> UAnimGraphNode_SaveCachedPose::MakeNameValidator() const
|
|
{
|
|
return MakeShareable(new FCachedPoseNameValidator(GetBlueprint(), CacheName));
|
|
}
|
|
|
|
void UAnimGraphNode_SaveCachedPose::GetRequiredExtensions(TArray<TSubclassOf<UAnimBlueprintExtension>>& OutExtensions) const
|
|
{
|
|
OutExtensions.Add(UAnimBlueprintExtension_CachedPose::StaticClass());
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|