Files
UnrealEngineUWP/Engine/Source/Editor/AnimGraph/Private/AnimStateNode.cpp
Thomas Sarkanen 40cfc29928 Copying //UE4/Dev-AnimPhys to //UE4/Dev-Main (Source: //UE4/Dev-AnimPhys @ 3537446)
#lockdown Nick.Penwarden

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

Change 3491514 by Jonathan.Poncelet

	Added new functions AddTorqueDegrees and AddAngularImpulseDegrees to UPrimitiveComponent

	Provided automated tests ensure that the angular velocity is consistent for each of the new functions by comparing it with an equivalent call to the original function.

	#jira UE-39757 Torque and angular velocity are inconsistent

	#automation Tests verify that AddTorque/AddTorqueDegrees and AddAngularImpulse/AddAngularImpulseDegrees both produce the correct angular velocity, when passed the same value in different units.

Change 3495025 by Jonathan.Poncelet

	Back out changelist 3491514

	"Added new functions AddTorqueDegrees and AddAngularImpulseDegrees to UPrimitiveComponent

	Provided automated tests ensure that the angular velocity is consistent for each of the new functions by comparing it with an equivalent call to the original function.

	#jira UE-39757 Torque and angular velocity are inconsistent

	#automation Tests verify that AddTorque/AddTorqueDegrees and AddAngularImpulse/AddAngularImpulseDegrees both produce the correct angular velocity, when passed the same value in different units."

Change 3505086 by Danny.Bouimad

	Updating test content in TM-AnimPhys and TM-TangentNormals

Change 3505375 by James.Cobbett

	Automating Settle test map

Change 3505714 by Lina.Halper

	Add more descriptive pin name and node text for constraint node

	#jira: UE-45895
	#rb: Ori.Cohen

Change 3505731 by Lina.Halper

	1. Renamed FTargetReference to FBoneSocketTarget

	 - this allows users to choose either bone or socket as a target.

	2. Two Bone IK refactor to use FBoneSocketTarget

	- Effector Target and Joint Target are converted to use FBoneSocketTarget, so you can use socket or bone

	- Effector Location and Joint Target Location is used as offset from target location, so you can use as a combination of FBoneSocketTarget

	- Editor code now uses runtime node instead of Graph Node, will have more discussion with Tom on this.

	3. FABRIK refactor to use FBoneSocketTarget

	#code review: Laurent.Delayen, Martin.Wilson, Thomas.Sarkanen
	#rb: Laurent.Delayen

Change 3505770 by Lina.Halper

	IK automation test

	#jira: UE-46250

Change 3506369 by Lina.Halper

	Fix initialization order issue

	#rb:none
	#rnx

Change 3506697 by Martin.Wilson

	Fix root motion when using ForceAnimRate's of more than 1

	#jira UE-39021

Change 3506765 by Lina.Halper

	It's confusing to see the same name multiple times. So fixed so that this utility functions show up later, and then added function instead.

	#jira: UE-45871
	#rb: Martin.Wilson

Change 3506787 by Ori.Cohen

	Added single threaded physx tasks stats using "stat PhysXTasks"

Change 3506803 by Ori.Cohen

	Turn off debug code which was submitted by accident

Change 3506840 by Jurre.deBaare

	Fix for automation vertex-color warning

Change 3506917 by Danny.Bouimad

	Checking in Edits made to AnimBP Constraint Content

Change 3507045 by James.Cobbett

	Submitting final Settle test map updates

Change 3509208 by Danny.Bouimad

	Checking in content changes for TM-SuspendCloth

Change 3509235 by James.Cobbett

	Deleting Settle test map from QAGame - now lives in EngineTest

Change 3509935 by Lina.Halper

	One customization tree for supporting Bone and Socket
	 : you can just use FBoneSocketTarget and that will allow displaying sockets also

	#jira: UE-45778
	#rb: Thomas.Sarkanen
	#code review:Thomas.Sarkanen

