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. Includes a thread-safety fix for 4.26 that hasnt made it over to 5.0 yet. 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 16071104 by Thomas Sarkanen in ue5-main branch]
213 lines
7.2 KiB
C++
213 lines
7.2 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "AnimGraphNode_AssetPlayerBase.h"
|
|
#include "EdGraphSchema_K2.h"
|
|
#include "Animation/AnimComposite.h"
|
|
#include "Animation/BlendSpace.h"
|
|
#include "Animation/AimOffsetBlendSpace.h"
|
|
#include "Animation/AimOffsetBlendSpace1D.h"
|
|
#include "AnimGraphNode_SequencePlayer.h"
|
|
#include "AnimGraphNode_SequenceEvaluator.h"
|
|
#include "AnimGraphNode_RotationOffsetBlendSpace.h"
|
|
#include "AnimGraphNode_BlendSpacePlayer.h"
|
|
#include "AnimGraphNode_BlendSpaceEvaluator.h"
|
|
#include "Animation/PoseAsset.h"
|
|
#include "AnimGraphNode_PoseBlendNode.h"
|
|
#include "AnimGraphNode_PoseByName.h"
|
|
#include "AnimGraphNode_PoseDriver.h"
|
|
#include "UObject/UObjectIterator.h"
|
|
#include "Animation/AnimLayerInterface.h"
|
|
#include "IAnimBlueprintGeneratedClassCompiledData.h"
|
|
#include "IAnimBlueprintCompilationContext.h"
|
|
#include "Animation/AnimSync.h"
|
|
#include "Animation/AnimAttributes.h"
|
|
#include "UObject/UE5MainStreamObjectVersion.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "UAnimGraphNode_AssetPlayerBase"
|
|
|
|
void UAnimGraphNode_AssetPlayerBase::Serialize(FArchive& Ar)
|
|
{
|
|
Super::Serialize(Ar);
|
|
|
|
Ar.UsingCustomVersion(FUE5MainStreamObjectVersion::GUID);
|
|
|
|
if(Ar.CustomVer(FUE5MainStreamObjectVersion::GUID) < FUE5MainStreamObjectVersion::AnimSyncGroupsExplicitSyncMethod)
|
|
{
|
|
if(SyncGroup_DEPRECATED.GroupName != NAME_None)
|
|
{
|
|
SyncGroup_DEPRECATED.Method = EAnimSyncMethod::SyncGroup;
|
|
}
|
|
}
|
|
|
|
if(Ar.CustomVer(FUE5MainStreamObjectVersion::GUID) < FUE5MainStreamObjectVersion::AnimNodeConstantDataRefactorPhase0)
|
|
{
|
|
FStructProperty* NodeProperty = GetFNodeProperty();
|
|
if(NodeProperty->Struct->IsChildOf(FAnimNode_AssetPlayerBase::StaticStruct()))
|
|
{
|
|
FAnimNode_AssetPlayerBase* Node = NodeProperty->ContainerPtrToValuePtr<FAnimNode_AssetPlayerBase>(this);
|
|
Node->SetGroupName(SyncGroup_DEPRECATED.GroupName);
|
|
Node->GetGroupRole(SyncGroup_DEPRECATED.GroupRole);
|
|
Node->SetGroupMethod(SyncGroup_DEPRECATED.Method);
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_AssetPlayerBase::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
|
{
|
|
Super::PostEditChangeProperty(PropertyChangedEvent);
|
|
|
|
FStructProperty* NodeProperty = GetFNodeProperty();
|
|
if(NodeProperty->Struct->IsChildOf(FAnimNode_AssetPlayerBase::StaticStruct()))
|
|
{
|
|
if(PropertyChangedEvent.GetPropertyName() == GET_MEMBER_NAME_CHECKED(FAnimNode_AssetPlayerBase, Method))
|
|
{
|
|
FAnimNode_AssetPlayerBase* Node = NodeProperty->ContainerPtrToValuePtr<FAnimNode_AssetPlayerBase>(this);
|
|
if(Node->GetGroupMethod() != EAnimSyncMethod::SyncGroup)
|
|
{
|
|
Node->SetGroupName(NAME_None);
|
|
Node->GetGroupRole(EAnimGroupRole::CanBeLeader);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_AssetPlayerBase::PinConnectionListChanged(UEdGraphPin* Pin)
|
|
{
|
|
Super::PinConnectionListChanged(Pin);
|
|
|
|
if (Pin->PinType.PinCategory == UEdGraphSchema_K2::PC_Object)
|
|
{
|
|
// recache visualization now an asset pin's connection is changed
|
|
if (const UEdGraphSchema* Schema = GetSchema())
|
|
{
|
|
Schema->ForceVisualizationCacheClear();
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_AssetPlayerBase::PinDefaultValueChanged(UEdGraphPin* Pin)
|
|
{
|
|
Super::PinDefaultValueChanged(Pin);
|
|
|
|
if (Pin->PinType.PinCategory == UEdGraphSchema_K2::PC_Object)
|
|
{
|
|
// recache visualization now an asset pin's default value has changed
|
|
if (const UEdGraphSchema* Schema = GetSchema())
|
|
{
|
|
Schema->ForceVisualizationCacheClear();
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_AssetPlayerBase::OnProcessDuringCompilation(IAnimBlueprintCompilationContext& InCompilationContext, IAnimBlueprintGeneratedClassCompiledData& OutCompiledData)
|
|
{
|
|
UBlueprint* Blueprint = GetBlueprint();
|
|
|
|
// Process Asset Player nodes to, if necessary cache off their node index for retrieval at runtime (used for evaluating Automatic Rule Transitions when using Layer nodes)
|
|
auto ProcessGraph = [this, &OutCompiledData](UEdGraph* Graph)
|
|
{
|
|
// Make sure we do not process the default AnimGraph
|
|
static const FName DefaultAnimGraphName("AnimGraph");
|
|
if (Graph->GetFName() != DefaultAnimGraphName)
|
|
{
|
|
FString GraphName = Graph->GetName();
|
|
// Also make sure we do not process any empty stub graphs
|
|
if (!GraphName.Contains(ANIM_FUNC_DECORATOR))
|
|
{
|
|
if (Graph->Nodes.ContainsByPredicate([this, &OutCompiledData](UEdGraphNode* Node) { return Node->NodeGuid == NodeGuid; }))
|
|
{
|
|
if (int32* IndexPtr = OutCompiledData.GetAnimBlueprintDebugData().NodeGuidToIndexMap.Find(NodeGuid))
|
|
{
|
|
FGraphAssetPlayerInformation& Info = OutCompiledData.GetGraphAssetPlayerInformation().FindOrAdd(FName(*GraphName));
|
|
Info.PlayerNodeIndices.AddUnique(*IndexPtr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
// Check for any definition of a layer graph
|
|
for (UEdGraph* Graph : Blueprint->FunctionGraphs)
|
|
{
|
|
ProcessGraph(Graph);
|
|
}
|
|
|
|
// Check for any implemented AnimLayer interface graphs
|
|
for (FBPInterfaceDescription& InterfaceDesc : Blueprint->ImplementedInterfaces)
|
|
{
|
|
// Only process Anim Layer interfaces
|
|
if (InterfaceDesc.Interface->IsChildOf<UAnimLayerInterface>())
|
|
{
|
|
for (UEdGraph* Graph : InterfaceDesc.Graphs)
|
|
{
|
|
ProcessGraph(Graph);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_AssetPlayerBase::ValidateAnimNodeDuringCompilation(USkeleton* ForSkeleton, FCompilerResultsLog& MessageLog)
|
|
{
|
|
Super::ValidateAnimNodeDuringCompilation(ForSkeleton, MessageLog);
|
|
|
|
FStructProperty* NodeProperty = GetFNodeProperty();
|
|
if(NodeProperty->Struct->IsChildOf(FAnimNode_AssetPlayerBase::StaticStruct()))
|
|
{
|
|
FAnimNode_AssetPlayerBase* Node = NodeProperty->ContainerPtrToValuePtr<FAnimNode_AssetPlayerBase>(this);
|
|
|
|
if(Node->GetGroupMethod() == EAnimSyncMethod::SyncGroup && Node->GetGroupName() == NAME_None)
|
|
{
|
|
MessageLog.Error(*LOCTEXT("NoSyncGroupSupplied", "Node @@ is set to use sync groups, but no sync group has been supplied").ToString(), this);
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_AssetPlayerBase::GetOutputLinkAttributes(FNodeAttributeArray& OutAttributes) const
|
|
{
|
|
OutAttributes.Add(UE::Anim::FAttributes::Curves);
|
|
OutAttributes.Add(UE::Anim::FAttributes::Attributes);
|
|
|
|
FStructProperty* NodeProperty = GetFNodeProperty();
|
|
if(NodeProperty->Struct->IsChildOf(FAnimNode_AssetPlayerBase::StaticStruct()))
|
|
{
|
|
const FAnimNode_AssetPlayerBase* Node = NodeProperty->ContainerPtrToValuePtr<FAnimNode_AssetPlayerBase>(this);
|
|
if(Node->GetGroupMethod() == EAnimSyncMethod::Graph)
|
|
{
|
|
OutAttributes.Add(UE::Anim::FAnimSync::Attribute);
|
|
}
|
|
}
|
|
}
|
|
|
|
UClass* GetNodeClassForAsset(const UClass* AssetClass)
|
|
{
|
|
UClass* NodeClass = nullptr;
|
|
|
|
// Iterate over all classes..
|
|
for (TObjectIterator<UClass> ClassIt; ClassIt; ++ClassIt)
|
|
{
|
|
UClass *Class = *ClassIt;
|
|
// Look for AnimGraphNode classes
|
|
if (Class->IsChildOf(UAnimGraphNode_Base::StaticClass()))
|
|
{
|
|
// See if this node is the 'primary handler' for this asset type
|
|
const UAnimGraphNode_Base* NodeCDO = Class->GetDefaultObject<UAnimGraphNode_Base>();
|
|
if (NodeCDO->SupportsAssetClass(AssetClass) == EAnimAssetHandlerType::PrimaryHandler)
|
|
{
|
|
NodeClass = Class;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return NodeClass;
|
|
}
|
|
|
|
bool SupportNodeClassForAsset(const UClass* AssetClass, UClass* NodeClass)
|
|
{
|
|
// Get node CDO
|
|
const UAnimGraphNode_Base* NodeCDO = NodeClass->GetDefaultObject<UAnimGraphNode_Base>();
|
|
// See if this node supports this asset type (primary or not)
|
|
return (NodeCDO->SupportsAssetClass(AssetClass) != EAnimAssetHandlerType::NotSupported);
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE |