Files
UnrealEngineUWP/Engine/Source/Editor/AnimGraph/Public/AnimStateTransitionNode.h
benjamin jillich a6ef0d5b7f [UE-136096] Relinking transitions in anim graph state machines
[UE-168360] User can create a transition from a state into the entry state

* Relinking multiple transitions (transition nodes at once) when none of the transition nodes is selected.
* Selective relinking in case a subset of the transition nodes on a transitions are selected.
* Special case handling for transitions from entry state (they don't have a transition node connected).
* Drawing circle indicator around the arrow head in case the mouse cursor is approaching the transition.
* Hovering the arrow head of a transition highlights it by filling the circle with solid orange color and turning the arrow black.
* Ending the relink operation in empty space or the entry node will cancel the relink operation.
* Fixed bug that prevents creating new transitions ending in an entry state.

#jira https://jira.it.epicgames.com/browse/UE-136096
#jira https://jira.it.epicgames.com/browse/UE-168360
#preflight 636a169963037c10262bc421

[CL 23025287 by benjamin jillich in ue5-main branch]
2022-11-08 04:09:22 -05:00

182 lines
6.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "Misc/Guid.h"
#include "Animation/AnimTypes.h"
#include "Animation/AnimStateMachineTypes.h"
#include "Animation/BlendProfile.h"
#include "AnimStateNodeBase.h"
#include "AnimStateTransitionNode.generated.h"
class UCurveFloat;
class UEdGraph;
class UEdGraphPin;
UCLASS(MinimalAPI, config=Editor)
class UAnimStateTransitionNode : public UAnimStateNodeBase
{
GENERATED_UCLASS_BODY()
// The transition logic graph for this transition (returning a boolean)
UPROPERTY()
TObjectPtr<class UEdGraph> BoundGraph;
// The animation graph for this transition if it uses custom blending (returning a pose)
UPROPERTY()
TObjectPtr<class UEdGraph> CustomTransitionGraph;
// The priority order of this transition. If multiple transitions out of a state go
// true at the same time, the one with the smallest priority order will take precedent
UPROPERTY(EditAnywhere, Category=Transition)
int32 PriorityOrder;
// The duration to cross-fade for
UPROPERTY(EditAnywhere, Config, Category=Transition, Meta=(ClampMin="0.0"))
float CrossfadeDuration;
// The type of blending to use in the crossfade
UPROPERTY()
TEnumAsByte<ETransitionBlendMode::Type> CrossfadeMode_DEPRECATED;
UPROPERTY(EditAnywhere, Category=Transition)
EAlphaBlendOption BlendMode;
UPROPERTY(EditAnywhere, Category=Transition)
TObjectPtr<UCurveFloat> CustomBlendCurve;
// The blend profile to use to evaluate this transition per-bone
UPROPERTY(EditAnywhere, Category=Transition, meta=(UseAsBlendProfile=true))
TObjectPtr<UBlendProfile> BlendProfile;
// Try setting the rule automatically based on most relevant player node's remaining time and the CrossfadeDuration of the transition, ignoring the internal time
UPROPERTY(EditAnywhere, Category=Transition)
bool bAutomaticRuleBasedOnSequencePlayerInState;
// If SyncGroupName is specified, Transition will only be taken if the SyncGroup has valid markers (other transition rules still apply in addition to that).
UPROPERTY(EditAnywhere, Category = Transition)
FName SyncGroupNameToRequireValidMarkersRule;
// What transition logic to use
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Transition)
TEnumAsByte<ETransitionLogicType::Type> LogicType;
UPROPERTY(EditAnywhere, Category=Events)
FAnimNotifyEvent TransitionStart;
UPROPERTY(EditAnywhere, Category=Events)
FAnimNotifyEvent TransitionEnd;
UPROPERTY(EditAnywhere, Category=Events)
FAnimNotifyEvent TransitionInterrupt;
/** This transition can go both directions */
UPROPERTY(EditAnywhere, Category=Transition)
bool Bidirectional;
/** The rules for this transition may be shared with other transition nodes */
UPROPERTY()
bool bSharedRules;
/** The cross-fade settings of this node may be shared */
UPROPERTY()
bool bSharedCrossfade;
/** What we call this transition if we are shared ('Transition X to Y' can't be used since its used in multiple places) */
UPROPERTY()
FString SharedRulesName;
/** Shared rules guid useful when copying between different state machines */
UPROPERTY()
FGuid SharedRulesGuid;
/** Color we draw in the editor as if we are shared */
UPROPERTY()
FLinearColor SharedColor;
UPROPERTY()
FString SharedCrossfadeName;
UPROPERTY()
FGuid SharedCrossfadeGuid;
UPROPERTY()
int32 SharedCrossfadeIdx;
//~ Begin UObject Interface
virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
virtual void PostLoad() override;
virtual void Serialize(FArchive& Ar) override;
//~ End UObject Interface
//~ Begin UEdGraphNode Interface
virtual void AllocateDefaultPins() override;
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
virtual FText GetTooltipText() const override;
virtual FLinearColor GetNodeTitleColor() const override;
virtual void PinConnectionListChanged(UEdGraphPin* Pin) override;
virtual bool CanDuplicateNode() const override { return true; }
virtual void PrepareForCopying() override;
virtual void PostPasteNode() override;
virtual void PostPlacedNewNode() override;
virtual void DestroyNode() override;
virtual void ValidateNodeDuringCompilation(class FCompilerResultsLog& MessageLog) const override;
virtual UObject* GetJumpTargetForDoubleClick() const override;
virtual TArray<UEdGraph*> GetSubGraphs() const override;
//~ End UEdGraphNode Interface
//~ Begin UAnimStateNodeBase Interface
virtual UEdGraph* GetBoundGraph() const override { return BoundGraph; }
virtual void ClearBoundGraph() override { BoundGraph = nullptr; }
virtual UEdGraphPin* GetInputPin() const override { return Pins[0]; }
virtual UEdGraphPin* GetOutputPin() const override { return Pins[1]; }
//~ End UAnimStateNodeBase Interface
// @return the name of this state
ANIMGRAPH_API FString GetStateName() const override;
ANIMGRAPH_API UAnimStateNodeBase* GetPreviousState() const;
ANIMGRAPH_API UAnimStateNodeBase* GetNextState() const;
ANIMGRAPH_API void CreateConnections(UAnimStateNodeBase* PreviousState, UAnimStateNodeBase* NextState);
/**
* Relink transition head (where the arrow is of a state transition) to a new state.
* @param[in] NewTargetState The new transition target.
*/
ANIMGRAPH_API void RelinkHead(UAnimStateNodeBase* NewTargetState);
/**
* Helper function to gather the transition nodes to be relinked by taking the graph selection into account as well.
* For example when relinking a transition holding several transition nodes but only a few are selected to be relinked.
*/
ANIMGRAPH_API static TArray<UAnimStateTransitionNode*> GetListTransitionNodesToRelink(UEdGraphPin* SourcePin, UEdGraphPin* OldTargetPin, const TArray<UEdGraphNode*>& InSelectedGraphNodes);
ANIMGRAPH_API bool IsBoundGraphShared() const;
ANIMGRAPH_API void MakeRulesShareable(FString ShareName);
ANIMGRAPH_API void MakeCrossfadeShareable(FString ShareName);
ANIMGRAPH_API void UnshareRules();
ANIMGRAPH_API void UnshareCrossade();
ANIMGRAPH_API void UseSharedRules(const UAnimStateTransitionNode* Node);
ANIMGRAPH_API void UseSharedCrossfade(const UAnimStateTransitionNode* Node);
void CopyCrossfadeSettings(const UAnimStateTransitionNode* SrcNode);
void PropagateCrossfadeSettings();
ANIMGRAPH_API bool IsReverseTrans(const UAnimStateNodeBase* Node);
protected:
void CreateBoundGraph();
void CreateCustomTransitionGraph();
public:
UEdGraph* GetCustomTransitionGraph() const { return CustomTransitionGraph; }
/** Validates any currently set blend profile, ensuring it's valid for the current skeleton */
ANIMGRAPH_API bool ValidateBlendProfile();
};