Files
UnrealEngineUWP/Engine/Source/Editor/AnimGraph/Private/AnimGraphNode_StateMachineBase.cpp
Marc Audy 26836a22cd Copying //UE4/Dev-Framework to Dev-Main (//UE4/Dev-Main) @ 2868852
#lockdown Nick.Penwarden

==========================
MAJOR FEATURES + CHANGES
==========================

Change 2821607 on 2016/01/08 by Mieszko.Zielinski

	Added a way to limit amount of information logged by vlog by discarding logs from classes from outside of class whitelist #UE4

	This feature was followed by refactoring of functions taking FVisualLogEntry pointers to use references instead.

	#rb Lukasz.Furman
	#codereview John.Abercrombie

Change 2828384 on 2016/01/14 by Mieszko.Zielinski

	Back out of visual log refactor done as part of CL#2821607 #UE4

Change 2855722 on 2016/02/04 by Zak.Middleton

	#ue4 - Expose PrimitiveComponent GetCollisionEnabled(), IsCollisionEnabled(), IsQueryCollisionEnabled(), IsPhysicsCollisionEnabled() functions to blueprints.

	#rb Daniel.Broder, Ori.Cohen
	#codereview Bob.Tellez
	#jira UE-26411

Change 2855737 on 2016/02/04 by James.Golding

	Add test AssetUserData C++ class to QAGame

Change 2855739 on 2016/02/04 by James.Golding

	PR #1858 : Add abstract and editinlinenew to AssetUserData class, so derived classes can be added to assets via details panel
	https://github.com/EpicGames/UnrealEngine/pull/1858
	#github 1858
	#jira UE-24494
	#rb thomas.sarkanen

Change 2855842 on 2016/02/04 by James.Golding

	UE-23968 : Add clamping to Friction, Restitution, Density and RaiseMassToPower properties of PhysicalMaterial
	#codereview ori.cohen
	#rb thomas.sarkanen

Change 2855843 on 2016/02/04 by James.Golding

	PR #1984 : Add 'AssetUserData' support to AnimationAsset/Texture
	https://github.com/EpicGames/UnrealEngine/pull/1984
	#github 1984
	#jira UE-25913
	#rb thomas.sarkanen

Change 2855844 on 2016/02/04 by James.Golding

	UE-23176 Fix incorrect clamping in GenerateKDopAsSimpleCollision() which could cause degenerate hulls
	Also don't 'nudge' kdops if there are other primitives present, will offset from mesh we were fitting around
	#rb thomas.sarkanen

Change 2855850 on 2016/02/04 by Benn.Gallagher

	Update required LOD bones when associating a cloth chunk that uses bones that aren't weighted to that LOD
	#rb Martin.Wilson

Change 2856409 on 2016/02/04 by Zak.Middleton

	#ue4 - Change LogSpawn warnings to normal logs for cases that are common and valid during gameplay (failed due to collision at the target location, or failed because it is destroyed in the process of spawning, ie projectile spawned in a target).

	#codereview Jeff.Farris

Change 2857018 on 2016/02/05 by Benn.Gallagher

	Fixes for various anim graph related subgraph issues/crashes
	#rb Ben.Cosh

Change 2857193 on 2016/02/05 by Lukasz.Furman

	extended crowd agent interface to handle avoidance groups
	#ue4 UE-24823
	#1896

Change 2857200 on 2016/02/05 by Lukasz.Furman

	fixed memory leak in CrowdManager
	#ue UE-26516
	#2026
	#codereview Mieszko.Zielinski

Change 2857417 on 2016/02/05 by Lina.Halper

	Add keyword for animation functions

Change 2858854 on 2016/02/08 by Benn.Gallagher

	Fixed pose evaluator customizations being processed at the wrong time which caused properties to always be re-added even if removed from the details panel, causing duplicated entries.
	#jira UE-8421
	#rb Lina.Halper