Change 3511250 by Martin.Wilson

	Fix crash when performing drag operations in the notify track window

	#jira UE-46420

Change 3511397 by Thomas.Sarkanen

	Asset reloading now defers re-opening asset editors until post-GC phase

	This prevents an issue in some asset editors (like Persona) which may reference other assets in their UI.

	#jira UE-46442 - Crash when opening skeletal mesh editor window after reloading asset

Change 3512849 by Aaron.McLeran

	#jira UE-46576 Fixing granulator loading multiple sound waves

Change 3513414 by James.Cobbett

	Fixing destructible test map

Change 3513588 by Benn.Gallagher

	Clothing LOD improvements
	 - Added full pipeline for adding LODs to clothing assets in editor
	 - Added methods for mapping parameters between masks on meshes with differing topology
	 - Fixed a few UI bugs

Change 3513599 by Benn.Gallagher

	Missed files from last checkin

Change 3513920 by Martin.Wilson

	Move Live Link Retarget Asset to live link plugin and remove engine dependency from LiveLinkInterface (fixes maya live link compiling)

Change 3515400 by Aaron.McLeran

	#jira UE-46299 Added a fade in function to audio device so audio can resume after fading out in main audio device.

Change 3515495 by Joe.Conley

	Had reports some AnimationBP deterministic cooking errors were being caused by FBakedAnimationState::bAlwaysResetOnEntry not being initialized in the constructor explicitly.  Changing that to be explicitly initialized to false in the constructor, as well as UAnimStateNode::bAlwaysResetOnEntry.

Change 3515641 by Benn.Gallagher

	CIS fix for game builds

Change 3516817 by Aaron.McLeran

	Moving opus lib to subfolder Windows instead of win32 to fix UGS game sync issues.

Change 3516853 by Aaron.McLeran

	Slight optimization in converting proc audio buffer to 16 bit PCM.

Change 3517525 by Jonathan.Poncelet

	Fix comment for FName operator!=

Change 3517826 by James.Cobbett

	Test files for bug UE-46719

Change 3518049 by James.Cobbett

	Updating Settle automated test map to include settling on convex floors. Also added step to save actor starting location in Ground Truth, and reset actors to that location at the end of the test.

Change 3518185 by Ori.Cohen

	Fix merge error as reported by NVIDIA

Change 3518711 by Ethan.Geller

	Integrating fix for switch crash on load level.

Change 3518720 by Ethan.Geller

	Back out changelist 3518711

Change 3519040 by Aaron.McLeran

	Simple feature to add attack/decay interpolation times for focus feature to avoid fast focus/out-of-focus volume scaling.

Change 3519972 by James.Golding

	Fix constructor order for FSoundAttenuationSettings to fix CIS

Change 3520141 by Martin.Wilson

	Make retarget assets are no longer assets but blueprints instead.
	Add blueprint function for remap asset to allow blueprints to transform bone names

	#jira UEAP-235

Change 3520568 by Martin.Wilson

	CIS fix

Change 3520677 by Benn.Gallagher

	Added ability to rename clothing assets after creation

Change 3520727 by Benn.Gallagher

	Removed unecessary header for asset list

Change 3520791 by Martin.Wilson

	Fix multiple calls to FinalizeBoneTransforms when calling RefreshBoneTransforms outside of tick

Change 3521069 by Jurre.deBaare

	Merging an actor with recompute normal and Overlapping UVs causes the normals generate incorrectly
	#fix old code path was causing normals to be recompute when it wasn't required causing the smooth normals on the issueing asset
	#jira UE-46806

Change 3521070 by Jurre.deBaare

	Ensure occurs when performing a Bake Out Material on Cube
	#fix Make sure that we update the Material data used for texture streaming when adding/changing materials during material baking
	#jira UE-46807

Change 3521142 by Jurre.deBaare

	Bake Material large Texture size crash
	#fix Added clamping to baked out material texture sizes in all occurences (GetMax2DTextureDimension())
	#jira UE-46808

Change 3523294 by Aaron.McLeran

	Resetting available byte count when resetting the procedural sound wave

Change 3523297 by Aaron.McLeran

	Adding thread safe mode for plugin interface shared ptrs.

Change 3524153 by Jurre.deBaare

	Issue where new blend space samples list in detailsview would not regenerate blendspace sampling
	#fix Unified what happens when you change the grid sample value (this issue also caused undo/redo not to work with these numeric boxes)

Change 3524154 by Jurre.deBaare

	Advanced preview tool tip in BlendSpace editor has different behaviour when grid doesn't have focus, and broke the sample dragging functionality.
	#fix Undid some added state cleanup code which actually was invalid to do, and made sure the CTRL down isn't a toggle but a constant state

Change 3524282 by Thomas.Sarkanen

	Fixed OculusAudio in line with new API

	Post-Main merge fixup

Change 3524348 by Thomas.Sarkanen

	Merging using Dev-Physics-Upgrade_PhysX3_To_Dev-AnimPhys_PhysX

	Original CL 3521358:

	[From trunk] 22410436 [Px-1090]PCm sphere convex jittering in UE4 [Reviewer: Kier]

	p4rmerge of Change 22415420 by sschirm
	from e:\P4\dev1\sw\physx\Releases\distro_mirrors\PhysX_3.4_APEX_1.4\Mirror_scripts\patch/cl-22415420.p4r
	moved from //sw/physx/Releases/distro_mirrors/PhysX_3.4_APEX_1.4/Mirror/ to //UE4/Dev-Physics-Upgrade/Engine/Source/ThirdParty/PhysX3/

	#jira UE-46668 - PCM still has stability issues

Change 3524541 by Jurre.deBaare

	Disabled material baking automated tests for now
	#jira UE-46510

Change 3524684 by Jurre.deBaare

	If you paste a invalid name into Bones to Remove and hit apply the editor will crash
	#fix did not check for INDEX_NONE or NAME_NONE bones when retrieving bone indices
	#jira UE-46830

Change 3525244 by Ori.Cohen

	Added the ability to verify the DDC content is not stale. Systems have to opt in (-VerifyDDC)

Change 3525248 by Ori.Cohen

	Physx DDC will now run with verify ddc. Also fixed bad key which was missing the complexity type of body setup

Change 3525263 by Ori.Cohen

	Fix typo with printf

Change 3525279 by Ori.Cohen

	Fix CIS

Change 3525478 by Ethan.Geller

	Adding memory aligned audio buffer support

Change 3525688 by Aaron.McLeran

	Removing unnecessary code

Change 3526391 by Benn.Gallagher

	Clothing optimization pass, mainly removing allocations and precaching some skin information. 10% Overall non-gamethread time reduction, gamethread sync completion task time halved.
	#jira UEAP-197

Change 3526454 by Benn.Gallagher

	CIS fix

Change 3526919 by Chad.Garyet

	adding verifyddc flag to automated tests

Change 3527006 by Lina.Halper

	Fix crash with blendspace sample value change

	- Matt also fixed undo transaction, queuing every move vs only final value
	- Matt fixed property changed to send interactive or not paramger, so that it doens't call object changed for every single move

	#jira: UE-46929
	#rb: Matt.Kuhlenschmidt
	#code review: Jurre.DeBaare, Matt.Kuhlenschmidt

Change 3528684 by Benn.Gallagher

	Static analysis fix, excessive statement left to signal reasons clothing assets would invalidate their caches triggered SA fail.

Change 3528687 by Benn.Gallagher

	CIS Fix, method definition outside of declaration #if block.

Change 3528890 by Ori.Cohen

	Fix false negative with PIE and verify DDC

Change 3528899 by Martin.Wilson

	Smart name refactor part 1 - Changed FindUID api to return UID rather than pointer to UID, fix code in Orion that was caching a pointer to internal TMap allocated memory.

	#jira UEAP-264

Change 3530148 by Aaron.McLeran

	Making check for Supporting multiple audio devices only happen in editor builds.

Change 3530519 by Jonathan.Poncelet

	Deprecated original angular physics functions in preference of a consistent API, using degrees vs. radians

	Functions are now suffixed "InDegrees" or "InRadians", to make it obvious which are used.
	The deprecated functions now call whichever degrees or radians counterpart is needed.
	FBodyInstance now works entirely in radians, to avoid unnecessary conversions.
	Automated tests have been added to verify behaviour.

	#jira UE-39757 Torque and angular velocity are inconsistent

Change 3530943 by Benn.Gallagher

	Fixed clothing shader model automation test.

	#jira UE-47052

Change 3530993 by Thomas.Sarkanen

	Merging using Dev-Rendering_To_Dev-AnimPhys from CL 3512333. Converting integrates to edits.

	Oiriginal CL desc:

	Texture source data is not released anymore in WillNeverCacheCookedPlatformDataAgain().
	This prevents an issue where texture referenced through CompositeTexture have no source data available.
	This doesn't affect peak memory so much as texture loaded with AllowAsyncLoading already release their temporary load data.

	#jira UE-47083 - Cook Odin fails with LogTexture: Error: Unable to get texture source mips because its bulk data was released.

Change 3536312 by Chad.Garyet

	adding verifyddc into the automatedtestbuild xml

Change 3537375 by James.Golding

	Merge Ocean GC crash fix (OCN-7666) from CL 3512485
	#jira UE-47211


DONE!

[CL 3537460 by Thomas Sarkanen in Main branch]
2017-07-14 06:36:47 -04:00

188 lines
5.1 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
AnimStateNode.cpp
=============================================================================*/
#include "AnimStateNode.h"
#include "Kismet2/BlueprintEditorUtils.h"
#include "AnimStateTransitionNode.h"
#include "AnimationStateGraph.h"
#include "Kismet2/Kismet2NameValidators.h"
#include "AnimGraphNode_StateResult.h"
#include "AnimationStateGraphSchema.h"
#define LOCTEXT_NAMESPACE "AnimStateNode"
/////////////////////////////////////////////////////
// UAnimStateNode
UAnimStateNode::UAnimStateNode(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
bCanRenameNode = true;
bAlwaysResetOnEntry = false;
}
void UAnimStateNode::AllocateDefaultPins()
{
UEdGraphPin* Inputs = CreatePin(EGPD_Input, TEXT("Transition"), FString(), nullptr, TEXT("In"));
UEdGraphPin* Outputs = CreatePin(EGPD_Output, TEXT("Transition"), FString(), nullptr, TEXT("Out"));
}
void UAnimStateNode::AutowireNewNode(UEdGraphPin* FromPin)
{
Super::AutowireNewNode(FromPin);
//@TODO: If the FromPin is a state, create a transition between us
if (FromPin)
{
if (GetSchema()->TryCreateConnection(FromPin, GetInputPin()))
{
FromPin->GetOwningNode()->NodeConnectionListChanged();
}
}
}
FText UAnimStateNode::GetNodeTitle(ENodeTitleType::Type TitleType) const
{
return FText::FromString(GetStateName());
}
FText UAnimStateNode::GetTooltipText() const
{
return LOCTEXT("AnimStateNode_Tooltip", "This is a state");
}
void UAnimStateNode::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
{
FName PropertyName = (PropertyChangedEvent.Property != NULL) ? PropertyChangedEvent.Property->GetFName() : NAME_None;
if (PropertyName == FName(TEXT("StateType")))
{
}
Super::PostEditChangeProperty(PropertyChangedEvent);
}
FString UAnimStateNode::GetStateName() const
{
return (BoundGraph != NULL) ? *(BoundGraph->GetName()) : TEXT("(null)");
}
void UAnimStateNode::GetTransitionList(TArray<UAnimStateTransitionNode*>& OutTransitions, bool bWantSortedList)
{
// Normal transitions
for (int32 LinkIndex = 0; LinkIndex < Pins[1]->LinkedTo.Num(); ++LinkIndex)
{
UEdGraphNode* TargetNode = Pins[1]->LinkedTo[LinkIndex]->GetOwningNode();
if (UAnimStateTransitionNode* Transition = Cast<UAnimStateTransitionNode>(TargetNode))
{
OutTransitions.Add(Transition);
}
}
// Bidirectional transitions where we are the 'backwards' link
for (int32 LinkIndex = 0; LinkIndex < Pins[0]->LinkedTo.Num(); ++LinkIndex)
{
UEdGraphNode* TargetNode = Pins[0]->LinkedTo[LinkIndex]->GetOwningNode();
if (UAnimStateTransitionNode* Transition = Cast<UAnimStateTransitionNode>(TargetNode))
{
if (Transition->Bidirectional)
{
OutTransitions.Add(Transition);
}
}
}
// Sort the transitions by priority order, lower numbers are higher priority
if (bWantSortedList)
{
struct FCompareTransitionsByPriority
{
FORCEINLINE bool operator()(const UAnimStateTransitionNode& A, const UAnimStateTransitionNode& B) const
{
return A.PriorityOrder < B.PriorityOrder;
}
};
OutTransitions.Sort(FCompareTransitionsByPriority());
}
}
UEdGraphPin* UAnimStateNode::GetInputPin() const
{
return Pins[0];
}
UEdGraphPin* UAnimStateNode::GetOutputPin() const
{
return Pins[1];
}
UEdGraphPin* UAnimStateNode::GetPoseSinkPinInsideState() const
{
if (UAnimationStateGraph* StateGraph = Cast<UAnimationStateGraph>(BoundGraph))
{
return (StateGraph->MyResultNode != NULL) ? StateGraph->MyResultNode->FindPin(TEXT("Result")) : NULL;
}
else
{
return NULL;
}
}
void UAnimStateNode::PostPasteNode()
{
// Find an interesting name, but try to keep the same if possible
TSharedPtr<INameValidatorInterface> NameValidator = FNameValidatorFactory::MakeValidator(this);
FBlueprintEditorUtils::RenameGraphWithSuggestion(BoundGraph, NameValidator, GetStateName());
Super::PostPasteNode();
}
void UAnimStateNode::PostPlacedNewNode()
{
// Create a new animation graph
check(BoundGraph == NULL);
BoundGraph = FBlueprintEditorUtils::CreateNewGraph(
this,
NAME_None,
UAnimationStateGraph::StaticClass(),
UAnimationStateGraphSchema::StaticClass());
check(BoundGraph);
// Find an interesting name
TSharedPtr<INameValidatorInterface> NameValidator = FNameValidatorFactory::MakeValidator(this);
FBlueprintEditorUtils::RenameGraphWithSuggestion(BoundGraph, NameValidator, TEXT("State"));
// Initialize the anim graph
const UEdGraphSchema* Schema = BoundGraph->GetSchema();
Schema->CreateDefaultNodesForGraph(*BoundGraph);
// Add the new graph as a child of our parent graph
UEdGraph* ParentGraph = GetGraph();
if(ParentGraph->SubGraphs.Find(BoundGraph) == INDEX_NONE)
{
ParentGraph->SubGraphs.Add(BoundGraph);
}
}
void UAnimStateNode::DestroyNode()
{
UEdGraph* GraphToRemove = BoundGraph;
BoundGraph = NULL;
Super::DestroyNode();
if (GraphToRemove)
{
UBlueprint* Blueprint = FBlueprintEditorUtils::FindBlueprintForNodeChecked(this);
FBlueprintEditorUtils::RemoveGraph(Blueprint, GraphToRemove, EGraphRemoveFlags::Recompile);
}
}
#undef LOCTEXT_NAMESPACE