Files
UnrealEngineUWP/Engine/Source/Editor/GraphEditor/Private/NodeFactory.cpp
Marc Audy 2f10ee3611 Copying //UE4/Dev-Framework to //UE4/Dev-Main (Source: //UE4/Dev-Framework @ 3544039)
#lockdown Nick.Penwarden
#rb none
#rnx

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

Change 3343905 by Dan.Oconnor

	ResolveMember optimizations and moved into cpp. ResolveMember<UFunction> now checks UClass::FuncMap before doing more expensive searches

Change 3346637 by Ben.Zeigler

	Actually fix in non editor builds

Change 3355484 by Dan.Oconnor

	Back out FMemberReference Optimization

Change 3425833 by Ben.Zeigler

	#jira UE-31749 Fix it so Undo works properly when modifying a local variable
	#jira UE-44736 Fix it so changing the type of a local variable correctly resets the default value

Change 3510091 by Marc.Audy

	Expose on Spawn functional test

	#rnx

Change 3510100 by Marc.Audy

	Fix spelling error

	#rnx

Change 3510132 by Marc.Audy

	Fix issues with marking a widget blueprint class as abstract

Change 3510133 by Marc.Audy

	Minor code cleanup

	#rnx

Change 3510178 by Ben.Zeigler

	#jira UE-46500 Fix it so editor-only and transient stuct members are not serialized for literal blueprint structs. It's unsafe to serialize them because they may not exist in the cooked build

Change 3510466 by Ben.Zeigler

	Start adding basic ability system tests to enginetest, very minimal so far

Change 3511295 by Marc.Audy

	Fix wasted work going weak -> object -> weak -> object

	#rnx

Change 3511824 by Marc.Audy

	Fix spelling error in tooltip
	#jira UE-46515

	#rnx

Change 3514446 by Ben.Zeigler

	Fix ActorBoundEvent and ComponentBoundEvent to always refresh their event signature from the delegate property they are bound to. This is required to correctly deal with delegate signatures being moved or renamed. Both types now do the fixup one time, in ReconstructNode.

Change 3514578 by Marc.Audy

	Move clearing of the actor component need end of frame update mark to base class instead of just primitive component

Change 3514583 by Ben.Zeigler

	Better fix to last delegate checkin that also handles moving functions between modules but not renaming

Change 3515325 by Dan.Oconnor

	Fix for rare orphan pin false positive, rare exposed on spawn false positive

	#rnx

Change 3515761 by Marc.Audy

	fix shipping configuration

	#rnx

Change 3515772 by Marc.Audy

	Fix static analysis warnings

	#rnx

Change 3516287 by Marc.Audy

	Fix references to instanced components not being updated when resetting component to default
	#jira UE-44706

	#rnx

Change 3516303 by Marc.Audy

	Back out CL# 3516287 while an oddity is investigated

	#rnx

Change 3516563 by Marc.Audy

	(4.17) Fix references to instanced components not being updated when resetting component to default
	#jira UE-44706

Change 3516637 by Phillip.Kavan

	#jira UE-44661 - Fix potential crash when changing the ChildActorComponent class default value on a Blueprint that also sets the class in the Construction Script.

	Change summary:
	- Modified UChildActorComponent::DestroyChildActor() to move the check for PendingKill/Unreachable so that we can also rename a defunct ChildActor instance out of the way in order to allow for a new ChildActor instance w/ the cached name.

Change 3517735 by Marc.Audy

	Avoid unnecessary string copy

	#rnx

Change 3517931 by Marc.Audy

	Small optimization to CleanupActors

Change 3518221 by Dan.Oconnor

	Fix rare crash when running ConformImplementedEvents when async loading
	#jira UE-45348

Change 3518270 by Ben.Zeigler

	#jira UE-46574 Add FCollectionReference type and customization to allow setting an FName to an editor collection
	Add AssetCollection to PrimaryAssetLabel that derives the bundled assets from an editor collection

Change 3518271 by Marc.Audy

	Get rid of unnecessary construction differentiation if custom reset is being used

Change 3518310 by Ben.Marsh

	Re-adding IOS files with correct case.

Change 3518423 by Ben.Zeigler

	#jira UE-46574 Initial support for chunk installation in Asset Manager.
	Refactor AssetManagerSettings so it copies runtime bools into the asset manager for fast access
	Add a concept of a stalled streamable manager handle, handles can be created stalled and will not execute their async load until all needed resources have been acquired externally

Change 3518480 by Marc.Audy

	Correctly get the variable reference for an input variable get from the member scope rather than a member variable of the same name on the class
	#jira UE-46737

Change 3518498 by Ben.Zeigler

	Fix bug with AssetManager where requesting the same load twice in a row before the first one finishes caused the complete callback to get called too early for the second load
	Update test map to catch this