Change 2858855 on 2016/02/08 by Benn.Gallagher

	Fixed blendspace players only reporting normalized time when using a time getter in an anim graph transition.
	#rb Lina.Halper

Change 2859159 on 2016/02/08 by Aaron.McLeran

	UE-25586 Fix for reporting audio memory usage

	- Realtime decompressed sounds that have CachedRealtimeFirstBuffers need to report the compressed asset size

Change 2859192 on 2016/02/08 by Laurent.Delayen

	Removed check disallowing cooked additive animations from using AnimationRelative and AnimationScale retargeting modes (on the root bone or editor).
	Skip AnimationRelative retargeting for baked additive animations since it gets cancelled out during the additive creation process.

	#rb martin.wilson
	#codereview lina.halper

Change 2859238 on 2016/02/08 by Lina.Halper

	Git pull request #1895

Change 2859239 on 2016/02/08 by Lina.Halper

	Git pull request #1813

Change 2859453 on 2016/02/08 by Aaron.McLeran

[CL 2868856 by Marc Audy in Main branch]
2016-02-16 13:35:21 -05:00

185 lines
5.6 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "AnimGraphPrivatePCH.h"
#include "GraphEditorActions.h"
#include "ScopedTransaction.h"
#include "EdGraphUtilities.h"
#include "Kismet2NameValidators.h"
#include "AnimationGraph.h"
#include "AnimationStateMachineGraph.h"
#include "AnimationStateMachineSchema.h"
#include "AnimGraphNode_StateMachine.h"
#include "AnimGraphNode_StateMachineBase.h"
/////////////////////////////////////////////////////
// FAnimStateMachineNodeNameValidator
class FAnimStateMachineNodeNameValidator : public FStringSetNameValidator
{
public:
FAnimStateMachineNodeNameValidator(const UAnimGraphNode_StateMachineBase* InStateMachineNode)
: FStringSetNameValidator(FString())
{
TArray<UAnimGraphNode_StateMachineBase*> Nodes;
UAnimationGraph* StateMachine = CastChecked<UAnimationGraph>(InStateMachineNode->GetOuter());
StateMachine->GetNodesOfClassEx<UAnimGraphNode_StateMachine, UAnimGraphNode_StateMachineBase>(Nodes);
for (auto Node : Nodes)
{
if (Node != InStateMachineNode)
{
Names.Add(Node->GetStateMachineName());
}
}
}
};
/////////////////////////////////////////////////////
// UAnimGraphNode_StateMachineBase
#define LOCTEXT_NAMESPACE "A3Nodes"
UAnimGraphNode_StateMachineBase::UAnimGraphNode_StateMachineBase(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
FLinearColor UAnimGraphNode_StateMachineBase::GetNodeTitleColor() const
{
return FLinearColor(0.8f, 0.8f, 0.8f);
}
FText UAnimGraphNode_StateMachineBase::GetTooltipText() const
{
return LOCTEXT("StateMachineTooltip", "Animation State Machine");
}
FText UAnimGraphNode_StateMachineBase::GetNodeTitle(ENodeTitleType::Type TitleType) const
{
if ((TitleType == ENodeTitleType::MenuTitle || TitleType == ENodeTitleType::ListView) && (EditorStateMachineGraph == nullptr))
{
return LOCTEXT("AddNewStateMachine", "Add New State Machine...");
}
else if (EditorStateMachineGraph == nullptr)
{
if (TitleType == ENodeTitleType::FullTitle)
{
return LOCTEXT("NullStateMachineFullTitle", "Error: No Graph\nState Machine");
}
else
{
return LOCTEXT("ErrorNoGraph", "Error: No Graph");
}
}
else if (TitleType == ENodeTitleType::FullTitle)
{
if (CachedFullTitle.IsOutOfDate(this))
{
FFormatNamedArguments Args;
Args.Add(TEXT("Title"), FText::FromName(EditorStateMachineGraph->GetFName()));
// FText::Format() is slow, so we cache this to save on performance
CachedFullTitle.SetCachedText(FText::Format(LOCTEXT("StateMachineFullTitle", "{Title}\nState Machine"), Args), this);
}
return CachedFullTitle;
}
return FText::FromName(EditorStateMachineGraph->GetFName());
}
FString UAnimGraphNode_StateMachineBase::GetNodeCategory() const
{
return TEXT("State Machines");
}
void UAnimGraphNode_StateMachineBase::PostPlacedNewNode()
{
// Create a new animation graph
check(EditorStateMachineGraph == NULL);
EditorStateMachineGraph = CastChecked<UAnimationStateMachineGraph>(FBlueprintEditorUtils::CreateNewGraph(this, NAME_None, UAnimationStateMachineGraph::StaticClass(), UAnimationStateMachineSchema::StaticClass()));
check(EditorStateMachineGraph);
EditorStateMachineGraph->OwnerAnimGraphNode = this;
// Find an interesting name
TSharedPtr<INameValidatorInterface> NameValidator = FNameValidatorFactory::MakeValidator(this);
FBlueprintEditorUtils::RenameGraphWithSuggestion(EditorStateMachineGraph, NameValidator, TEXT("New State Machine"));
// Initialize the anim graph
const UEdGraphSchema* Schema = EditorStateMachineGraph->GetSchema();
Schema->CreateDefaultNodesForGraph(*EditorStateMachineGraph);
// Add the new graph as a child of our parent graph
UEdGraph* ParentGraph = GetGraph();
if(ParentGraph->SubGraphs.Find(EditorStateMachineGraph) == INDEX_NONE)
{
ParentGraph->Modify();
ParentGraph->SubGraphs.Add(EditorStateMachineGraph);
}
}
UObject* UAnimGraphNode_StateMachineBase::GetJumpTargetForDoubleClick() const
{
// Open the state machine graph
return EditorStateMachineGraph;
}
void UAnimGraphNode_StateMachineBase::DestroyNode()
{
UEdGraph* GraphToRemove = EditorStateMachineGraph;
EditorStateMachineGraph = NULL;
Super::DestroyNode();
if (GraphToRemove)
{
UBlueprint* Blueprint = GetBlueprint();
GraphToRemove->Modify();
FBlueprintEditorUtils::RemoveGraph(Blueprint, GraphToRemove, EGraphRemoveFlags::Recompile);
}
}
void UAnimGraphNode_StateMachineBase::PostPasteNode()
{
Super::PostPasteNode();
// Add the new graph as a child of our parent graph
UEdGraph* ParentGraph = CastChecked<UEdGraph>(GetGraph());
if(ParentGraph->SubGraphs.Find(EditorStateMachineGraph) == INDEX_NONE)
{
ParentGraph->SubGraphs.Add(EditorStateMachineGraph);
}
// Find an interesting name
TSharedPtr<INameValidatorInterface> NameValidator = FNameValidatorFactory::MakeValidator(this);
FBlueprintEditorUtils::RenameGraphWithSuggestion(EditorStateMachineGraph, NameValidator, EditorStateMachineGraph->GetName());
//restore transactional flag that is lost during copy/paste process
EditorStateMachineGraph->SetFlags(RF_Transactional);
}
FString UAnimGraphNode_StateMachineBase::GetStateMachineName()
{
return (EditorStateMachineGraph != NULL) ? *(EditorStateMachineGraph->GetName()) : TEXT("(null)");
}
TSharedPtr<class INameValidatorInterface> UAnimGraphNode_StateMachineBase::MakeNameValidator() const
{
return MakeShareable(new FAnimStateMachineNodeNameValidator(this));
}
FString UAnimGraphNode_StateMachineBase::GetDocumentationLink() const
{
return TEXT("Shared/GraphNodes/AnimationStateMachine");
}
void UAnimGraphNode_StateMachineBase::OnRenameNode(const FString& NewName)
{
FBlueprintEditorUtils::RenameGraph(EditorStateMachineGraph, NewName);
}
#undef LOCTEXT_NAMESPACE