You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Added a new animation graph node that hosts its own UBlendSpaceBase. Modified UBlendSpaceBase to allow for pose links to be evaluated as the sample points. The new blend space graphs can be spawned from existing UBlendSpace and UBlendSpace1D assets, or they can be created from scratch, or they can be converted from existing blendspace player nodes via the context menu. Fixed anim node conversion functions so that their transactions work correctly. Updated FBlueprintEditorUtils::IsGraphNameUnique to allow it to work with any object as the outer, not just UBlueprint. UBlueprint still has a special case for functions and events. This is to support GenerateUniqueGraphName within a scope (e.g. an outer graph). Formalized the concept of 'node sub-graphs' (as well as the composite node pattern a little). Previously a number of known node types that contained sub-graphs (e.g. UK2Node_Composite) had special case logic for dealing with node/graph deletion etc. Now any node can opt into this behaviour via the GetSubGraphs() override. Added status bar readouts for the blendspace grid, so we dont have to stuff the prompts into the tooltip any more. Moved anim BP related APIs out of FBlueprintEditor. They are always used via FAnimationBlueprintEditor. Refactored graph title bar widget creation out into a function to allow other document tab factories to create it. Altered breadcrumb trail click callbacks and SMyBlueprint::ExecuteAction to always JumpToHyperLink rather than calling OpenDocument directly. This allows unknown (to FBlueprintEditor) document types that reference objects to be correctly jumped to using the breadcrumb trail. Derived asset editors (i.e. FAnimationBlueprintEditor) can intercept the JumpToHyperlink call to ensure that the correct document is presented (i.e. the correct tab payload is generated). Instead of making yet another bunch of duplicated code for handling the various alpha blend options, refactored this into FAnimGraphNodeAlphaOptions (for editor code) and FAnimNodeAlphaOptions (for runtime code). Added OnCopyTermDefaultsToDefaultObject for per-node copying of default values from editor node to runtime node, rather than another special-case in the compiler. #rb Jurre.deBaare,Phillip.Kavan [CL 15177316 by Thomas Sarkanen in ue5-main branch]
189 lines
5.8 KiB
C++
189 lines
5.8 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "AnimGraphNode_LayeredBoneBlend.h"
|
|
#include "ToolMenus.h"
|
|
#include "Kismet2/BlueprintEditorUtils.h"
|
|
|
|
#include "AnimGraphCommands.h"
|
|
#include "ScopedTransaction.h"
|
|
|
|
#include "DetailLayoutBuilder.h"
|
|
#include "Kismet2/CompilerResultsLog.h"
|
|
/////////////////////////////////////////////////////
|
|
// UAnimGraphNode_LayeredBoneBlend
|
|
|
|
#define LOCTEXT_NAMESPACE "A3Nodes"
|
|
|
|
UAnimGraphNode_LayeredBoneBlend::UAnimGraphNode_LayeredBoneBlend(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
Node.AddPose();
|
|
}
|
|
|
|
FLinearColor UAnimGraphNode_LayeredBoneBlend::GetNodeTitleColor() const
|
|
{
|
|
return FLinearColor(0.2f, 0.8f, 0.2f);
|
|
}
|
|
|
|
FText UAnimGraphNode_LayeredBoneBlend::GetTooltipText() const
|
|
{
|
|
return LOCTEXT("AnimGraphNode_LayeredBoneBlend_Tooltip", "Layered blend per bone");
|
|
}
|
|
|
|
FText UAnimGraphNode_LayeredBoneBlend::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
|
{
|
|
return LOCTEXT("AnimGraphNode_LayeredBoneBlend_Title", "Layered blend per bone");
|
|
}
|
|
|
|
void UAnimGraphNode_LayeredBoneBlend::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
|
|
{
|
|
const FName PropertyName = (PropertyChangedEvent.Property ? PropertyChangedEvent.Property->GetFName() : NAME_None);
|
|
|
|
// Reconstruct node to show updates to PinFriendlyNames.
|
|
if (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_LayeredBoneBlend, BlendMode))
|
|
{
|
|
// If we change blend modes, we need to resize our containers
|
|
Node.ValidateData();
|
|
FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(GetBlueprint());
|
|
}
|
|
|
|
Super::PostEditChangeProperty(PropertyChangedEvent);
|
|
}
|
|
|
|
FString UAnimGraphNode_LayeredBoneBlend::GetNodeCategory() const
|
|
{
|
|
return TEXT("Blends");
|
|
}
|
|
|
|
void UAnimGraphNode_LayeredBoneBlend::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder)
|
|
{
|
|
TSharedRef<IPropertyHandle> NodeHandle = DetailBuilder.GetProperty(FName(TEXT("Node")), GetClass());
|
|
|
|
if (Node.BlendMode != ELayeredBoneBlendMode::BranchFilter)
|
|
{
|
|
DetailBuilder.HideProperty(NodeHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FAnimNode_LayeredBoneBlend, LayerSetup)));
|
|
}
|
|
|
|
if (Node.BlendMode != ELayeredBoneBlendMode::BlendMask)
|
|
{
|
|
DetailBuilder.HideProperty(NodeHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FAnimNode_LayeredBoneBlend, BlendMasks)));
|
|
}
|
|
|
|
Super::CustomizeDetails(DetailBuilder);
|
|
}
|
|
|
|
void UAnimGraphNode_LayeredBoneBlend::PreloadRequiredAssets()
|
|
{
|
|
// Preload our blend profiles in case they haven't been loaded by the skeleton yet.
|
|
if (Node.BlendMode == ELayeredBoneBlendMode::BlendMask)
|
|
{
|
|
int32 NumBlendMasks = Node.BlendMasks.Num();
|
|
for (int32 MaskIndex = 0; MaskIndex < NumBlendMasks; ++MaskIndex)
|
|
{
|
|
UBlendProfile* BlendMask = Node.BlendMasks[MaskIndex];
|
|
PreloadObject(BlendMask);
|
|
}
|
|
}
|
|
|
|
Super::PreloadRequiredAssets();
|
|
}
|
|
|
|
void UAnimGraphNode_LayeredBoneBlend::AddPinToBlendByFilter()
|
|
{
|
|
FScopedTransaction Transaction( LOCTEXT("AddPinToBlend", "AddPinToBlendByFilter") );
|
|
Modify();
|
|
|
|
Node.AddPose();
|
|
ReconstructNode();
|
|
FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(GetBlueprint());
|
|
}
|
|
|
|
void UAnimGraphNode_LayeredBoneBlend::RemovePinFromBlendByFilter(UEdGraphPin* Pin)
|
|
{
|
|
FScopedTransaction Transaction( LOCTEXT("RemovePinFromBlend", "RemovePinFromBlendByFilter") );
|
|
Modify();
|
|
|
|
FProperty* AssociatedProperty;
|
|
int32 ArrayIndex;
|
|
GetPinAssociatedProperty(GetFNodeType(), Pin, /*out*/ AssociatedProperty, /*out*/ ArrayIndex);
|
|
|
|
if (ArrayIndex != INDEX_NONE)
|
|
{
|
|
//@TODO: ANIMREFACTOR: Need to handle moving pins below up correctly
|
|
// setting up removed pins info
|
|
RemovedPinArrayIndex = ArrayIndex;
|
|
Node.RemovePose(ArrayIndex);
|
|
ReconstructNode();
|
|
FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(GetBlueprint());
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_LayeredBoneBlend::GetNodeContextMenuActions(UToolMenu* Menu, UGraphNodeContextMenuContext* Context) const
|
|
{
|
|
if (!Context->bIsDebugging)
|
|
{
|
|
{
|
|
FToolMenuSection& Section = Menu->AddSection("AnimGraphNodeLayeredBoneblend", LOCTEXT("LayeredBoneBlend", "Layered Bone Blend"));
|
|
if (Context->Pin != NULL)
|
|
{
|
|
// we only do this for normal BlendList/BlendList by enum, BlendList by Bool doesn't support add/remove pins
|
|
if (Context->Pin->Direction == EGPD_Input)
|
|
{
|
|
//@TODO: Only offer this option on arrayed pins
|
|
Section.AddMenuEntry(FAnimGraphCommands::Get().RemoveBlendListPin);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Section.AddMenuEntry(FAnimGraphCommands::Get().AddBlendListPin);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_LayeredBoneBlend::Serialize(FArchive& Ar)
|
|
{
|
|
Super::Serialize(Ar);
|
|
Node.ValidateData();
|
|
}
|
|
|
|
void UAnimGraphNode_LayeredBoneBlend::ValidateAnimNodeDuringCompilation(class USkeleton* ForSkeleton, class FCompilerResultsLog& MessageLog)
|
|
{
|
|
UAnimGraphNode_Base::ValidateAnimNodeDuringCompilation(ForSkeleton, MessageLog);
|
|
|
|
bool bCompilationError = false;
|
|
// Validate blend masks
|
|
if (Node.BlendMode == ELayeredBoneBlendMode::BlendMask)
|
|
{
|
|
int32 NumBlendMasks = Node.BlendMasks.Num();
|
|
for (int32 MaskIndex = 0; MaskIndex < NumBlendMasks; ++MaskIndex)
|
|
{
|
|
const UBlendProfile* BlendMask = Node.BlendMasks[MaskIndex];
|
|
if (BlendMask == nullptr)
|
|
{
|
|
MessageLog.Error(*FText::Format(LOCTEXT("LayeredBlendNullMask", "@@ has null BlendMask for Blend Pose {0}. "), FText::AsNumber(MaskIndex)).ToString(), this, BlendMask);
|
|
bCompilationError = true;
|
|
continue;
|
|
}
|
|
else if (BlendMask->Mode != EBlendProfileMode::BlendMask)
|
|
{
|
|
MessageLog.Error(*FText::Format(LOCTEXT("LayeredBlendProfileModeError", "@@ is using a BlendProfile(@@) without a BlendMask mode for Blend Pose {0}. "), FText::AsNumber(MaskIndex)).ToString(), this, BlendMask);
|
|
bCompilationError = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Don't rebuild the node's data if compilation failed. We may be attempting to do so with invalid data.
|
|
if (bCompilationError)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// ensure to cache the data
|
|
if (Node.IsCacheInvalid(ForSkeleton))
|
|
{
|
|
Node.RebuildCacheData(ForSkeleton);
|
|
}
|
|
}
|
|
#undef LOCTEXT_NAMESPACE
|