Change 3518526 by Ben.Zeigler

	IOS Fix

Change 3518619 by Ben.Zeigler

	#jira UE-46744 Fix issue where refreshing asset manager editor settings would throw away asset label rules overrides, causing the recursive flag to accidentally get set

Change 3518747 by Phillip.Kavan

	#jira UE-43154 - Prevent ConstructGenericObject nodes from compiling if the selected type does not include 'BlueprintType' in its inheritance hierarchy.

	Change summary:
	- Moved UGameplayStatics::CanSpawnObjectOfClass() into UK2Node_GenericCreateObject as a local util method (per JIRA notes). This was not exposed to Blueprints and as such was inconsistent with the rest of the API.
	- Modified UGameplayStatics::SpawnObject() to no longer call CanSpawnObjectOfClass(). This seemed redundant as this will already have been called during node validation at Blueprint compile time.
	- Refactored CanSpawnObjectOfClass() into FK2Node_GenericCreateObject_Utils. Walking up the inheritance chain no longer starts out w/ the assumption that 'BlueprintType' is set by default, which was previously including a lot of engine-specific classes into the "allowed" set (e.g. UByteProperty). Also unified the 2 loop iterations that were being used to check for 'BlueprintType'/'NotBlueprintType' and 'DontUseGenericSpawnObjectName', as well as the check for whether or not the class is a derivative of AActor/UActorComponent.
	- Modified UK2Node_GenericCreateObject::EarlyValidation() to call FK2Node_GenericCreateObject_Utils::CanSpawnObjectOfClass() and emit a slightly more informative error message to the BP compiler message log.

Change 3518756 by Michael.Noland

	(4.17) Framework: Prevent various asserts when USplineComponent methods are called on a spline with no points

Change 3518760 by Michael.Noland

	Core: Changed FRuntimeAssetCache ensures to ensureAsRuntimeWarning

Change 3518771 by Michael.Noland

	AI: Prevent an ensure in UBlackboardComponent::ClearValue when called on a component with a null BlackboardAsset

Change 3518818 by Michael.Noland

	Rendering: Fixed a whitespace issue in UCanvasRenderTarget2D::RepaintCanvas()

	#rnx

Change 3518822 by Michael.Noland

	Sequencer: Prevented crashes in some methods of UMovieSceneSequencePlayer when there is no Sequence set
	Sequencer: Prevented a crash in FMovieSceneRootEvaluationTemplateInstance::Evaluate when the instance has no template set

Change 3518824 by Michael.Noland

	Landscape: Marked ULandscapeComponent and ULandscapeHeightfieldCollisionComponent as Within=LandscapeProxy, since they do CastChecked on their Outer all the time

Change 3519073 by Michael.Noland

	QAGame: Fixed a crash in UQASynth::PlaySynth() if called on a directly created instance rather than using the factory method

Change 3519076 by Michael.Noland

	Preventing crashes in UAutomationPerformaceHelper (sic) when spawned abnormally for fuzzing (assumes that the outer will have a route to a world)
	#rnx

Change 3519079 by Michael.Noland

	Sequencer: Fixed a potential crash in UMediaPlaylist::Insert and UMediaPlaylist::RemoveAt when passed an invalid index

Change 3519081 by Michael.Noland

	Blueprints: Added support for creating appropriate outers for objects that must be nested within another class during fuzzing (ones that specify Within=, other relationships aren't knowable yet)

Change 3519082 by Michael.Noland

	VR: Prevent a crash in UMRMeshComponent::ConnectReconstructor when passed a null reconstructor

Change 3519084 by Michael.Noland

	Rendering: Prevent crashes when UNiagaraComponent::GetEffectDataInterface is called on a component with no effect asset set

Change 3521889 by Michael.Noland

	Sequencer: Prevented a bogus static analysis warning by reworking the code (FixedFrameInterval could have only been set if the pointer were valid from the line above)
	#rnx

Change 3521987 by Michael.Noland

	Animation: Prevent a couple of potential asserts in UControlRig::GetOrAllocateSubControlRig

Change 3522101 by Michael.Noland

	Physics: Improved the comment on UPhysicalMaterial::Friction

	#rn

Change 3522105 by Michael.Noland

	Physics: Fixed a few crashes in UVehicleWheel when spawned directly

Change 3522106 by Michael.Noland

	Framework: Marked ULevelStreaming as Within=World, since it does CastChecked on the Outer all the time

Change 3522109 by Michael.Noland

	Animation: Marked UAnimInstance as Within=SkeletalMeshComponent since it assumes the outer in various places

Change 3522121 by Michael.Noland

	Mobile: Prevent UMobileInstalledContent methods from crashing when called on a created instance in an uncooked build (no installed manifest)

Change 3522783 by Zak.Middleton

	#ue4 - Imported new simple collision for Engine/Content/BasicShaps/Cylinder.uasset which is a single convex shape (rather than being 4 shapes as before).

Change 3525477 by Dan.Oconnor

	Remove Tooltip, Category, and HideCategories tooltip from the blueprint generated class if source data is cleared

Change 3526538 by Ben.Zeigler

	Refresh primary asset labels if their bundles are different at all and not just if they're added or removed. This is required because they now work based on collections or directories. This fixes issue with the onboarding collection changes not correctly modifying chunks
	Copy of CL #3526501

Change 3526817 by Ben.Zeigler

	#jira UE-46917 Fix issue where maps that do not contain level script blueprints were being counted as unindexed for find in blueprints. The old behavior depended on detecting the existence of empty tags, but the asset registry now filters those out so treat maps with no FiB data as indexed

Change 3526873 by Ben.Zeigler

	#jira UE-46627 Change it so blueprint or native subclasses of static mesh actor cannot be added to clusters, as they are not likely to be immutable the way the base class is
	Add code to to the ubergraph frame to fall back to hard reference serialization if the reference collector doesn't support weak references, such as the cluster collector

Change 3526958 by Marc.Audy

	(4.17) Don't copy and then break pin links when reconstructing. Instead simply move.
	#jira UE-46935

Change 3528916 by Marc.Audy

	PR #3609: Adds GetKeysForAxis() to complement GetKeysForAction() in UPlayerInput (Contributed by alanedwardes)
	#jira UE-45347

Change 3529080 by mason.seay

	BP asset for undetermined type bug

Change 3529381 by Marc.Audy

	Fix ability to insert duplicates in to a set or map

Change 3529471 by Dan.Oconnor

	Fix for clang 4.0 error: definition of builtin function '__rdtsc' inline unsigned long long __rdtsc()

Change 3530876 by Marc.Audy

	Based on PR #3457: Add MakeSet BP node (Contributed by projectgheist)
	Also refactored MakeArray/Set to share a base MakeContainer class
	Cleaned up some dead code from MakeArray
	Added icon for MakeSet
	Added Functional Test for MakeSet
	#jira UE-43717

Change 3531070 by Phillip.Kavan

	#jira UE-46866 - Fix crash on load when an external variable member reference's owning type cannot be loaded.

	Change summary:
	- Modified FBlueprintEditorUtils::GetSkeletonClass() to check for NULL before attempting to check for the generating BP.

Change 3531081 by Marc.Audy

	Remove deprecated CustomMapParamValue code

Change 3531094 by Phillip.Kavan

	#jira UE-46952 - Fix a packaging code build failure that will occur with a nativized Blueprint class that contains a UInterfaceProperty.

	Change summary:
	- Modified TScriptInterface::operator=() to cast the given 'SourceObject' instance to the 'InterfaceType' type before assigning to 'SourceInterface'. This was necessary because if the caller (in this case nativized codegen) passes in a UObject* that does not explicitly inherit from 'InterfaceType', then it will need to go through the object's GetInterfaceAddress() API instead and cast the result back to an 'InterfaceType' pointer.

Change 3531186 by Phillip.Kavan

	Back out changelist 3531094 (temp CIS fix).

	#rnx

Change 3532082 by Marc.Audy

	Move garbage collection timers and other management to UEngine instead of UWorld
	Fixes CollectGarbage blueprint node not working in shipping
	#jira UE-46566

Change 3532134 by Phillip.Kavan

	Restored changelist 3531094 w/ fix for non-unity.

	- Mirrored from //UE4/Release-4.17 (CL# 3531232).

	#rnx

Change 3533009 by Marc.Audy

	Fixup missing function and deprecation warnings

Change 3534056 by Marc.Audy

	(4.17) Fix expose on spawn of map and sets to work
	#jira UE-47140

Change 3534761 by Marc.Audy

	(4.17) Apply code review changes to Dev-Framework as well

	#rnx

Change 3535147 by Dan.Oconnor

	Build fix, already made in 4.17

	#rnx

Change 3535530 by mason.seay

	Resaving to remove error when opening level blueprint

Change 3535581 by Marc.Audy

	Class Properties are only identical if they are literally the same object. Do not consider the deep compare port flags as object property base does.
	#jira UE-46533

Change 3535583 by Marc.Audy

	When properties are imported in to a child actor component the cached instance data is invalidated, so clear it.
	#jira UE-46533

Change 3535617 by Marc.Audy

	PR #3788: UE-39237: Prevent (im-)pure casting during BP debugging (Contributed by projectgheist)
	#jira UE-47188
	#jira UE-39237

Change 3535671 by Marc.Audy

	Change NodeFactory to look at interface to use sequence node instead of each node having to add itself

Change 3535955 by Marc.Audy

	Prevent MakeSet from removing split pins

Change 3536114 by Michael.Noland

	Paper2D: Removing deprecated code from 4.3/4.4 era

	#rnx

Change 3536120 by Michael.Noland

	Animation: Removed deprecated FTAlphaBlend class and AlphaBlendType.h header

Change 3536124 by Michael.Noland

	Physics: Removed deprecated methods that were replaced by _AssumesLocked variations

Change 3536131 by Michael.Noland

	Slate: Converting remaining uses of EKeyboardFocusCause to EFocusCause and properly deprecating it

Change 3536138 by Michael.Noland

	Slate: Removed any deprecated code older than 4.10 that didn't affect content compatibility

Change 3536167 by Dan.Oconnor

	When a client provides a skeleton class as the self scope, make sure we also use a skel class for non-self scopes - but only if using the compilation manager. Skel classes are not reliably up to date when not using the compilation manager
	#jira UE-46904

Change 3536221 by Michael.Noland

	Editor: Removing deprecated code from 4.9 or earlier

Change 3536240 by Michael.Noland

	Blueprints: Removed long-deprecated TypeToString method from the K2 schema
	#rnx

Change 3536243 by Michael.Noland

	AI: Prevent crashes if UMockTask_Log is created manually rather than via the CreateTask factory method

Change 3536244 by Michael.Noland

	Core: Prevent FScopedExternalProfilerBase::StopScopedTimer() from asserting if called an unmatched number of times with StartScopedTimer, as both are exposed to BPs now

Change 3536250 by Michael.Noland

	CoreUObject: Removed any deprecated code older than 4.10 that didn't affect content compatibility

Change 3536253 by Michael.Noland

	Core: Removed any deprecated code older than 4.10 that didn't affect content compatibility

Change 3536310 by Michael.Noland

	Engine: Removed any deprecated code older than 4.10 that didn't affect content compatibility

Change 3536397 by Mieszko.Zielinski

	Fixed UCrowdFollowingComponent::UpdateCachedDirections crashing when CharacterMovement is not set #UE4

	#jira UE-46860

Change 3536404 by Michael.Noland

	Platform: Added a warning for others when they try to remove this 'deprecated' method

Change 3536639 by Michael.Noland

	CharacterMovement: Changed the name of a variable introduced in CL# 3536397 to better match intent
	#rnx

Change 3536893 by Michael.Noland

	Blueprints: Clear the stale value on the value pin when a map find node fails to find an item
	#jira UE-47233

Change 3536902 by Michael.Noland

	Framework: Killed a couple of more deprecated methods that were not exposed to Blueprints

	#rnx

Change 3537038 by Ben.Marsh

	Fixing case of iOS directories, pt1

Change 3537039 by Ben.Marsh

	Fixing case of iOS directories, pt2

Change 3538246 by Michael.Noland

	UnrealTournament: Fixing issues with renamed enum

	#rnx

Change 3538618 by Ben.Zeigler

	Fix ensure when closing sequencer transform UI

Change 3540213 by Ben.Zeigler

	#jira UE-47313 Fix crash serializing a MapProperty where the value type has changed for a type that implements ConvertFromType. The address passed to ConvertFromType needs to be the container root, not the specific value address, keys worked because the offset was 0.

Change 3540253 by Marc.Audy

	Only copy default values for input pins as output pins do not have them

	#rnx

Change 3540376 by Marc.Audy

	Add utility FromPinType for FEdGraphTerminalType

	#rnx

Change 3540433 by Marc.Audy

	Add MakeMap
	#jira UE-47093
	Unify IsConnectionDisallowed for containers and fix static analysis warning
	#jira UE-47291

Change 3540585 by Phillip.Kavan

	#jira UE-47117 - Fix crash on launch of a nativized build that includes an instanced default subobject that's referenced by another instanced default subobject.

	Change summary:
	- Modified FEmitDefaultValueHelper::HandleSpecialTypes() to only direct HandleInstancedSubobject() to emit code to create the instanced subobject if it's not a default subobject. This was previously being incorrectly interpreted as an object having the 'RF_ArchetypeObject' flag set; however, default subobjects will also have that flag set in addition to the 'RF_DefaultSubobject' flag.
	- Modified FEmitDefaultValueHelper::HandleInstancedSubobject() to assert in the 'GetDefaultSubobjectByName' case if the given object is not also a default subobject.

Change 3541147 by Dan.Oconnor

	Fix for not being able to override custom events when using the compilation manager post 3536167
	#jira UE-47292
	#rnx

Change 3541177 by Ben.Zeigler

	#jira UE-46595, UE-46553 Fix issue where creating a widget template could cause a widget blueprint being cooked to have the wrong package flags, making it appear to be an uncooked package
	Copy of CL #3541027

Change 3541325 by Dan.Oconnor

	K2node data table data needs to preload data before the compilation queue is flushed

	#rnx
	#jira UE-47319

Change 3541409 by Michael.Noland

	Blueprints: Added code to reapply any active breakpoints after recompilation when using the BP compilation manager
	#jira UE-47322

	[reimplementing CL# 3541404 in Dev-Framework]

Change 3541418 by Dan.Oconnor

	Fix for bad SKEL_ CDO reference in blueprint bytecode
	#jira UE-47265

	#rnx

Change 3541482 by Dan.Oconnor

	Blanket fix up of preload calls that are being done in AllocateDefaultPins. AllocatDefaultPins is not called until compile, meaning if these preload calls load blueprints they will be loaded while the compilation manager is compiling blueprints

	#rnx
	#jira UE-47319

Change 3541817 by Marc.Audy

	Fix static analysis warnings

	#rnx

Change 3542299 by Michael.Noland

	Blueprints: Speculative fix for static analysis warning
	#rnx

Change 3542406 by Marc.Audy

	Use a check slow to avoid any cost

	#rnx

Change 3542486 by Michael.Noland

	Asset Manager: Removing an unnecessary ensure (it's a potentially expected case)

	#jira UE-47380

Change 3542659 by Michael.Noland

	Blueprints: Clear out null entries in the LastEditedDocuments list during PostLoad() and remove entries when a graph is being deleted to prevent their generation in the first place
	#jira UE-47385

Change 3543620 by Dan.Oconnor

	Remove overzealous ensure - we may recompile blueprints that are asynchronously loading when a user triggers a synchronous compile
	#jira UE-47415
	#rnx

Change 3518415 by Ben.Zeigler

	#jira UE-46574 Deprecate IPlatformChunkInstall::SetChunkInstallDelgate as it was spelled wrong, was only half implemented, and did not support success vs failure
	Replace with AddChunkInstallDelegate, which supports a bool error code and is bound once instead of separately for each chunk. All implementations support this delegate at a basic level, although several could be improved to call the failure delegate in more cases

Change 3534339 by Michael.Noland

	Platforms: Changed DEPRECATED() macro description to use 4.xx rather than a speciifc version in examples, so it doesn't show up when removing deprecated code

[CL 3544050 by Marc Audy in Main branch]
2017-07-19 09:49:59 -04:00

388 lines
13 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "NodeFactory.h"
#include "UObject/Class.h"
#include "InputCoreTypes.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "MaterialGraph/MaterialGraphNode_Comment.h"
#include "MaterialGraph/MaterialGraphNode_Base.h"
#include "MaterialGraph/MaterialGraphNode.h"
#include "MaterialGraph/MaterialGraphNode_Root.h"
#include "MaterialGraph/MaterialGraphSchema.h"
#include "SoundCueGraph/SoundCueGraphNode.h"
#include "SoundCueGraph/SoundCueGraphNode_Root.h"
#include "SoundCueGraph/SoundCueGraphSchema.h"
#include "Engine/CollisionProfile.h"
#include "SGraphPin.h"
#include "EdGraphSchema_K2.h"
#include "K2Node.h"
#include "K2Node_Event.h"
#include "K2Node_AddPinInterface.h"
#include "K2Node_CallArrayFunction.h"
#include "K2Node_CallMaterialParameterCollectionFunction.h"
#include "K2Node_Composite.h"
#include "K2Node_Copy.h"
#include "K2Node_CreateDelegate.h"
#include "K2Node_FormatText.h"
#include "K2Node_GetArrayItem.h"
#include "K2Node_Knot.h"
#include "K2Node_MakeStruct.h"
#include "K2Node_SpawnActor.h"
#include "K2Node_SpawnActorFromClass.h"
#include "K2Node_Switch.h"
#include "K2Node_Timeline.h"
#include "SGraphNodeDefault.h"
#include "SGraphNodeComment.h"
#include "SGraphNodeDocumentation.h"
#include "EdGraph/EdGraphNode_Documentation.h"
#include "SGraphNodeKnot.h"
#include "KismetNodes/SGraphNodeK2Default.h"
#include "KismetNodes/SGraphNodeK2Var.h"
#include "KismetNodes/SGraphNodeK2Composite.h"
#include "KismetNodes/SGraphNodeSwitchStatement.h"
#include "KismetNodes/SGraphNodeK2Sequence.h"
#include "KismetNodes/SGraphNodeK2Timeline.h"
#include "KismetNodes/SGraphNodeSpawnActor.h"
#include "KismetNodes/SGraphNodeSpawnActorFromClass.h"
#include "KismetNodes/SGraphNodeK2CreateDelegate.h"
#include "KismetNodes/SGraphNodeCallParameterCollectionFunction.h"
#include "KismetNodes/SGraphNodeK2Event.h"
#include "KismetNodes/SGraphNodeFormatText.h"
#include "KismetNodes/SGraphNodeMakeStruct.h"
#include "KismetNodes/SGraphNodeK2Copy.h"
#include "KismetPins/SGraphPinBool.h"
#include "SGraphPinString.h"
#include "KismetPins/SGraphPinText.h"
#include "SGraphPinObject.h"
#include "KismetPins/SGraphPinClass.h"
#include "KismetPins/SGraphPinExec.h"
#include "SGraphPinNum.h"
#include "SGraphPinInteger.h"
#include "SGraphPinColor.h"
#include "KismetPins/SGraphPinEnum.h"
#include "KismetPins/SGraphPinKey.h"
#include "SGraphPinVector.h"
#include "SGraphPinVector2D.h"
#include "SGraphPinVector4.h"
#include "KismetPins/SGraphPinIndex.h"
#include "KismetPins/SGraphPinCollisionProfile.h"
#include "MaterialNodes/SGraphNodeMaterialBase.h"
#include "MaterialNodes/SGraphNodeMaterialComment.h"
#include "MaterialNodes/SGraphNodeMaterialResult.h"
#include "MaterialGraphNode_Knot.h"
#include "MaterialPins/SGraphPinMaterialInput.h"
#include "ConnectionDrawingPolicy.h"
#include "BlueprintConnectionDrawingPolicy.h"
#include "MaterialGraphConnectionDrawingPolicy.h"
#include "EdGraphUtilities.h"
#include "EdGraphSchema_Niagara.h"
TSharedPtr<SGraphNode> FNodeFactory::CreateNodeWidget(UEdGraphNode* InNode)
{
check(InNode != NULL);
// First give a shot to the node itself
{
TSharedPtr<SGraphNode> NodeCreatedResult = InNode->CreateVisualWidget();
if (NodeCreatedResult.IsValid())
{
return NodeCreatedResult;
}
}
// First give a shot to the registered node factories
for (auto FactoryIt = FEdGraphUtilities::VisualNodeFactories.CreateIterator(); FactoryIt; ++FactoryIt)
{
TSharedPtr<FGraphPanelNodeFactory> FactoryPtr = *FactoryIt;
if (FactoryPtr.IsValid())
{
TSharedPtr<SGraphNode> ResultVisualNode = FactoryPtr->CreateNode(InNode);
if (ResultVisualNode.IsValid())
{
return ResultVisualNode;
}
}
}
if (UMaterialGraphNode_Base* BaseMaterialNode = Cast<UMaterialGraphNode_Base>(InNode))
{
if (UMaterialGraphNode_Root* RootMaterialNode = Cast<UMaterialGraphNode_Root>(InNode))
{
return SNew(SGraphNodeMaterialResult, RootMaterialNode);
}
else if (UMaterialGraphNode_Knot* MaterialKnot = Cast<UMaterialGraphNode_Knot>(InNode))
{
return SNew(SGraphNodeKnot, MaterialKnot);
}
else if (UMaterialGraphNode* MaterialNode = Cast<UMaterialGraphNode>(InNode))
{
return SNew(SGraphNodeMaterialBase, MaterialNode);
}
}
if (UK2Node* K2Node = Cast<UK2Node>(InNode))
{
if (UK2Node_Composite* CompositeNode = Cast<UK2Node_Composite>(InNode))
{
return SNew(SGraphNodeK2Composite, CompositeNode);
}
else if (K2Node->DrawNodeAsVariable())
{
return SNew(SGraphNodeK2Var, K2Node);
}
else if (UK2Node_Switch* SwitchNode = Cast<UK2Node_Switch>(InNode))
{
return SNew(SGraphNodeSwitchStatement, SwitchNode);
}
else if (InNode->GetClass()->ImplementsInterface(UK2Node_AddPinInterface::StaticClass()))
{
return SNew(SGraphNodeK2Sequence, CastChecked<UK2Node>(InNode));
}
else if (UK2Node_Timeline* TimelineNode = Cast<UK2Node_Timeline>(InNode))
{
return SNew(SGraphNodeK2Timeline, TimelineNode);
}
else if(UK2Node_SpawnActor* SpawnActorNode = Cast<UK2Node_SpawnActor>(InNode))
{
return SNew(SGraphNodeSpawnActor, SpawnActorNode);
}
else if(UK2Node_SpawnActorFromClass* SpawnActorNodeFromClass = Cast<UK2Node_SpawnActorFromClass>(InNode))
{
return SNew(SGraphNodeSpawnActorFromClass, SpawnActorNodeFromClass);
}
else if(UK2Node_CreateDelegate* CreateDelegateNode = Cast<UK2Node_CreateDelegate>(InNode))
{
return SNew(SGraphNodeK2CreateDelegate, CreateDelegateNode);
}
else if (UK2Node_CallMaterialParameterCollectionFunction* CallFunctionNode = Cast<UK2Node_CallMaterialParameterCollectionFunction>(InNode))
{
return SNew(SGraphNodeCallParameterCollectionFunction, CallFunctionNode);
}
else if (UK2Node_Event* EventNode = Cast<UK2Node_Event>(InNode))
{
return SNew(SGraphNodeK2Event, EventNode);
}
else if (UK2Node_FormatText* FormatTextNode = Cast<UK2Node_FormatText>(InNode))
{
return SNew(SGraphNodeFormatText, FormatTextNode);
}
else if (UK2Node_Knot* Knot = Cast<UK2Node_Knot>(InNode))
{
return SNew(SGraphNodeKnot, Knot);
}
else if (UK2Node_MakeStruct* MakeStruct = Cast<UK2Node_MakeStruct>(InNode))
{
return SNew(SGraphNodeMakeStruct, MakeStruct);
}
else if (UK2Node_Copy* CopyNode = Cast<UK2Node_Copy>(InNode))
{
return SNew(SGraphNodeK2Copy, CopyNode);
}
else
{
return SNew(SGraphNodeK2Default, K2Node);
}
}
else if(UEdGraphNode_Documentation* DocNode = Cast<UEdGraphNode_Documentation>(InNode))
{
return SNew(SGraphNodeDocumentation, DocNode);
}
else if (InNode->ShouldDrawNodeAsComment())
{
if (UMaterialGraphNode_Comment* MaterialCommentNode = Cast<UMaterialGraphNode_Comment>(InNode))
{
return SNew(SGraphNodeMaterialComment, MaterialCommentNode);
}
else
{
return SNew(SGraphNodeComment, InNode);
}
}
else
{
return SNew(SGraphNodeDefault)
.GraphNodeObj(InNode);
}
}
TSharedPtr<SGraphPin> FNodeFactory::CreatePinWidget(UEdGraphPin* InPin)
{
check(InPin != NULL);
// First give a shot to the registered pin factories
for (auto FactoryIt = FEdGraphUtilities::VisualPinFactories.CreateIterator(); FactoryIt; ++FactoryIt)
{
TSharedPtr<FGraphPanelPinFactory> FactoryPtr = *FactoryIt;
if (FactoryPtr.IsValid())
{
TSharedPtr<SGraphPin> ResultVisualPin = FactoryPtr->CreatePin(InPin);
if (ResultVisualPin.IsValid())
{
return ResultVisualPin;
}
}
}
if (const UEdGraphSchema_K2* K2Schema = Cast<const UEdGraphSchema_K2>(InPin->GetSchema()))
{
if (InPin->PinType.PinCategory == K2Schema->PC_Boolean)
{
return SNew(SGraphPinBool, InPin);
}
else if (InPin->PinType.PinCategory == K2Schema->PC_Text)
{
return SNew(SGraphPinText, InPin);
}
else if (InPin->PinType.PinCategory == K2Schema->PC_Exec)
{
return SNew(SGraphPinExec, InPin);
}
else if (InPin->PinType.PinCategory == K2Schema->PC_Object)
{
return SNew(SGraphPinObject, InPin);
}
else if (InPin->PinType.PinCategory == K2Schema->PC_Interface)
{
return SNew(SGraphPinObject, InPin);
}
else if (InPin->PinType.PinCategory == K2Schema->PC_Asset)
{
return SNew(SGraphPinObject, InPin);
}
else if (InPin->PinType.PinCategory == K2Schema->PC_Class)
{
return SNew(SGraphPinClass, InPin);
}
else if (InPin->PinType.PinCategory == K2Schema->PC_AssetClass)
{
return SNew(SGraphPinClass, InPin);
}
else if (InPin->PinType.PinCategory == K2Schema->PC_Int)
{
return SNew(SGraphPinInteger, InPin);
}
else if (InPin->PinType.PinCategory == K2Schema->PC_Float)
{
return SNew(SGraphPinNum, InPin);
}
else if (InPin->PinType.PinCategory == K2Schema->PC_String || InPin->PinType.PinCategory == K2Schema->PC_Name)
{
return SNew(SGraphPinString, InPin);
}
else if (InPin->PinType.PinCategory == K2Schema->PC_Struct)
{
// If you update this logic you'll probably need to update UEdGraphSchema_K2::ShouldHidePinDefaultValue!
UScriptStruct* ColorStruct = TBaseStructure<FLinearColor>::Get();
UScriptStruct* VectorStruct = TBaseStructure<FVector>::Get();
UScriptStruct* Vector2DStruct = TBaseStructure<FVector2D>::Get();
UScriptStruct* RotatorStruct = TBaseStructure<FRotator>::Get();
if (InPin->PinType.PinSubCategoryObject == ColorStruct)
{
return SNew(SGraphPinColor, InPin);
}
else if ((InPin->PinType.PinSubCategoryObject == VectorStruct) || (InPin->PinType.PinSubCategoryObject == RotatorStruct))
{
return SNew(SGraphPinVector, InPin);
}
else if (InPin->PinType.PinSubCategoryObject == Vector2DStruct)
{
return SNew(SGraphPinVector2D, InPin);
}
else if (InPin->PinType.PinSubCategoryObject == FKey::StaticStruct())
{
return SNew(SGraphPinKey, InPin);
}
else if (InPin->PinType.PinSubCategoryObject == FCollisionProfileName::StaticStruct())
{
return SNew(SGraphPinCollisionProfile, InPin);
}
}
else if (InPin->PinType.PinCategory == K2Schema->PC_Byte)
{
// Check for valid enum object reference
if ((InPin->PinType.PinSubCategoryObject != NULL) && (InPin->PinType.PinSubCategoryObject->IsA(UEnum::StaticClass())))
{
return SNew(SGraphPinEnum, InPin);
}
else
{
return SNew(SGraphPinInteger, InPin);
}
}
else if ((InPin->PinType.PinCategory == K2Schema->PC_Wildcard) && (InPin->PinType.PinSubCategory == K2Schema->PSC_Index))
{
return SNew(SGraphPinIndex, InPin);
}
else if(InPin->PinType.PinCategory == K2Schema->PC_MCDelegate)
{
return SNew(SGraphPinString, InPin);
}
}
if (const UMaterialGraphSchema* MaterialGraphSchema = Cast<const UMaterialGraphSchema>(InPin->GetSchema()))
{
if (InPin->PinType.PinCategory == MaterialGraphSchema->PC_MaterialInput)
{
return SNew(SGraphPinMaterialInput, InPin);
}
else
{
return SNew(SGraphPin, InPin);
}
}
// If we didn't pick a custom pin widget, use an uncustomized basic pin
return SNew(SGraphPin, InPin);
}
FConnectionDrawingPolicy* FNodeFactory::CreateConnectionPolicy(const UEdGraphSchema* Schema, int32 InBackLayerID, int32 InFrontLayerID, float ZoomFactor, const FSlateRect& InClippingRect, FSlateWindowElementList& InDrawElements, UEdGraph* InGraphObj)
{
FConnectionDrawingPolicy* ConnectionDrawingPolicy;
// First give the schema a chance to provide the connection drawing policy
ConnectionDrawingPolicy = Schema->CreateConnectionDrawingPolicy(InBackLayerID, InFrontLayerID, ZoomFactor, InClippingRect, InDrawElements, InGraphObj);
// First give a shot to the registered connection factories
if (!ConnectionDrawingPolicy)
{
for (auto FactoryIt = FEdGraphUtilities::VisualPinConnectionFactories.CreateIterator(); FactoryIt; ++FactoryIt)
{
TSharedPtr<FGraphPanelPinConnectionFactory> FactoryPtr = *FactoryIt;
if (FactoryPtr.IsValid())
{
ConnectionDrawingPolicy = FactoryPtr->CreateConnectionPolicy(Schema, InBackLayerID, InFrontLayerID, ZoomFactor, InClippingRect, InDrawElements, InGraphObj);
}
}
}
// If neither the schema nor the factory provides a policy, try the hardcoded ones
//@TODO: Fold all of this code into registered factories for the various schemas!
if (!ConnectionDrawingPolicy)
{
if (Schema->IsA(UEdGraphSchema_K2::StaticClass()))
{
ConnectionDrawingPolicy = new FKismetConnectionDrawingPolicy(InBackLayerID, InFrontLayerID, ZoomFactor, InClippingRect, InDrawElements, InGraphObj);
}
else if (Schema->IsA(UMaterialGraphSchema::StaticClass()))
{
ConnectionDrawingPolicy = new FMaterialGraphConnectionDrawingPolicy(InBackLayerID, InFrontLayerID, ZoomFactor, InClippingRect, InDrawElements, InGraphObj);
}
else
{
ConnectionDrawingPolicy = new FConnectionDrawingPolicy(InBackLayerID, InFrontLayerID, ZoomFactor, InClippingRect, InDrawElements);
}
}
// If we never picked a custom policy, use the uncustomized standard policy
return ConnectionDrawingPolicy;
}