You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb none #lockdown Nick.Penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 2927746 on 2016/03/30 by Michael.Schoell Local variables in function graphs will now store a hard reference to their UObject value. Fixes a crash when a Blueprint is saved before compiling with the local variable's value set. Ensures that the UObject is loaded with the Blueprint. #jira UE-27738 - Local variables in a function that is in a blueprint will somehow become invalid when calling a native Change 2927751 on 2016/03/30 by Michael.Schoell Back out changelist 2927746 Change 2986483 on 2016/05/23 by Maciej.Mroz #jira UE-30976 Editable enum values set on an instance are lost during nativization Added overriden names of Enum keys. Change 2986712 on 2016/05/23 by Phillip.Kavan [UE-21010] Apply updated transform to component template instances when changing the scene root in a Blueprint class. change summary: - modified SSCS_RowWidget::OnMakeNewRootDropAction() to propagate the location/rotation reset to instances of the component template that's becoming the new scene root. Change 2987406 on 2016/05/23 by Ryan.Rauschkolb Fixed Functions filter in Find-In-Blueprints will show components from the SCS #jira UE-30140 Change 2988925 on 2016/05/24 by Ryan.Rauschkolb Fixed Issue where certain primitives would not automatically type cast to Text in Blueprint graph. #jira UE-20232 Change 2989001 on 2016/05/24 by Dan.Oconnor PR #2418: Fixed a typo in Blueprint.h (Contributed by PistonMiner) #jira UE-31142 Change 2989447 on 2016/05/25 by Phillip.Kavan [UE-30807] Propagate edit condition property value changes to instances of template objects. change summary: - modified FPropertyEditor::SetEditConditionState() to propagate an EditConditionProperty value change to all instances if the outer owning object is a template (e.g. CDO) Change 2989804 on 2016/05/25 by Phillip.Kavan [UE-30289] Preserve relative scale on the root scene component when converting an Actor instance to a Blueprint Class. change summary: - modified FKismetEditorUtilities::CreateBlueprintFromActor() to post-copy the relative scale value from the Actor's root component to the new Blueprint CDO's root component Change 2990234 on 2016/05/25 by Ryan.Rauschkolb Fixed issue where including a period ina Blueprint function causes double-click to fail to open its graph #jira UE-4426 Change 2990566 on 2016/05/25 by Mike.Beach Better warn logging to help locate variable nodes that emit a "variable not found" message. Change 2991083 on 2016/05/26 by Maciej.Mroz Blueprint nativization: converted classes have "config" specified. Change 2991363 on 2016/05/26 by Phillip.Kavan [UE-19599] Copy-and-paste of Actor instances from level to Blueprint/IWCE component tree views now adds properly-initialized components. change summary: - modified FCustomizableTextObjectFactory::CanCreateObjectsFromText() to handle "Begin Actor/End Actor" blocks in T3D text - modified FCustomizableTextObjectFactory::ProcessBuffer() to handle "Begin Actor/End Actor" blocks in T3D text (so that Actor-type objects can be processed) - modified FComponentObjectTextFactory::CanCreateClass() to allow Actor-type objects to pass - modified FComponentObjectTextFactory::ProcessConstructedObject() to handle Actor-type objects and pull out owned component instances as constructed objects Change 2992990 on 2016/05/27 by Ryan.Rauschkolb Fixed issue where Connecting Self Reference Pin to a String pin does not fully connect the generated GetDisplayName node #jira UE-21973 Change 2992995 on 2016/05/27 by Ryan.Rauschkolb Fixed issue where GetClass node is not listed in the Context Menu when pulling from a self node and Context Sensitive is checked. #jira UE-30990 Change 2993449 on 2016/05/27 by Phillip.Kavan [UE-31379] Don't instrument "preview" Actor instances during Blueprint profiler script event processing. change summary: - modified FBlueprintProfiler::InstrumentEvent() to check for and bypass Actor instances belonging to a preview or inactive world type. Change 2993531 on 2016/05/27 by Mike.Beach PR #2433: Interface functions inherited from a native base class now appear in . (Contributed by MichaelSchoell) Change 2993969 on 2016/05/30 by Maciej.Mroz UE-30729 Crash in Native Orion when selecting Sword or Tomahawk Clear AsyncLoading in subobjects. Change 2993990 on 2016/05/30 by Phillip.Kavan [UE-30984] Exclude reroute nodes from Blueprint profiler node mapping. change summary: - modified FBlueprintFunctionContext::MapInputPins() to pass through non-relevant nodes when iterating through non-exec input pin links. - modified FBlueprintFunctionContext::MapExecPins() to pass through non-relevant nodes when iterating through output exec pin links. - modified FBlueprintFunctionContext::MapTunnelEntry() to pass through non-relevant nodes when iterating through tunnel node exit points. - modified FBlueprintFunctionContext::MapTunnelInstance() to pass through non-relevant nodes when iterating through tunnel graph entry points. Change 2994591 on 2016/05/31 by Ryan.Rauschkolb Fixed issue where inherited Blueprint variable would not show parent's replications settings #jira UE-18912 Change 2994613 on 2016/05/31 by Ben.Cosh Minor refactor and Various fixes to the blueprint profiler moving towards MVP goal. #Jira UE-27039 - Blueprint Profiler does not lists stats when calling an Event Dispatcher #Jira UE-31396 - Blueprint profiler crashes inside the profiler connection drawing policy #Jira UE-30957 - "Pure Time" does not populate with data in the Blueprint Profiler #Jira UE-30926 - Blueprint profiler - expose heatmap thresholds to user through the profiler tab #Jira UE-30909 - Blueprint Profiler - "compile" icon should denote Blueprint's instrumented status #Jira UE-30911 - Blueprint profiler tab/panel should display warning when Blueprint is uninstrumented #Jira UE-31385 - BP Profiler - Inclusive time column should be entirely filled out #Jira UE-31375 - BP Profiler - Default sample averaging to the "arithmetic mean" #Jira UE-31377 - BP Profiler - Default tree view filtering to off #Jira UE-31387 - BP Profiler - Remove the "view type" button for MVP #Jira UE-31384 - BP Profiler - In the tree view, rename the first time column "Avg. Time (ms)" Notes:- - Sequence node inclusive time fixed - Trace History tidy up - Compile Icon and status messages for instrumentation - Message in the profiler tab for instrumentation - Profiler view tidy up and heat thresholds controls added - fixed the summed execution branch stats - fixed the connection drawing policy to use branch pin stats and fixed the crash from UE-31396 - added hottest path and hottest endpoint wire heatmaps - switched off the graph filter by default - added total time for the heatmaps - fixed issue where initialising mapped functions caused an assert due to changes to the array/map in initialisation code Change 2995058 on 2016/05/31 by Phillip.Kavan [UE-30718] Native/const implementable events will no longer cause a crash at runtime when the Blueprint profiler is running. change summary: - modified UObject::ProcessEvent() to bypass instrumentation for native event functions that are not implemented (overridden) in a BP class. - modified FScriptEventPlayback::Process() to first check for a standalone function match (UCS, implementable events declared as 'const') before settling on the ubergraph function for the target context. Change 2995218 on 2016/05/31 by Phillip.Kavan [UE-30778] Restored non-K2 compact graph nodes (e.g. Material Editor) to previous size. change summary: - modified SGraphNode::GetNodeIndicatorOverlayVisibility() default impl to return 'Collapsed' by default, so it doesn't affect layout. Change 2996417 on 2016/06/01 by Phillip.Kavan [UE-16073] Basic shape components (cube etc.) will now apply the correct override material to instances after being added through the component tree in the Blueprint editor. change summary: - modified the 'OnBasicShapeCreated' lambda in FComponentTypeRegistryData::AddBasicShapeComponents() to propagate the material override to all instances when the given component is an archetype (template) object. Change 2997001 on 2016/06/01 by Ryan.Rauschkolb Fixed Double Clicking a component in the results of Find-In-Blueprints does not select the component #jira UE-30143 Change 2997521 on 2016/06/02 by Maciej.Mroz [Blueprint Nativization] - Added FilesToIncludeInModuleHeader config variable in BlueprintNativizationSettings. So some headers can be included in NativizedAssets.h - Guids of nodes are no longer recreated when Blueprint is duplicated for "C++ compilation". Previously child bp used variable names based on original parent class, but nativized parent class had guids recreated. Change 2997522 on 2016/06/02 by Maciej.Mroz Native implementation of NOEXPORT FInterpCurvePoint structures. (It's necessary for Blueprint nativization) Change 2997638 on 2016/06/02 by Maciej.Mroz Improvements for Blueprint Nativization: - Overridden names in nativized code have proper escape characters (in generated code). - OnlyDefaultConstructorDeclared metadata is replaced by ObjectInitializerConstructorDeclared - Arrays of nativized anum have the following form: TArray<Enum> (previously it was TArray<TEnumAsByte<Enum>>) - warning C4883 is disabled in .generated.cpp files for nativized module Change 2997639 on 2016/06/02 by Maciej.Mroz Minor improvements in Ocean gameplay code. Required for Blueprint Nativization. #jira UE-28945 Failure packaging Nativized Ocean Change 2997656 on 2016/06/02 by Maciej.Mroz Various improvements in BlueprintCompilerCppBackend: - Fixed interface cast - Fixed TSwitchValue issue (when used with literals) - Fixed improper name for NativeBlueprintEvent (when calling parent's implementation) - Fixed bitfield getter code. - Reduce code size (less UsedAssets, less ReferencedConvertedFields, cached UEnums) - operator == is generated for nativized structs - Fixed AssedId (AssetPtr) constructor in nativized code. - Fixed arrays of noexport struct - Fixed missing headers for native single cast delegate signature. - Fixed issue when default constructor (in native) is missing (constructor with FObjectInitialized, wont be used automatically). See "ObjectInitializerConstructorDeclared" metadata. Change 2997691 on 2016/06/02 by Maciej.Mroz operator == in FText. It is required for some functions in TArray<FText> Change 2997793 on 2016/06/02 by Ben.Cosh Added support for BaseAsyncTask nodes, fixed a problem with instance mapping and turned off the debug instance filter #Jira UE-30703 - Crash using blueprint profiler on AI pawn using nav mesh #Proj BlueprintProfiler, Kismet Change 2997901 on 2016/06/02 by Maciej.Mroz Back out changelist 2997691 Change 2998038 on 2016/06/02 by Mike.Beach Merging //UE4/Dev-Main to Dev-Blueprints (//UE4/Dev-Blueprints) Change 2998052 on 2016/06/02 by Ryan.Rauschkolb Fixed Comment bubbles not remembering changes after losing focus #jira UE-20012 Change 2998450 on 2016/06/02 by Phillip.Kavan [UE-31550] Fix crash on load of a Blueprint class containing a bitmask variable with missing enum type metadata. change summary: - modified FBlueprintEditorUtils::ValidateBlueprintVariableMetadata() to check for presence of bitmask enum type metadata on a variable before trying to validate it. Change 2999763 on 2016/06/03 by Mike.Beach Guarding against a crash with an ensure - attempting to catch why this is happening by logging more info, as we're unable to repro it. Guarding against nodes which reference malformed (TRASH) classes. #jira UE-26761 Change 2999768 on 2016/06/03 by Maciej.Mroz #jira UE-31592, UE-31593 This is just workaound. FReferenceFinder::FindReferences doesn;t find Enum variable in UByteProperty. Change 2999770 on 2016/06/03 by Maciej.Mroz [Blueprint Nativization] Workaround for missing ==operator in native structures. The generated code uses special version of array funtions. Change 2999798 on 2016/06/03 by Mike.Beach Guarding against malformed Blueprints (ones without valid "authoratative" class) used as context for the node menu. Baffling how we'd get into this scenario, but this adds ensures to hopefully give us clues and stabalize the editor. #jira UE-31522 Change 2999941 on 2016/06/03 by Mike.Beach Correcting mistake in previously attempted fix (CL 2781229). Now using weak ptr IsValid checks to guard against destroyed nodes in deferred graph actions (TWeakObjectPtr::Get() does not check IsValid before returning). #jira UE-23371 Change 3001731 on 2016/06/06 by Phillip.Kavan [UE-30638] BP profiler will no longer crash at runtime while profiling events that call functions on an external target. change summary: - modified FBlueprintProfiler::ProcessEventProfilingData() to only remove 'Class' and 'Instance' signals on new events. - modified FScriptEventPlayback::NodeSignalHelper struct to include a new 'BlueprintContext' field. - modified FScriptEventPlayback::Process() to handle midstream context switches by updating the Blueprint/Function context on 'Class' and/or 'Instance' signals. - modified FScriptEventPlayback::Process() to cache and reference the current Blueprint context within the cached NodeSignalHelper while handling processed events. Change 3002075 on 2016/06/06 by Maciej.Mroz Improved FScriptBuilderBase::EmitTermExpr in KismetCompilerVMBackend. Literal expression can be emitted without known desitination property. #jira UE-28443 Set Boolean (by ref) crashes the editor on compile Change 3002096 on 2016/06/06 by Ben.Cosh This change expands the way that the blueprint profiler detects event nodes during mapping to include other non function graphs. #Jira UE-30716 - Blueprint Profiler crashes if function in another graph is called #Proj BlueprintProfiler Change 3002108 on 2016/06/06 by Ben.Cosh Adds a new default option to average the blueprint level stats in the profiler. #Jira UE-31386 - BP Profiler - Timings reported with "Show Instances" off (in the tree view) are not averaged #Proj Kismet, BlueprintProfiler - The controls were also getting a bit messy so I tidied them all up into a re-usable toolbar for convenience going forward. Change 3002782 on 2016/06/06 by samuel.proctor Test assets for Interface testing Change 3003826 on 2016/06/07 by Ben.Cosh A few minor visual improvements for the blueprint profiler. #Proj Kismet, BlueprintProfiler, EditorStyle - Updated the actor icon to match the world outliner and added some functionality to draw attention to stale/deleted actors. - Updated the pure node icon. Change 3004067 on 2016/06/07 by samuel.proctor New test asset for blueprint interfaces Change 3004069 on 2016/06/07 by samuel.proctor Updating asset for Interface testing Change 3004275 on 2016/06/07 by Ryan.Rauschkolb Fixed issue where Toggle Comment Bubble button for Reroute nodes would not rever tthe comment bubble to constant visibility #jira UE-23733 Change 3004329 on 2016/06/07 by Dan.Oconnor EdGraphPin is no longer a UObject, this will improve load times significantly on projects with large number of blueprints, but content does need to be resaved in order to see the improvement in load time. UObject counts are also greatly reduced. Change 3004418 on 2016/06/07 by Maciej.Mroz KismetCompilerVMBackend: Fixed issue, when a byte property has no enum specified (for examle parameter from EqualEqual_ByteByte) but the enum is needed to parse a literal value. Change3004496on 2016/06/07 by Dan.Oconnor Disabling expensive pin allocation tracking Change 3004649 on 2016/06/07 by Mike.Beach Preventing a new warning from being generated on trace point exceptions (trace point exceptions are used to hook into the debugger, and don't represent errors). #jira UE-31236 Change 3004667 on 2016/06/07 by Dan.Oconnor Removed my debugging logic Change 3004848 on 2016/06/07 by Dan.Oconnor Fix spammy ensure Change 3004871 on 2016/06/07 by Phillip.Kavan [UE-24950] No longer including components instanced as default subobjects of and attached to components instanced by construction script in the IWCE component tree view. change summary: - modified SSCSEditor::UpdateTree() to exclude child components instanced in native code as "nested" DSOs and parented to non-natively-constructed (e.g. Blueprint) components; these instances are no longer being shown in IWCE in order to avoid confusion, as they're not currently mutable at the instance level, will always be parented to something that is visible in the tree, and they're also not currently shown in the Blueprint editor's component tree view (because they're not stored in the CDO). - modified FSceneComponentData's ctor to exclude child components instanced in native code as nested DSOs from the AttachedInstancedComponents array; this allows child components instanced as nested DSOs to be disposed of along with the constructed parent instance when re-running construction scripts. Change 3005203 on 2016/06/07 by Dan.Oconnor Fix for undo/redo/serialization issues with ed graph pin change. When serialization logic was applied incrementally our attempts to keep LinkedTo symetrical and aggressively clear destroyed nodes caused problems #jira UE-31750 Change 3005441 on 2016/06/08 by Maciej.Mroz #jira UE-31625 Crash in nativized Orion AssembleReferenceTokenStream is called for Dynamic Classes: - in ConstructDynamicType() (when class is explicitly loaded) - in __CustomDynamicClassInitialization() (when CDO is created) Change 3005540 on 2016/06/08 by Ben.Cosh This adds the ability to track profiler instances between editor and PIE instances and displays the current status through the icon coloring. #Jira UE-30705 - Blueprint profiler stats lost if instance destroyed during PIE #Proj BlueprintProfiler, Kismet - The jira was already fixed but I think this change improves the instance status clarity Change 3006196 on 2016/06/08 by Dan.Oconnor Copy/paste logic for pin connections got lost in the shuffle #jira UE-31747 Change 3006416 on 2016/06/08 by Phillip.Kavan [UE-31735] Fix potential loss of GetClassDefaults node output pin links on load (due to dependency load order). change summary: - modified UK2Node_GetClassDefaults::GetInputClass() to redirect to the generated skeleton class only if it's valid. this ensures that output pins will be reallocated during node reconstruction even if the dependent Blueprint's skeleton class has not yet been generated on load. Change 3006522 on 2016/06/08 by Dan.Oconnor Under rare circumstances a deprecated pin comes in that is outered to the transient package #jira UE-31779 Change 3006576 on 2016/06/08 by Dan.Oconnor Fix for non-editor builds #jira UE-31796 Change 3006610 on 2016/06/08 by Phillip.Kavan [UE-31743] Fix data loss issue when loading a serialized non-native component class instance that's owned by an Actor-based Blueprint class instance. change summary: - modified FObjectInitializer::InitProperties() to disable fast path initialization for non-native class types when the default data does not equate to the non-native CDO (as is also done within the native path). this is necessary because the optimized property list that we generate at load time to support fast path initialization of Blueprint class instances is only applicable to the generated CDO. Change 3006824 on 2016/06/08 by Dan.Oconnor More undo/redo fixes, this time fixes for when transaction buffer changes # of pins, thus destabalizing the LinkedTo arrays #jira UE-31794 Change 3006828 on 2016/06/08 by Dan.Oconnor Fix for non-editor builds Change 3006857 on 2016/06/08 by Dan.Oconnor Investigating shutdown ensure, traced back to a static UEdGraphPin Change 3006907 on 2016/06/08 by Dan.Oconnor Noneditor build fix Change 3006929 on 2016/06/08 by Dan.Oconnor Deferring DeprecatedPins destruction until after UBlueprint has had a chance to fix up its watched pins, this is a better fix for #jira UE-31779 Change 3007133 on 2016/06/09 by Ben.Cosh Fix for issue in the profiler asserting creating pins that don't have unique names. #Jira UE-31752 - Crash compiling various Orion assets for blueprints profiling, ScriptExecNode.IsValid() failed #Proj BlueprintProfiler - I believe this was recently introduced with the changes to UEdGraphPin's Change 3007964 on 2016/06/09 by Dan.Oconnor Fix for PinHelpers::UnresolvedPins being left with stale entries by undo/redo #jira UE-31829 Change 3007996 on 2016/06/09 by Ryan.Rauschkolb Added 'empty' keyword to Array Clear Node. #jira UE-12356 Change 3008007 on 2016/06/09 by Ryan.Rauschkolb Added 'negate' keyword to boolean NOT node #jira UE-12490 Change3008011on 2016/06/09 by Ryan.Rauschkolb Added Vector2D * Vector2D multiplication node #jira UE-31503 Change 3008014 on 2016/06/09 by Ryan.Rauschkolb Fixed Cannot connect Make Array node output to MakeArray input with split pins #jira UE-28530 Change 3008243 on 2016/06/09 by Dan.Oconnor Fix for creation of FWeakGraphPinPtr from a pin that had been destroyed, client logic is still a bit broken in the case of the ClassDefaults node, but we're back to 'safe' #jira UE-31841 Change 3008289 on 2016/06/09 by Dan.Oconnor Editor transaction saves all state before applying undo/redo buffers when using 'bFlip' flow. This prevents messing with the object graph in the middle of saving state that will be restored later #jira UE-31794 Change 3008422 on 2016/06/09 by Dan.Oconnor Correct usage of GIsTransacting, replaced with Ar.IsTransacting() to correctly handle the case where we serialize after transacting but during the transaction (for instance, recompile blueprint in post undo, which we do quite a bit it turns out) #jira UE-31857 Change 3009164 on 2016/06/10 by Ryan.Rauschkolb Making changes to default values in the structure editor will now make changes to the structure without rebuilding the default values panel. #jira UE-21141,UE-23723 Change 3009165 on 2016/06/10 by Ryan.Rauschkolb Fixed Structure Default value editor collapses after undoing an alteration of a default value #jira UE-31741 Change 3009181 on 2016/06/10 by Ryan.Rauschkolb Fixed issue where modifying a default value in a Widget Blueprint would cause the Details Panel to refresh #jira UE-30014 Change 3009313 on 2016/06/10 by Mike.Beach Addressing issues with function return nodes in multiple ways: - Preventing users from deleting return nodes for overriden/inherited functions. - Also making sure that we create terminals for out params when the return node is disconnected (and pruned). - Lastly, ensuring that new return nodes adhere to the function's signature (for cases, like where you copy/paste a return node from a different function). #jira UE-31418 Change 3009595 on 2016/06/10 by Dan.Oconnor EdGraphPinReference using PinId to resolve itself again, may create issues resolving pins created in compile #jira UE-31879 Change 3009774 on 2016/06/10 by Dan.Oconnor Fix for bad logic in RemovePin introduced in 3004329, just a bad reading of the logic, missed an early return #jira UE-31906 Change 3009988 on 2016/06/10 by Dan.Oconnor Prefer to use existing pins (based on PinId) when undoing/redoing pin serialization #jira UE-31888 Change 3010050 on 2016/06/10 by Dan.Oconnor Fixed missing call to ssuper class's PostEditUndo, fixed UBehaviorTreeGraph::PostEditUndo accessing Pins before they have been resolved #jira UE-31892 Change 3010071 on 2016/06/10 by Dan.Oconnor Fix for pasting when owning node has whitespace in result of GetPathName #jira UE-31898 #coderview Bob.Tellez Change 3010244 on 2016/06/11 by Dan.Oconnor Fix for trivial copy/paste error, causes crash when copying/pasting nodes with text default values, part of UE-31870 Change 3010630 on 2016/06/13 by Dan.Oconnor No longer relying on path name for pin resolution, path is unstable across graphs #jira UE-31870 Change 3010647 on 2016/06/13 by Dan.Oconnor PR #2496: Updated KismetMathLibrary comparison descriptions for FDateTime and FTimespan. (Contributed by CelPlays) #jira UE-31928 Change 3011175 on 2016/06/13 by Ben.Cosh Updates the Blueprint Profiler so that it can correctly map entry/exit from tunnels based on instance. #Jira UE-30106 - Compiling QA_PhysVelocitySettleTest with the blueprint profiler results in a crash/assert #Proj Kismet, BlueprintProfiler - Ensured that the trace paths contain the macro instance exec nodes - Selectively update stats in the tunnel exit site nodes based on valid exit sites to prevent cyclic updates. - Updated the comments in map tunnel entry to spare peoples sanity when trying to understand what that function does. Change 3011271 on 2016/06/13 by Ben.Cosh This adds support for inherited blueprint classes to the blueprint profiler. #Jira UE-31833 - The Blueprint profiler asserts when using a FlipFlop macro. #Jira UE-31752 - Crash compiling various Orion assets for blueprints profiling, ScriptExecNode.IsValid() failed #Proj BlueprintProfiler Change 3011556 on 2016/06/13 by Ryan.Rauschkolb Fixed Crash when breaking link to a split pin in MakeArray that is an array type #jira UE-31919 Change 3011624 on 2016/06/13 by Dan.Oconnor Fix for missing entries in MessageLog's source pin identification map. Bob T had originally populated this correctly, but somehow i lost it while iterating. #jira UE-31955 Change 3011984 on 2016/06/13 by Dan.Oconnor Sanitizing parentpin's subpins when destroying a pin #jira UE-21392 Change 3012894 on 2016/06/14 by Phillip.Kavan [UE-30922] Ensure that customized defaults are propagated to new instances at construction time during non-Actor-based Blueprint class reinstancing. change summary: - modified FBlueprintCompileReinstancer::ReplaceInstancesOfClass_Inner() to use the reinstanced archetype object as the template object during construction of the new instance for non-Actor-based Blueprint class types. #jira UE-30922 Change 3013037 on 2016/06/14 by Ryan.Rauschkolb Fixed Crash when connecting to a split pin in a MakeArray node that has no connections #jira UE-31917 Change 3014846 on 2016/06/15 by Dan.Oconnor No longer using FText::IsLetter to parse math expression nodes, that function is very slow. $x is now a valid math expression variable name (genereated a compile error prior to this change) #jira FORT-23753 Change 3015014 on 2016/06/15 by Dan.Oconnor Removing poorly implement IsLetter function Change 3015142 on 2016/06/15 by Dan.Oconnor More intentional about removing subpins, prevents stale iterator on split pin collapse #jira UE-32072 Change 3016326 on 2016/06/16 by Ryan.Rauschkolb Fixed MakeArray node does not reset to wildcard when breaking links with split struct pins that have default values #jira UE-32016 Change 3016494 on 2016/06/16 by Ryan.Rauschkolb Fixed Crash when dragging a component into the Event Graph that's inherited from a C++ class #jira UE-31876 Change 3016557 on 2016/06/16 by Dan.Oconnor Explicit copy/move of string data for FText, removes some redundant copying and object construction/destruction [which could be optimzed away], saves 2-3 seconds in my 80s load asset benchmark #jira FORT-23753 Change 3016577 on 2016/06/16 by Ryan.Rauschkolb Fixed compiler warning for hidden member variable in FBlueprintVarActionDetails::GetVariableReplicationType Change 3016906 on 2016/06/16 by Dan.Oconnor Back out changelist 3016557 This will be done by Jamie.Dale in Dev-Editor Change 3018081 on 2016/06/17 by Phillip.Kavan [UE-31832] PR #2486: Expose UInheritableComponentHandler::GetAllTemplates() outside of editor (Contributed by Bogustus) #jira UE-31832 Change 3018402 on 2016/06/17 by Dan.Oconnor Missing include Change 3018426 on 2016/06/17 by Ryan.Rauschkolb Fixed MakeArray node with split pins and no connections does not paste correctly #jira UE-32148 Change 3018452 on 2016/06/17 by Mike.Beach Moving the patching of instanced sub-objects out of CPFUO (where you can't rely on the target to be a replacement for the source) to FBlueprintEditorUtils::PatchCDOSubobjectsIntoExport(), and making it so PatchCDOSubobjectsIntoExport() is called regularly for Blueprint regeneration (on load). #jira UE-32158 Change 3018456 on 2016/06/17 by Dan.Oconnor Fix for static analysis warning, this null check does nothing Change3018595on 2016/06/17 by Mike.Beach Fix for shadowed variable warning in CIS. Change 3018699 on 2016/06/17 by Mike.Beach Making MinimumAreaRectangle callable in Blueprints without world context (which is only needed for debug drawing). Change 3019734 on 2016/06/20 by Phillip.Kavan [UE-32064] Clone associated component template(s) when duplicating Blueprint function graphs containing one or more Add Component nodes. change summary: - added a UK2Node_AddComponent::PostDuplicate() override - moved UK2Node_AddComponent::PostPasteNode() logic into a helper method that's now called from both PostDuplicate() and PostPasteNode() overrides. notes: - will prevent getting into the scenario described in UE-31831 #jira UE-32064 Change 3020635 on 2016/06/20 by Dan.Oconnor Fix for bad cast in FCompilerResultsLog::Append, could cause crashes in clients of this function (math expressions nodes occasionally do when they fail to compile) Change 3020894 on 2016/06/21 by Maciej.Mroz #2522: Interface UProperties can ExposeOnSpawn (in Blueprints) (Contributed by MichaelSchoell) Change 3020958 on 2016/06/21 by Ben.Cosh This improves the way key events are detected in the blueprint profiler, preventing duplicate event entries when pressed and released are both wired. It also catches a bug with the compiler instrumentation flag when compiling. #Jira UE-32270 - Input key events generate extra instrumentation data per key press #Jira UE-32266 - Recompiling blueprints with instrumentation can fail to add instrumentation. #Proj BlueprintProfiler, UnrealEd Change 3021316 on 2016/06/21 by Ryan.Rauschkolb Fixed issue where Copy/Paste of event nodes would not retain link information Change 3021826 on 2016/06/21 by Phillip.Kavan [UE-31831] Fix up AddComponent nodes on load if they are not associated with a unique template object. change summary: - added external linkage to UK2Node_AddComponent::MakeNewComponentTemplate(), and switched it to be a public API - modified FBlueprintEditorUtils::UpdateComponentTemplates() (as this is already called on Blueprint load) to detect/warn and correct non-unique templates #jira UE-31831 Change 3022047 on 2016/06/21 by Ryan.Rauschkolb Fixed issue where copy/paste of return nodes would not preserve value or link data #jira UE-26937 Change 3022619 on 2016/06/22 by Maciej.Mroz #jira UE-30858 Nativized Orion - Some particle effects are not rendering A static/persistent information (the mechanism is similar to AssetRegistrySearchable) about DynamicClass is added. It's necessary since DynamicClasses are not handled as regular assets by AssetRegistry. Fixed GameplayCueManager. Nativized cues can be found. This is an early version of the feature. Amount of stored persistent data can be extended (but it would increase memory-usage). Change 3022654 on 2016/06/22 by Maciej.Mroz FBackendHelperStaticSearchableValues -fixed too strict ensure Change 3023067 on 2016/06/22 by Maciej.Mroz #jira UE-32083 Nativize Blueprints removes blueprint functionality in packaged project Config settings from super class are not applied (at runtime) to nativized Blueprints . So all "config" properties are filled in constructor. Change 3023222 on 2016/06/22 by Ryan.Rauschkolb Fixed MakeArray node elements break when editing struct elements #jira UE-21392 Change 3023405 on 2016/06/22 by Mike.Beach Making sure sub-objects get instanced for Blueprint CDOs that had their FObjectInitializer deferred (happens when the super CDO hasn't been fully serialized). By the time the deferred FObjectInitializer is ran, the sub-objects have been assigned a RF_NeedLoad flag (where they normally wouldn't have one right after construction, when the initialization is usually ran). #jira UE-31897 Change 3023992 on 2016/06/22 by Mike.Beach Fixed an issue where hovering on/off a reroute node (toggling the comment bubble visibility) would create extraneous undo transactions. #jira UE-31859 [CL 3025946 by Mike Beach in Main branch]
1695 lines
56 KiB
C++
1695 lines
56 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
#include "GraphEditorCommon.h"
|
|
#include "NodeFactory.h"
|
|
|
|
#include "Editor/UnrealEd/Public/DragAndDrop/ActorDragDropGraphEdOp.h"
|
|
#include "Editor/UnrealEd/Public/DragAndDrop/AssetDragDropOp.h"
|
|
#include "Editor/UnrealEd/Public/DragAndDrop/LevelDragDropOp.h"
|
|
|
|
#include "GraphEditorActions.h"
|
|
#include "UICommandInfo.h"
|
|
#include "InputChord.h"
|
|
|
|
#include "ConnectionDrawingPolicy.h"
|
|
|
|
#include "AssetSelection.h"
|
|
#include "ComponentAssetBroker.h"
|
|
|
|
#include "KismetNodes/KismetNodeInfoContext.h"
|
|
#include "GraphDiffControl.h"
|
|
|
|
#include "AnimationGraphSchema.h"
|
|
#include "AnimationStateMachineSchema.h"
|
|
|
|
DEFINE_LOG_CATEGORY_STATIC(LogGraphPanel, Log, All);
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// FGraphPinHandle
|
|
|
|
FGraphPinHandle::FGraphPinHandle(UEdGraphPin* InPin)
|
|
{
|
|
if (InPin != nullptr)
|
|
{
|
|
if (UEdGraphNode* Node = InPin->GetOwningNodeUnchecked())
|
|
{
|
|
PinName = InPin->PinName;
|
|
NodeGuid = Node->NodeGuid;
|
|
}
|
|
}
|
|
}
|
|
|
|
TSharedPtr<SGraphPin> FGraphPinHandle::FindInGraphPanel(const SGraphPanel& InPanel) const
|
|
{
|
|
// First off, find the node
|
|
if (NodeGuid.IsValid())
|
|
{
|
|
TSharedPtr<SGraphNode> GraphNode = InPanel.GetNodeWidgetFromGuid(NodeGuid);
|
|
if (GraphNode.IsValid())
|
|
{
|
|
UEdGraphNode* Node = GraphNode->GetNodeObj();
|
|
|
|
if (UEdGraphPin* Pin = Node->FindPin(PinName))
|
|
{
|
|
return GraphNode->FindWidgetForPin(Pin);
|
|
}
|
|
}
|
|
}
|
|
|
|
return TSharedPtr<SGraphPin>();
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// SGraphPanel
|
|
|
|
void SGraphPanel::Construct( const SGraphPanel::FArguments& InArgs )
|
|
{
|
|
SNodePanel::Construct();
|
|
|
|
this->OnGetContextMenuFor = InArgs._OnGetContextMenuFor;
|
|
this->GraphObj = InArgs._GraphObj;
|
|
this->GraphObjToDiff = InArgs._GraphObjToDiff;
|
|
this->SelectionManager.OnSelectionChanged = InArgs._OnSelectionChanged;
|
|
this->IsEditable = InArgs._IsEditable;
|
|
this->DisplayAsReadOnly = InArgs._DisplayAsReadOnly;
|
|
this->OnNodeDoubleClicked = InArgs._OnNodeDoubleClicked;
|
|
this->OnDropActor = InArgs._OnDropActor;
|
|
this->OnDropStreamingLevel = InArgs._OnDropStreamingLevel;
|
|
this->OnVerifyTextCommit = InArgs._OnVerifyTextCommit;
|
|
this->OnTextCommitted = InArgs._OnTextCommitted;
|
|
this->OnSpawnNodeByShortcut = InArgs._OnSpawnNodeByShortcut;
|
|
this->OnUpdateGraphPanel = InArgs._OnUpdateGraphPanel;
|
|
this->OnDisallowedPinConnection = InArgs._OnDisallowedPinConnection;
|
|
|
|
this->bPreservePinPreviewConnection = false;
|
|
this->PinVisibility = SGraphEditor::Pin_Show;
|
|
|
|
CachedAllottedGeometryScaledSize = FVector2D(160, 120);
|
|
if (InArgs._InitialZoomToFit)
|
|
{
|
|
ZoomToFit(/*bOnlySelection=*/ false);
|
|
bTeleportInsteadOfScrollingWhenZoomingToFit = true;
|
|
}
|
|
|
|
BounceCurve.AddCurve(0.0f, 1.0f);
|
|
|
|
FEditorDelegates::BeginPIE.AddRaw( this, &SGraphPanel::OnBeginPIE );
|
|
FEditorDelegates::EndPIE.AddRaw( this, &SGraphPanel::OnEndPIE );
|
|
|
|
// Register for notifications
|
|
MyRegisteredGraphChangedDelegate = FOnGraphChanged::FDelegate::CreateSP(this, &SGraphPanel::OnGraphChanged);
|
|
MyRegisteredGraphChangedDelegateHandle = this->GraphObj->AddOnGraphChangedHandler(MyRegisteredGraphChangedDelegate);
|
|
|
|
ShowGraphStateOverlay = InArgs._ShowGraphStateOverlay;
|
|
|
|
SavedMousePosForOnPaintEventLocalSpace = FVector2D::ZeroVector;
|
|
PreviousFrameSavedMousePosForSplineOverlap = FVector2D::ZeroVector;
|
|
|
|
TimeLeftToInvalidatePerTick = 0.0f;
|
|
}
|
|
|
|
SGraphPanel::~SGraphPanel()
|
|
{
|
|
FEditorDelegates::BeginPIE.RemoveAll( this );
|
|
FEditorDelegates::EndPIE.RemoveAll( this );
|
|
|
|
this->GraphObj->RemoveOnGraphChangedHandler(MyRegisteredGraphChangedDelegateHandle);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
int32 SGraphPanel::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
|
|
{
|
|
CachedAllottedGeometryScaledSize = AllottedGeometry.Size * AllottedGeometry.Scale;
|
|
|
|
//Style used for objects that are the same between revisions
|
|
FWidgetStyle FadedStyle = InWidgetStyle;
|
|
FadedStyle.BlendColorAndOpacityTint(FLinearColor(0.45f,0.45f,0.45f,0.45f));
|
|
|
|
// First paint the background
|
|
const UEditorExperimentalSettings& Options = *GetDefault<UEditorExperimentalSettings>();
|
|
|
|
const FSlateBrush* BackgroundImage = FEditorStyle::GetBrush(TEXT("Graph.Panel.SolidBackground"));
|
|
PaintBackgroundAsLines(BackgroundImage, AllottedGeometry, MyClippingRect, OutDrawElements, LayerId);
|
|
|
|
const float ZoomFactor = AllottedGeometry.Scale * GetZoomAmount();
|
|
|
|
FArrangedChildren ArrangedChildren(EVisibility::Visible);
|
|
ArrangeChildNodes(AllottedGeometry, ArrangedChildren);
|
|
|
|
// Determine some 'global' settings based on current LOD
|
|
const bool bDrawShadowsThisFrame = GetCurrentLOD() > EGraphRenderingLOD::LowestDetail;
|
|
|
|
// Because we paint multiple children, we must track the maximum layer id that they produced in case one of our parents
|
|
// wants to an overlay for all of its contents.
|
|
|
|
// Save LayerId for comment boxes to ensure they always appear below nodes & wires
|
|
const int32 CommentNodeShadowLayerId = LayerId++;
|
|
const int32 CommentNodeLayerId = LayerId++;
|
|
|
|
// Save a LayerId for wires, which appear below nodes but above comments
|
|
// We will draw them later, along with the arrows which appear above nodes.
|
|
const int32 WireLayerId = LayerId++;
|
|
|
|
const int32 NodeShadowsLayerId = LayerId;
|
|
const int32 NodeLayerId = NodeShadowsLayerId + 1;
|
|
int32 MaxLayerId = NodeLayerId;
|
|
|
|
const FPaintArgs NewArgs = Args.WithNewParent(this);
|
|
|
|
const FVector2D NodeShadowSize = GetDefault<UGraphEditorSettings>()->GetShadowDeltaSize();
|
|
const UEdGraphSchema* Schema = GraphObj->GetSchema();
|
|
|
|
// Draw the child nodes
|
|
{
|
|
// When drawing a marquee, need a preview of what the selection will be.
|
|
const FGraphPanelSelectionSet* SelectionToVisualize = &(SelectionManager.SelectedNodes);
|
|
FGraphPanelSelectionSet SelectionPreview;
|
|
if ( Marquee.IsValid() )
|
|
{
|
|
ApplyMarqueeSelection(Marquee, SelectionManager.SelectedNodes, SelectionPreview);
|
|
SelectionToVisualize = &SelectionPreview;
|
|
}
|
|
|
|
// Context for rendering node infos
|
|
FKismetNodeInfoContext Context(GraphObj);
|
|
|
|
TArray<FGraphDiffControl::FNodeMatch> NodeMatches;
|
|
for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex)
|
|
{
|
|
FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex];
|
|
TSharedRef<SGraphNode> ChildNode = StaticCastSharedRef<SGraphNode>(CurWidget.Widget);
|
|
|
|
// Examine node to see what layers we should be drawing in
|
|
int32 ShadowLayerId = NodeShadowsLayerId;
|
|
int32 ChildLayerId = NodeLayerId;
|
|
|
|
// If a comment node, draw in the dedicated comment slots
|
|
{
|
|
UObject* NodeObj = ChildNode->GetObjectBeingDisplayed();
|
|
if (NodeObj && NodeObj->IsA(UEdGraphNode_Comment::StaticClass()))
|
|
{
|
|
ShadowLayerId = CommentNodeShadowLayerId;
|
|
ChildLayerId = CommentNodeLayerId;
|
|
}
|
|
}
|
|
|
|
|
|
const bool bNodeIsVisible = FSlateRect::DoRectanglesIntersect( CurWidget.Geometry.GetClippingRect(), MyClippingRect );
|
|
|
|
if (bNodeIsVisible)
|
|
{
|
|
const bool bSelected = SelectionToVisualize->Contains( StaticCastSharedRef<SNodePanel::SNode>(CurWidget.Widget)->GetObjectBeingDisplayed() );
|
|
|
|
// Handle Node renaming once the node is visible
|
|
if( bSelected && ChildNode->IsRenamePending() )
|
|
{
|
|
// Only open a rename when the window has focus
|
|
TSharedPtr<SWindow> OwnerWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
|
|
if (!OwnerWindow.IsValid() || FSlateApplication::Get().HasFocusedDescendants(OwnerWindow.ToSharedRef()))
|
|
{
|
|
ChildNode->ApplyRename();
|
|
}
|
|
}
|
|
|
|
// Draw the node's shadow.
|
|
if (bDrawShadowsThisFrame || bSelected)
|
|
{
|
|
const FSlateBrush* ShadowBrush = ChildNode->GetShadowBrush(bSelected);
|
|
FSlateDrawElement::MakeBox(
|
|
OutDrawElements,
|
|
ShadowLayerId,
|
|
CurWidget.Geometry.ToInflatedPaintGeometry(NodeShadowSize),
|
|
ShadowBrush,
|
|
MyClippingRect
|
|
);
|
|
}
|
|
|
|
// Draw the comments and information popups for this node, if it has any.
|
|
{
|
|
const SNodePanel::SNode::FNodeSlot* CommentSlot = ChildNode->GetSlot( ENodeZone::TopCenter );
|
|
float CommentBubbleY = CommentSlot ? -CommentSlot->Offset.Get().Y : 0.f;
|
|
Context.bSelected = bSelected;
|
|
TArray<FGraphInformationPopupInfo> Popups;
|
|
|
|
{
|
|
ChildNode->GetNodeInfoPopups(&Context, /*out*/ Popups);
|
|
}
|
|
|
|
for (int32 PopupIndex = 0; PopupIndex < Popups.Num(); ++PopupIndex)
|
|
{
|
|
FGraphInformationPopupInfo& Popup = Popups[PopupIndex];
|
|
PaintComment(Popup.Message, CurWidget.Geometry, MyClippingRect, OutDrawElements, ChildLayerId, Popup.BackgroundColor, /*inout*/ CommentBubbleY, InWidgetStyle);
|
|
}
|
|
}
|
|
|
|
int32 CurWidgetsMaxLayerId;
|
|
{
|
|
UEdGraphNode* NodeObj = Cast<UEdGraphNode>(ChildNode->GetObjectBeingDisplayed());
|
|
|
|
/** When diffing nodes, nodes that are different between revisions are opaque, nodes that have not changed are faded */
|
|
FGraphDiffControl::FNodeMatch NodeMatch = FGraphDiffControl::FindNodeMatch(GraphObjToDiff, NodeObj, NodeMatches);
|
|
if (NodeMatch.IsValid())
|
|
{
|
|
NodeMatches.Add(NodeMatch);
|
|
}
|
|
const bool bNodeIsDifferent = (!GraphObjToDiff || NodeMatch.Diff(FGraphDiffControl::FNodeDiffContext()));
|
|
|
|
/* When dragging off a pin, we want to duck the alpha of some nodes */
|
|
TSharedPtr< SGraphPin > OnlyStartPin = (1 == PreviewConnectorFromPins.Num()) ? PreviewConnectorFromPins[0].FindInGraphPanel(*this) : TSharedPtr< SGraphPin >();
|
|
const bool bNodeIsNotUsableInCurrentContext = Schema->FadeNodeWhenDraggingOffPin(NodeObj, OnlyStartPin.IsValid() ? OnlyStartPin.Get()->GetPinObj() : nullptr);
|
|
const FWidgetStyle& NodeStyleToUse = (bNodeIsDifferent && !bNodeIsNotUsableInCurrentContext)? InWidgetStyle : FadedStyle;
|
|
|
|
// Draw the node.O
|
|
CurWidgetsMaxLayerId = CurWidget.Widget->Paint(NewArgs, CurWidget.Geometry, MyClippingRect, OutDrawElements, ChildLayerId, NodeStyleToUse, !DisplayAsReadOnly.Get() && ShouldBeEnabled( bParentEnabled ) );
|
|
}
|
|
|
|
// Draw the node's overlay, if it has one.
|
|
{
|
|
// Get its size
|
|
const FVector2D WidgetSize = CurWidget.Geometry.Size;
|
|
|
|
{
|
|
TArray<FOverlayBrushInfo> OverlayBrushes;
|
|
ChildNode->GetOverlayBrushes(bSelected, WidgetSize, /*out*/ OverlayBrushes);
|
|
|
|
for (int32 BrushIndex = 0; BrushIndex < OverlayBrushes.Num(); ++BrushIndex)
|
|
{
|
|
FOverlayBrushInfo& OverlayInfo = OverlayBrushes[BrushIndex];
|
|
const FSlateBrush* OverlayBrush = OverlayInfo.Brush;
|
|
if (OverlayBrush != nullptr)
|
|
{
|
|
FPaintGeometry BouncedGeometry = CurWidget.Geometry.ToPaintGeometry(OverlayInfo.OverlayOffset, OverlayBrush->ImageSize, 1.f);
|
|
|
|
// Handle bouncing during PIE
|
|
const float BounceValue = FMath::Sin(2.0f * PI * BounceCurve.GetLerp());
|
|
BouncedGeometry.DrawPosition += (OverlayInfo.AnimationEnvelope * BounceValue * ZoomFactor);
|
|
|
|
CurWidgetsMaxLayerId++;
|
|
FSlateDrawElement::MakeBox(
|
|
OutDrawElements,
|
|
CurWidgetsMaxLayerId,
|
|
BouncedGeometry,
|
|
OverlayBrush,
|
|
MyClippingRect
|
|
);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
{
|
|
TArray<FOverlayWidgetInfo> OverlayWidgets = ChildNode->GetOverlayWidgets(bSelected, WidgetSize);
|
|
|
|
for (int32 WidgetIndex = 0; WidgetIndex < OverlayWidgets.Num(); ++WidgetIndex)
|
|
{
|
|
FOverlayWidgetInfo& OverlayInfo = OverlayWidgets[WidgetIndex];
|
|
if(OverlayInfo.Widget->GetVisibility() == EVisibility::Visible)
|
|
{
|
|
// call SlatePrepass as these widgets are not in the 'normal' child hierarchy
|
|
OverlayInfo.Widget->SlatePrepass(AllottedGeometry.GetAccumulatedLayoutTransform().GetScale());
|
|
|
|
const FGeometry WidgetGeometry = CurWidget.Geometry.MakeChild(OverlayInfo.OverlayOffset, OverlayInfo.Widget->GetDesiredSize());
|
|
|
|
OverlayInfo.Widget->Paint(NewArgs, WidgetGeometry, MyClippingRect, OutDrawElements, CurWidgetsMaxLayerId, InWidgetStyle, bParentEnabled);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
MaxLayerId = FMath::Max( MaxLayerId, CurWidgetsMaxLayerId + 1 );
|
|
}
|
|
}
|
|
}
|
|
|
|
MaxLayerId += 1;
|
|
|
|
|
|
// Draw connections between pins
|
|
if (Children.Num() > 0 )
|
|
{
|
|
FConnectionDrawingPolicy* ConnectionDrawingPolicy = FNodeFactory::CreateConnectionPolicy(Schema, WireLayerId, MaxLayerId, ZoomFactor, MyClippingRect, OutDrawElements, GraphObj);
|
|
|
|
TArray<TSharedPtr<SGraphPin>> OverridePins;
|
|
for (const FGraphPinHandle& Handle : PreviewConnectorFromPins)
|
|
{
|
|
TSharedPtr<SGraphPin> Pin = Handle.FindInGraphPanel(*this);
|
|
if (Pin.IsValid())
|
|
{
|
|
OverridePins.Add(Pin);
|
|
}
|
|
}
|
|
ConnectionDrawingPolicy->SetHoveredPins(CurrentHoveredPins, OverridePins, TimeWhenMouseEnteredPin);
|
|
ConnectionDrawingPolicy->SetMarkedPin(MarkedPin);
|
|
ConnectionDrawingPolicy->SetMousePosition(AllottedGeometry.AbsolutePosition + SavedMousePosForOnPaintEventLocalSpace);
|
|
|
|
// Get the set of pins for all children and synthesize geometry for culled out pins so lines can be drawn to them.
|
|
TMap<TSharedRef<SWidget>, FArrangedWidget> PinGeometries;
|
|
TSet< TSharedRef<SWidget> > VisiblePins;
|
|
for (int32 ChildIndex = 0; ChildIndex < Children.Num(); ++ChildIndex)
|
|
{
|
|
TSharedRef<SGraphNode> ChildNode = StaticCastSharedRef<SGraphNode>(Children[ChildIndex]);
|
|
|
|
// If this is a culled node, approximate the pin geometry to the corner of the node it is within
|
|
if (IsNodeCulled(ChildNode, AllottedGeometry))
|
|
{
|
|
TArray< TSharedRef<SWidget> > NodePins;
|
|
ChildNode->GetPins(NodePins);
|
|
|
|
const FVector2D NodeLoc = ChildNode->GetPosition();
|
|
const FGeometry SynthesizedNodeGeometry(GraphCoordToPanelCoord(NodeLoc), AllottedGeometry.AbsolutePosition, FVector2D::ZeroVector, 1.f);
|
|
|
|
for (TArray< TSharedRef<SWidget> >::TConstIterator NodePinIterator(NodePins); NodePinIterator; ++NodePinIterator)
|
|
{
|
|
const SGraphPin& PinWidget = static_cast<const SGraphPin&>((*NodePinIterator).Get());
|
|
FVector2D PinLoc = NodeLoc + PinWidget.GetNodeOffset();
|
|
|
|
const FGeometry SynthesizedPinGeometry(GraphCoordToPanelCoord(PinLoc), AllottedGeometry.AbsolutePosition, FVector2D::ZeroVector, 1.f);
|
|
PinGeometries.Add(*NodePinIterator, FArrangedWidget(*NodePinIterator, SynthesizedPinGeometry));
|
|
}
|
|
|
|
// Also add synthesized geometries for culled nodes
|
|
ArrangedChildren.AddWidget( FArrangedWidget(ChildNode, SynthesizedNodeGeometry) );
|
|
}
|
|
else
|
|
{
|
|
ChildNode->GetPins(VisiblePins);
|
|
}
|
|
}
|
|
|
|
// Now get the pin geometry for all visible children and append it to the PinGeometries map
|
|
TMap<TSharedRef<SWidget>, FArrangedWidget> VisiblePinGeometries;
|
|
{
|
|
this->FindChildGeometries(AllottedGeometry, VisiblePins, VisiblePinGeometries);
|
|
PinGeometries.Append(VisiblePinGeometries);
|
|
}
|
|
|
|
// Draw preview connections (only connected on one end)
|
|
if (PreviewConnectorFromPins.Num() > 0)
|
|
{
|
|
for (const FGraphPinHandle& Handle : PreviewConnectorFromPins)
|
|
{
|
|
TSharedPtr< SGraphPin > CurrentStartPin = Handle.FindInGraphPanel(*this);
|
|
if (!CurrentStartPin.IsValid())
|
|
{
|
|
continue;
|
|
}
|
|
const FArrangedWidget* PinGeometry = PinGeometries.Find( CurrentStartPin.ToSharedRef() );
|
|
|
|
if (PinGeometry != nullptr)
|
|
{
|
|
FVector2D StartPoint;
|
|
FVector2D EndPoint;
|
|
|
|
if (CurrentStartPin->GetDirection() == EGPD_Input)
|
|
{
|
|
StartPoint = AllottedGeometry.AbsolutePosition + PreviewConnectorEndpoint;
|
|
EndPoint = FGeometryHelper::VerticalMiddleLeftOf( PinGeometry->Geometry ) - FVector2D(ConnectionDrawingPolicy->ArrowRadius.X, 0);
|
|
}
|
|
else
|
|
{
|
|
StartPoint = FGeometryHelper::VerticalMiddleRightOf( PinGeometry->Geometry );
|
|
EndPoint = AllottedGeometry.AbsolutePosition + PreviewConnectorEndpoint;
|
|
}
|
|
|
|
ConnectionDrawingPolicy->DrawPreviewConnector(PinGeometry->Geometry, StartPoint, EndPoint, CurrentStartPin.Get()->GetPinObj());
|
|
}
|
|
|
|
//@TODO: Re-evaluate this incompatible mojo; it's mutating every pin state every frame to accomplish a visual effect
|
|
ConnectionDrawingPolicy->SetIncompatiblePinDrawState(CurrentStartPin, VisiblePins);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//@TODO: Re-evaluate this incompatible mojo; it's mutating every pin state every frame to accomplish a visual effect
|
|
ConnectionDrawingPolicy->ResetIncompatiblePinDrawState(VisiblePins);
|
|
}
|
|
|
|
// Draw all regular connections
|
|
ConnectionDrawingPolicy->Draw(PinGeometries, ArrangedChildren);
|
|
|
|
// Pull back data from the drawing policy
|
|
{
|
|
FGraphSplineOverlapResult OverlapData = ConnectionDrawingPolicy->SplineOverlapResult;
|
|
|
|
if (OverlapData.IsValid())
|
|
{
|
|
OverlapData.ComputeBestPin();
|
|
|
|
// Only allow spline overlaps when there is no node under the cursor (unless it is a comment box)
|
|
const FVector2D PaintAbsoluteSpaceMousePos = AllottedGeometry.AbsolutePosition + SavedMousePosForOnPaintEventLocalSpace;
|
|
const int32 HoveredNodeIndex = SWidget::FindChildUnderPosition(ArrangedChildren, PaintAbsoluteSpaceMousePos);
|
|
if (HoveredNodeIndex != INDEX_NONE)
|
|
{
|
|
TSharedRef<SGraphNode> HoveredNode = StaticCastSharedRef<SGraphNode>(ArrangedChildren[HoveredNodeIndex].Widget);
|
|
UEdGraphNode_Comment* CommentNode = Cast<UEdGraphNode_Comment>(HoveredNode->GetObjectBeingDisplayed());
|
|
if (CommentNode == nullptr)
|
|
{
|
|
// Wasn't a comment node, disallow the spline interaction
|
|
OverlapData = FGraphSplineOverlapResult();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Update the spline hover state
|
|
const_cast<SGraphPanel*>(this)->OnSplineHoverStateChanged(OverlapData);
|
|
}
|
|
|
|
delete ConnectionDrawingPolicy;
|
|
}
|
|
|
|
// Draw a shadow overlay around the edges of the graph
|
|
++MaxLayerId;
|
|
PaintSurroundSunkenShadow(FEditorStyle::GetBrush(TEXT("Graph.Shadow")), AllottedGeometry, MyClippingRect, OutDrawElements, MaxLayerId);
|
|
|
|
if (ShowGraphStateOverlay.Get())
|
|
{
|
|
const FSlateBrush* BorderBrush = nullptr;
|
|
if ((GEditor->bIsSimulatingInEditor || GEditor->PlayWorld != nullptr))
|
|
{
|
|
// Draw a surrounding indicator when PIE is active, to make it clear that the graph is read-only, etc...
|
|
BorderBrush = FEditorStyle::GetBrush(TEXT("Graph.PlayInEditor"));
|
|
}
|
|
else if (!IsEditable.Get())
|
|
{
|
|
// Draw a different border when we're not simulating but the graph is read-only
|
|
BorderBrush = FEditorStyle::GetBrush(TEXT("Graph.ReadOnlyBorder"));
|
|
}
|
|
|
|
if (BorderBrush != nullptr)
|
|
{
|
|
// Actually draw the border
|
|
FSlateDrawElement::MakeBox(
|
|
OutDrawElements,
|
|
MaxLayerId,
|
|
AllottedGeometry.ToPaintGeometry(),
|
|
BorderBrush,
|
|
MyClippingRect
|
|
);
|
|
}
|
|
}
|
|
|
|
// Draw the marquee selection rectangle
|
|
PaintMarquee(AllottedGeometry, MyClippingRect, OutDrawElements, MaxLayerId);
|
|
|
|
// Draw the software cursor
|
|
++MaxLayerId;
|
|
PaintSoftwareCursor(AllottedGeometry, MyClippingRect, OutDrawElements, MaxLayerId);
|
|
|
|
return MaxLayerId;
|
|
}
|
|
|
|
void SGraphPanel::OnSplineHoverStateChanged(const FGraphSplineOverlapResult& NewSplineHoverState)
|
|
{
|
|
TSharedPtr<SGraphPin> OldPinWidget = PreviousFrameSplineOverlap.GetBestPinWidget(*this);
|
|
PreviousFrameSplineOverlap = NewSplineHoverState;
|
|
TSharedPtr<SGraphPin> NewPinWidget = PreviousFrameSplineOverlap.GetBestPinWidget(*this);
|
|
|
|
PreviousFrameSavedMousePosForSplineOverlap = SavedMousePosForOnPaintEventLocalSpace;
|
|
|
|
// Handle mouse enter/leaves on the associated pin
|
|
if (OldPinWidget != NewPinWidget)
|
|
{
|
|
if (OldPinWidget.IsValid())
|
|
{
|
|
OldPinWidget->OnMouseLeave(LastPointerEvent);
|
|
}
|
|
|
|
if (NewPinWidget.IsValid())
|
|
{
|
|
NewPinWidget->OnMouseEnter(LastPointerGeometry, LastPointerEvent);
|
|
|
|
// Get the pin/wire glowing quicker, since it's a direct selection (this time was already set to 'now' as part of entering the pin)
|
|
//@TODO: Source this parameter from the graph rendering settings once it is there (see code in ApplyHoverDeemphasis)
|
|
TimeWhenMouseEnteredPin -= 0.75f;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool SGraphPanel::SupportsKeyboardFocus() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
void SGraphPanel::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const
|
|
{
|
|
SNodePanel::OnArrangeChildren(AllottedGeometry, ArrangedChildren);
|
|
|
|
FArrangedChildren MyArrangedChildren(ArrangedChildren.GetFilter());
|
|
for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex)
|
|
{
|
|
FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex];
|
|
TSharedRef<SGraphNode> ChildNode = StaticCastSharedRef<SGraphNode>(CurWidget.Widget);
|
|
|
|
TArray<FOverlayWidgetInfo> OverlayWidgets = ChildNode->GetOverlayWidgets(false, CurWidget.Geometry.Size);
|
|
|
|
for (int32 WidgetIndex = 0; WidgetIndex < OverlayWidgets.Num(); ++WidgetIndex)
|
|
{
|
|
FOverlayWidgetInfo& OverlayInfo = OverlayWidgets[WidgetIndex];
|
|
|
|
MyArrangedChildren.AddWidget(AllottedGeometry.MakeChild( OverlayInfo.Widget.ToSharedRef(), CurWidget.Geometry.Position + OverlayInfo.OverlayOffset, OverlayInfo.Widget->GetDesiredSize(), GetZoomAmount() ));
|
|
}
|
|
}
|
|
|
|
ArrangedChildren.Append(MyArrangedChildren);
|
|
}
|
|
|
|
TSharedPtr<IToolTip> SGraphPanel::GetToolTip()
|
|
{
|
|
if (SGraphPin* BestPinFromHoveredSpline = GetBestPinFromHoveredSpline())
|
|
{
|
|
return BestPinFromHoveredSpline->GetToolTip();
|
|
}
|
|
|
|
return SNodePanel::GetToolTip();
|
|
}
|
|
|
|
void SGraphPanel::UpdateSelectedNodesPositions(FVector2D PositionIncrement)
|
|
{
|
|
for (FGraphPanelSelectionSet::TIterator NodeIt(SelectionManager.SelectedNodes); NodeIt; ++NodeIt)
|
|
{
|
|
TSharedRef<SNode>* pWidget = NodeToWidgetLookup.Find(*NodeIt);
|
|
if (pWidget != nullptr)
|
|
{
|
|
SNode& Widget = pWidget->Get();
|
|
SNode::FNodeSet NodeFilter;
|
|
Widget.MoveTo(Widget.GetPosition() + PositionIncrement, NodeFilter);
|
|
}
|
|
}
|
|
}
|
|
|
|
FReply SGraphPanel::OnKeyDown( const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent )
|
|
{
|
|
if( IsEditable.Get() )
|
|
{
|
|
const bool bIsModifierActive = InKeyEvent.IsCommandDown() || InKeyEvent.IsAltDown() || InKeyEvent.IsShiftDown() || InKeyEvent.IsControlDown();
|
|
if (!bIsModifierActive)
|
|
{
|
|
if( InKeyEvent.GetKey() == EKeys::Up ||InKeyEvent.GetKey() == EKeys::NumPadEight )
|
|
{
|
|
UpdateSelectedNodesPositions(FVector2D(0.0f,-GetSnapGridSize()));
|
|
return FReply::Handled();
|
|
}
|
|
if( InKeyEvent.GetKey() == EKeys::Down || InKeyEvent.GetKey() == EKeys::NumPadTwo )
|
|
{
|
|
UpdateSelectedNodesPositions(FVector2D(0.0f,GetSnapGridSize()));
|
|
return FReply::Handled();
|
|
}
|
|
if( InKeyEvent.GetKey() == EKeys::Right || InKeyEvent.GetKey() == EKeys::NumPadSix )
|
|
{
|
|
UpdateSelectedNodesPositions(FVector2D(GetSnapGridSize(),0.0f));
|
|
return FReply::Handled();
|
|
}
|
|
if( InKeyEvent.GetKey() == EKeys::Left || InKeyEvent.GetKey() == EKeys::NumPadFour )
|
|
{
|
|
UpdateSelectedNodesPositions(FVector2D(-GetSnapGridSize(),0.0f));
|
|
return FReply::Handled();
|
|
}
|
|
}
|
|
|
|
if(InKeyEvent.GetKey() == FGraphEditorCommands::Get().ZoomOut->GetActiveChord()->Key)
|
|
{
|
|
ChangeZoomLevel(-1, CachedAllottedGeometryScaledSize / 2.f, InKeyEvent.IsControlDown());
|
|
return FReply::Handled();
|
|
}
|
|
if(InKeyEvent.GetKey() == FGraphEditorCommands::Get().ZoomIn->GetActiveChord()->Key)
|
|
{
|
|
ChangeZoomLevel(+1, CachedAllottedGeometryScaledSize / 2.f, InKeyEvent.IsControlDown());
|
|
return FReply::Handled();
|
|
}
|
|
}
|
|
|
|
return SNodePanel::OnKeyDown(MyGeometry, InKeyEvent);
|
|
}
|
|
|
|
FReply SGraphPanel::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
if ((MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton) && (MouseEvent.IsAltDown() || MouseEvent.IsControlDown()))
|
|
{
|
|
if (SGraphPin* BestPinFromHoveredSpline = GetBestPinFromHoveredSpline())
|
|
{
|
|
return BestPinFromHoveredSpline->OnPinMouseDown(MyGeometry, MouseEvent);
|
|
}
|
|
}
|
|
|
|
return SNodePanel::OnMouseButtonDown(MyGeometry, MouseEvent);
|
|
}
|
|
|
|
FReply SGraphPanel::OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
if ((MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton) && (MouseEvent.IsShiftDown()))
|
|
{
|
|
if (SGraphPin* BestPinFromHoveredSpline = GetBestPinFromHoveredSpline())
|
|
{
|
|
return BestPinFromHoveredSpline->OnMouseButtonUp(MyGeometry, MouseEvent);
|
|
}
|
|
}
|
|
|
|
return SNodePanel::OnMouseButtonUp(MyGeometry, MouseEvent);
|
|
}
|
|
|
|
FReply SGraphPanel::OnMouseButtonDoubleClick(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
UEdGraphPin* Pin1;
|
|
UEdGraphPin* Pin2;
|
|
if (PreviousFrameSplineOverlap.GetPins(*this, /*out*/ Pin1, /*out*/ Pin2))
|
|
{
|
|
// Give the schema a chance to do something interesting with a double click on a proper spline (both ends are attached to a pin, i.e., not a preview/drag one)
|
|
const FVector2D DoubleClickPositionInGraphSpace = PanelCoordToGraphCoord(MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition()));
|
|
|
|
const UEdGraphSchema* Schema = GraphObj->GetSchema();
|
|
Schema->OnPinConnectionDoubleCicked(Pin1, Pin2, DoubleClickPositionInGraphSpace);
|
|
}
|
|
|
|
return SNodePanel::OnMouseButtonDoubleClick(MyGeometry, MouseEvent);
|
|
}
|
|
|
|
class SGraphPin* SGraphPanel::GetBestPinFromHoveredSpline() const
|
|
{
|
|
TSharedPtr<SGraphPin> BestPinWidget = PreviousFrameSplineOverlap.GetBestPinWidget(*this);
|
|
return BestPinWidget.Get();
|
|
}
|
|
|
|
void SGraphPanel::GetAllPins(TSet< TSharedRef<SWidget> >& AllPins)
|
|
{
|
|
// Get the set of pins for all children
|
|
for (int32 ChildIndex = 0; ChildIndex < Children.Num(); ++ChildIndex)
|
|
{
|
|
TSharedRef<SGraphNode> ChildNode = StaticCastSharedRef<SGraphNode>(Children[ChildIndex]);
|
|
ChildNode->GetPins(AllPins);
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::AddPinToHoverSet(UEdGraphPin* HoveredPin)
|
|
{
|
|
CurrentHoveredPins.Add(HoveredPin);
|
|
TimeWhenMouseEnteredPin = FSlateApplication::Get().GetCurrentTime();
|
|
|
|
// About covers the fade in time when highlighting pins or splines.
|
|
TimeLeftToInvalidatePerTick += 1.5f;
|
|
|
|
// This handle should always be for this function
|
|
if (!ActiveTimerHandleInvalidatePerTick.IsValid())
|
|
{
|
|
ActiveTimerHandleInvalidatePerTick = RegisterActiveTimer(0.f, FWidgetActiveTimerDelegate::CreateSP(this, &SGraphPanel::InvalidatePerTick));
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::RemovePinFromHoverSet(UEdGraphPin* UnhoveredPin)
|
|
{
|
|
CurrentHoveredPins.Remove(UnhoveredPin);
|
|
TimeWhenMouseLeftPin = FSlateApplication::Get().GetCurrentTime();
|
|
}
|
|
|
|
void SGraphPanel::ArrangeChildrenForContextMenuSummon(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const
|
|
{
|
|
// First pass nodes
|
|
for (int32 ChildIndex = 0; ChildIndex < VisibleChildren.Num(); ++ChildIndex)
|
|
{
|
|
const TSharedRef<SNode>& SomeChild = VisibleChildren[ChildIndex];
|
|
if (!SomeChild->RequiresSecondPassLayout())
|
|
{
|
|
ArrangedChildren.AddWidget(AllottedGeometry.MakeChild(SomeChild, SomeChild->GetPosition() - ViewOffset, SomeChild->GetDesiredSizeForMarquee(), GetZoomAmount()));
|
|
}
|
|
}
|
|
|
|
// Second pass nodes
|
|
for (int32 ChildIndex = 0; ChildIndex < VisibleChildren.Num(); ++ChildIndex)
|
|
{
|
|
const TSharedRef<SNode>& SomeChild = VisibleChildren[ChildIndex];
|
|
if (SomeChild->RequiresSecondPassLayout())
|
|
{
|
|
SomeChild->PerformSecondPassLayout(NodeToWidgetLookup);
|
|
ArrangedChildren.AddWidget(AllottedGeometry.MakeChild(SomeChild, SomeChild->GetPosition() - ViewOffset, SomeChild->GetDesiredSizeForMarquee(), GetZoomAmount()));
|
|
}
|
|
}
|
|
}
|
|
|
|
TSharedPtr<SWidget> SGraphPanel::OnSummonContextMenu(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
//Editability is up to the user to consider for menu options
|
|
{
|
|
// If we didn't drag very far, summon a context menu.
|
|
// Figure out what's under the mouse: Node, Pin or just the Panel, and summon the context menu for that.
|
|
UEdGraphNode* NodeUnderCursor = nullptr;
|
|
UEdGraphPin* PinUnderCursor = nullptr;
|
|
{
|
|
FArrangedChildren ArrangedNodes(EVisibility::Visible);
|
|
this->ArrangeChildrenForContextMenuSummon(MyGeometry, ArrangedNodes);
|
|
const int32 HoveredNodeIndex = SWidget::FindChildUnderMouse( ArrangedNodes, MouseEvent );
|
|
if (HoveredNodeIndex != INDEX_NONE)
|
|
{
|
|
const FArrangedWidget& HoveredNode = ArrangedNodes[HoveredNodeIndex];
|
|
TSharedRef<SGraphNode> GraphNode = StaticCastSharedRef<SGraphNode>(HoveredNode.Widget);
|
|
TSharedPtr<SGraphNode> GraphSubNode = GraphNode->GetNodeUnderMouse(HoveredNode.Geometry, MouseEvent);
|
|
GraphNode = GraphSubNode.IsValid() ? GraphSubNode.ToSharedRef() : GraphNode;
|
|
NodeUnderCursor = GraphNode->GetNodeObj();
|
|
|
|
// Selection should switch to this code if it isn't already selected.
|
|
// When multiple nodes are selected, we do nothing, provided that the
|
|
// node for which the context menu is being created is in the selection set.
|
|
if (!SelectionManager.IsNodeSelected(GraphNode->GetObjectBeingDisplayed()))
|
|
{
|
|
SelectionManager.SelectSingleNode(GraphNode->GetObjectBeingDisplayed());
|
|
}
|
|
|
|
const TSharedPtr<SGraphPin> HoveredPin = GraphNode->GetHoveredPin( HoveredNode.Geometry, MouseEvent );
|
|
if (HoveredPin.IsValid())
|
|
{
|
|
PinUnderCursor = HoveredPin->GetPinObj();
|
|
}
|
|
}
|
|
}
|
|
|
|
const FVector2D NodeAddPosition = PanelCoordToGraphCoord( MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition()) );
|
|
TArray<UEdGraphPin*> NoSourcePins;
|
|
|
|
return SummonContextMenu(MouseEvent.GetScreenSpacePosition(), NodeAddPosition, NodeUnderCursor, PinUnderCursor, NoSourcePins, MouseEvent.IsShiftDown());
|
|
}
|
|
|
|
return TSharedPtr<SWidget>();
|
|
}
|
|
|
|
|
|
bool SGraphPanel::OnHandleLeftMouseRelease(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
TSharedPtr<SGraphPin> PreviewConnectionPin = PreviewConnectorFromPins.Num() > 0 ? PreviewConnectorFromPins[0].FindInGraphPanel(*this) : nullptr;
|
|
if (PreviewConnectionPin.IsValid() && IsEditable.Get())
|
|
{
|
|
TSet< TSharedRef<SWidget> > AllConnectors;
|
|
for (int32 ChildIndex = 0; ChildIndex < Children.Num(); ++ChildIndex)
|
|
{
|
|
//@FINDME:
|
|
TSharedRef<SGraphNode> ChildNode = StaticCastSharedRef<SGraphNode>(Children[ChildIndex]);
|
|
ChildNode->GetPins(AllConnectors);
|
|
}
|
|
|
|
TMap<TSharedRef<SWidget>, FArrangedWidget> PinGeometries;
|
|
this->FindChildGeometries(MyGeometry, AllConnectors, PinGeometries);
|
|
|
|
bool bHandledDrop = false;
|
|
TSet<UEdGraphNode*> NodeList;
|
|
for ( TMap<TSharedRef<SWidget>, FArrangedWidget>::TIterator SomePinIt(PinGeometries); !bHandledDrop && SomePinIt; ++SomePinIt )
|
|
{
|
|
FArrangedWidget& PinWidgetGeometry = SomePinIt.Value();
|
|
if( PinWidgetGeometry.Geometry.IsUnderLocation( MouseEvent.GetScreenSpacePosition() ) )
|
|
{
|
|
SGraphPin& TargetPin = static_cast<SGraphPin&>( PinWidgetGeometry.Widget.Get() );
|
|
|
|
if (PreviewConnectionPin->TryHandlePinConnection(TargetPin))
|
|
{
|
|
NodeList.Add(TargetPin.GetPinObj()->GetOwningNode());
|
|
NodeList.Add(PreviewConnectionPin->GetPinObj()->GetOwningNode());
|
|
}
|
|
bHandledDrop = true;
|
|
}
|
|
}
|
|
|
|
// No longer make a connection for a pin; we just connected or failed to connect.
|
|
OnStopMakingConnection(/*bForceStop=*/ true);
|
|
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
FReply SGraphPanel::OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
LastPointerEvent = MouseEvent;
|
|
LastPointerGeometry = MyGeometry;
|
|
|
|
// Save the mouse position to use in OnPaint for spline hit detection
|
|
SavedMousePosForOnPaintEventLocalSpace = MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition());
|
|
|
|
// Invalidate the spline results if we moved very far
|
|
const FVector2D MouseDelta = SavedMousePosForOnPaintEventLocalSpace - PreviousFrameSavedMousePosForSplineOverlap;
|
|
const float MouseDeltaLengthSquared = MouseDelta.SizeSquared();
|
|
const bool bCursorInDeadZone = MouseDeltaLengthSquared <= FMath::Square(FSlateApplication::Get().GetDragTriggerDistance());
|
|
|
|
if (!bCursorInDeadZone)
|
|
{
|
|
//@TODO: Should we do this or just rely on the next OnPaint?
|
|
// Our frame-latent approximation is going to be totally junk if the mouse is moving quickly
|
|
OnSplineHoverStateChanged(FGraphSplineOverlapResult());
|
|
}
|
|
|
|
return SNodePanel::OnMouseMove(MyGeometry, MouseEvent);
|
|
}
|
|
|
|
void SGraphPanel::OnDragEnter( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
|
|
{
|
|
TSharedPtr<FGraphEditorDragDropAction> DragConnectionOp = DragDropEvent.GetOperationAs<FGraphEditorDragDropAction>();
|
|
if (DragConnectionOp.IsValid())
|
|
{
|
|
DragConnectionOp->SetHoveredGraph( SharedThis(this) );
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::OnDragLeave( const FDragDropEvent& DragDropEvent )
|
|
{
|
|
TSharedPtr<FGraphEditorDragDropAction> Operation = DragDropEvent.GetOperationAs<FGraphEditorDragDropAction>();
|
|
if( Operation.IsValid() )
|
|
{
|
|
Operation->SetHoveredGraph(TSharedPtr<SGraphPanel>(nullptr));
|
|
}
|
|
else
|
|
{
|
|
TSharedPtr<FDecoratedDragDropOp> AssetOp = DragDropEvent.GetOperationAs<FDecoratedDragDropOp>();
|
|
if( AssetOp.IsValid() )
|
|
{
|
|
AssetOp->ResetToDefaultToolTip();
|
|
}
|
|
}
|
|
}
|
|
|
|
FReply SGraphPanel::OnDragOver( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
|
|
{
|
|
TSharedPtr<FDragDropOperation> Operation = DragDropEvent.GetOperation();
|
|
if (!Operation.IsValid())
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
|
|
// Handle Read only graphs
|
|
if (!IsEditable.Get())
|
|
{
|
|
TSharedPtr<FGraphEditorDragDropAction> GraphDragDropOp = DragDropEvent.GetOperationAs<FGraphEditorDragDropAction>();
|
|
|
|
if (GraphDragDropOp.IsValid())
|
|
{
|
|
GraphDragDropOp->SetDropTargetValid(false);
|
|
}
|
|
else
|
|
{
|
|
TSharedPtr<FDecoratedDragDropOp> AssetOp = DragDropEvent.GetOperationAs<FDecoratedDragDropOp>();
|
|
if (AssetOp.IsValid())
|
|
{
|
|
FText Tooltip = AssetOp->GetHoverText();
|
|
if (Tooltip.IsEmpty())
|
|
{
|
|
Tooltip = NSLOCTEXT( "GraphPanel", "DragDropOperation", "Graph is Read-Only" );
|
|
}
|
|
AssetOp->SetToolTip(Tooltip, FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.Error")));
|
|
}
|
|
}
|
|
return FReply::Handled();
|
|
}
|
|
|
|
if (Operation->IsOfType<FGraphEditorDragDropAction>())
|
|
{
|
|
PreviewConnectorEndpoint = MyGeometry.AbsoluteToLocal( DragDropEvent.GetScreenSpacePosition() );
|
|
return FReply::Handled();
|
|
}
|
|
else if (Operation->IsOfType<FExternalDragOperation>())
|
|
{
|
|
return AssetUtil::CanHandleAssetDrag(DragDropEvent);
|
|
}
|
|
else if (Operation->IsOfType<FAssetDragDropOp>())
|
|
{
|
|
if ((GraphObj != nullptr) && (GraphObj->GetSchema() != nullptr))
|
|
{
|
|
TSharedPtr<FAssetDragDropOp> AssetOp = StaticCastSharedPtr<FAssetDragDropOp>(Operation);
|
|
bool bOkIcon = false;
|
|
FString TooltipText;
|
|
GraphObj->GetSchema()->GetAssetsGraphHoverMessage(AssetOp->AssetData, GraphObj, TooltipText, bOkIcon);
|
|
const FSlateBrush* TooltipIcon = bOkIcon ? FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.OK")) : FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.Error"));;
|
|
AssetOp->SetToolTip(FText::FromString(TooltipText), TooltipIcon);
|
|
}
|
|
return FReply::Handled();
|
|
}
|
|
else
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
}
|
|
|
|
FReply SGraphPanel::OnDrop( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
|
|
{
|
|
const FVector2D NodeAddPosition = PanelCoordToGraphCoord( MyGeometry.AbsoluteToLocal( DragDropEvent.GetScreenSpacePosition() ) );
|
|
|
|
FSlateApplication::Get().SetKeyboardFocus(AsShared(), EFocusCause::SetDirectly);
|
|
|
|
TSharedPtr<FDragDropOperation> Operation = DragDropEvent.GetOperation();
|
|
if (!Operation.IsValid() || !IsEditable.Get())
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
|
|
if (Operation->IsOfType<FGraphEditorDragDropAction>())
|
|
{
|
|
check(GraphObj);
|
|
TSharedPtr<FGraphEditorDragDropAction> DragConn = StaticCastSharedPtr<FGraphEditorDragDropAction>(Operation);
|
|
if (DragConn.IsValid() && DragConn->IsSupportedBySchema(GraphObj->GetSchema()))
|
|
{
|
|
return DragConn->DroppedOnPanel(SharedThis(this), DragDropEvent.GetScreenSpacePosition(), NodeAddPosition, *GraphObj);
|
|
}
|
|
|
|
return FReply::Unhandled();
|
|
}
|
|
else if (Operation->IsOfType<FActorDragDropGraphEdOp>())
|
|
{
|
|
TSharedPtr<FActorDragDropGraphEdOp> ActorOp = StaticCastSharedPtr<FActorDragDropGraphEdOp>(Operation);
|
|
OnDropActor.ExecuteIfBound(ActorOp->Actors, GraphObj, NodeAddPosition);
|
|
return FReply::Handled();
|
|
}
|
|
|
|
else if (Operation->IsOfType<FLevelDragDropOp>())
|
|
{
|
|
TSharedPtr<FLevelDragDropOp> LevelOp = StaticCastSharedPtr<FLevelDragDropOp>(Operation);
|
|
OnDropStreamingLevel.ExecuteIfBound(LevelOp->StreamingLevelsToDrop, GraphObj, NodeAddPosition);
|
|
return FReply::Handled();
|
|
}
|
|
else
|
|
{
|
|
if ((GraphObj != nullptr) && (GraphObj->GetSchema() != nullptr))
|
|
{
|
|
TArray< FAssetData > DroppedAssetData = AssetUtil::ExtractAssetDataFromDrag( DragDropEvent );
|
|
|
|
if ( DroppedAssetData.Num() > 0 )
|
|
{
|
|
GraphObj->GetSchema()->DroppedAssetsOnGraph( DroppedAssetData, NodeAddPosition, GraphObj );
|
|
return FReply::Handled();
|
|
}
|
|
}
|
|
|
|
return FReply::Unhandled();
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::OnBeginMakingConnection(UEdGraphPin* InOriginatingPin)
|
|
{
|
|
if (InOriginatingPin != nullptr)
|
|
{
|
|
PreviewConnectorFromPins.Add(InOriginatingPin);
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::OnStopMakingConnection(bool bForceStop)
|
|
{
|
|
if (bForceStop || !bPreservePinPreviewConnection)
|
|
{
|
|
PreviewConnectorFromPins.Reset();
|
|
bPreservePinPreviewConnection = false;
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::PreservePinPreviewUntilForced()
|
|
{
|
|
bPreservePinPreviewConnection = true;
|
|
}
|
|
|
|
/** Add a slot to the CanvasPanel dynamically */
|
|
void SGraphPanel::AddGraphNode( const TSharedRef<SNodePanel::SNode>& NodeToAdd )
|
|
{
|
|
TSharedRef<SGraphNode> GraphNode = StaticCastSharedRef<SGraphNode>(NodeToAdd);
|
|
GraphNode->SetOwner( SharedThis(this) );
|
|
|
|
const UEdGraphNode* Node = GraphNode->GetNodeObj();
|
|
if (Node)
|
|
{
|
|
NodeGuidMap.Add(Node->NodeGuid, GraphNode);
|
|
}
|
|
|
|
SNodePanel::AddGraphNode(NodeToAdd);
|
|
}
|
|
|
|
void SGraphPanel::RemoveAllNodes()
|
|
{
|
|
NodeGuidMap.Empty();
|
|
CurrentHoveredPins.Empty();
|
|
SNodePanel::RemoveAllNodes();
|
|
}
|
|
|
|
TSharedPtr<SWidget> SGraphPanel::SummonContextMenu(const FVector2D& WhereToSummon, const FVector2D& WhereToAddNode, UEdGraphNode* ForNode, UEdGraphPin* ForPin, const TArray<UEdGraphPin*>& DragFromPins, bool bShiftOperation)
|
|
{
|
|
if (OnGetContextMenuFor.IsBound())
|
|
{
|
|
FGraphContextMenuArguments SpawnInfo;
|
|
SpawnInfo.NodeAddPosition = WhereToAddNode;
|
|
SpawnInfo.GraphNode = ForNode;
|
|
SpawnInfo.GraphPin = ForPin;
|
|
SpawnInfo.DragFromPins = DragFromPins;
|
|
SpawnInfo.bShiftOperation = bShiftOperation;
|
|
|
|
FActionMenuContent FocusedContent = OnGetContextMenuFor.Execute(SpawnInfo);
|
|
|
|
TSharedRef<SWidget> MenuContent = FocusedContent.Content;
|
|
|
|
FSlateApplication::Get().PushMenu(
|
|
AsShared(),
|
|
FWidgetPath(),
|
|
MenuContent,
|
|
WhereToSummon,
|
|
FPopupTransitionEffect( FPopupTransitionEffect::ContextMenu )
|
|
);
|
|
|
|
return FocusedContent.WidgetToFocus;
|
|
}
|
|
|
|
return TSharedPtr<SWidget>();
|
|
}
|
|
|
|
void SGraphPanel::AttachGraphEvents(TSharedPtr<SGraphNode> CreatedSubNode)
|
|
{
|
|
check(CreatedSubNode.IsValid());
|
|
CreatedSubNode->SetIsEditable(IsEditable);
|
|
CreatedSubNode->SetDoubleClickEvent(OnNodeDoubleClicked);
|
|
CreatedSubNode->SetVerifyTextCommitEvent(OnVerifyTextCommit);
|
|
CreatedSubNode->SetTextCommittedEvent(OnTextCommitted);
|
|
}
|
|
|
|
bool SGraphPanel::GetBoundsForNode(const UObject* InNode, FVector2D& MinCorner, FVector2D& MaxCorner, float Padding) const
|
|
{
|
|
return SNodePanel::GetBoundsForNode(InNode, MinCorner, MaxCorner, Padding);
|
|
}
|
|
|
|
class FConnectionAligner
|
|
{
|
|
public:
|
|
void DefineConnection(UEdGraphNode* SourceNode, const TSharedPtr<SGraphPin>& SourcePin, UEdGraphNode* DestinationNode, const TSharedPtr<SGraphPin>& DestinationPin)
|
|
{
|
|
auto& Dependencies = Connections.FindOrAdd(SourceNode);
|
|
if (SourcePin->GetPinObj()->Direction == EEdGraphPinDirection::EGPD_Output)
|
|
{
|
|
Dependencies.Outputs.FindOrAdd(DestinationNode).Add(FPinPair{ SourcePin, DestinationPin });
|
|
}
|
|
else
|
|
{
|
|
Dependencies.Inputs.FindOrAdd(DestinationNode).Add(FPinPair{ SourcePin, DestinationPin });
|
|
}
|
|
}
|
|
|
|
/** Align all the connections */
|
|
void Process()
|
|
{
|
|
struct FRankedNode
|
|
{
|
|
UEdGraphNode* Node;
|
|
uint32 Rank;
|
|
};
|
|
|
|
TArray<FRankedNode> RankedNodes;
|
|
RankedNodes.Reserve(Connections.Num());
|
|
|
|
TMap<UEdGraphNode*, uint32> LongestChainCache;
|
|
LongestChainCache.Reserve(Connections.Num());
|
|
|
|
for (auto& Pair : Connections)
|
|
{
|
|
RankedNodes.Add(FRankedNode{ Pair.Key, CalculateNodeRank(Pair.Key, LongestChainCache) });
|
|
}
|
|
|
|
// Sort the nodes based on dependencies - highest is processed first
|
|
RankedNodes.Sort([](const FRankedNode& A, const FRankedNode& B){
|
|
return A.Rank > B.Rank;
|
|
});
|
|
|
|
TSet<UEdGraphNode*> VistedNodes;
|
|
for (FRankedNode& RankedNode : RankedNodes)
|
|
{
|
|
StraightenConnectionsForNode(RankedNode.Node, VistedNodes, EEdGraphPinDirection::EGPD_Output);
|
|
if (VistedNodes.Num() == RankedNodes.Num())
|
|
{
|
|
return;
|
|
}
|
|
|
|
StraightenConnectionsForNode(RankedNode.Node, VistedNodes, EEdGraphPinDirection::EGPD_Input);
|
|
if (VistedNodes.Num() == RankedNodes.Num())
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
private:
|
|
|
|
void StraightenConnectionsForNode(UEdGraphNode* Node, TSet<UEdGraphNode*>& VisitedNodes, EEdGraphPinDirection Direction)
|
|
{
|
|
FDependencyInfo* Info = Connections.Find(Node);
|
|
if (!Info)
|
|
{
|
|
return;
|
|
}
|
|
|
|
for (auto& NodeToPins : Info->GetDirection(Direction))
|
|
{
|
|
if (NodeToPins.Value.Num() == 0 || VisitedNodes.Contains(NodeToPins.Key))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// Align the averages of all the pins
|
|
float AlignmentDelta = 0.f;
|
|
for (const FPinPair& Pins : NodeToPins.Value)
|
|
{
|
|
AlignmentDelta += (Node->NodePosY + Pins.SrcPin->GetNodeOffset().Y) - (NodeToPins.Key->NodePosY + Pins.DstPin->GetNodeOffset().Y);
|
|
}
|
|
|
|
NodeToPins.Key->Modify();
|
|
NodeToPins.Key->NodePosY += AlignmentDelta / NodeToPins.Value.Num();
|
|
|
|
VisitedNodes.Add(Node);
|
|
VisitedNodes.Add(NodeToPins.Key);
|
|
|
|
StraightenConnectionsForNode(NodeToPins.Key, VisitedNodes, Direction);
|
|
}
|
|
}
|
|
|
|
/** Find the longest chain of single-connection nodes connected to the specified node */
|
|
uint32 FindLongestUniqueChain(UEdGraphNode* Node, TMap<UEdGraphNode*, uint32>& LongestChainCache, EEdGraphPinDirection Direction)
|
|
{
|
|
if (uint32* Length = LongestChainCache.Find(Node))
|
|
{
|
|
// Already set, or circular dependency - ignore
|
|
return *Length;
|
|
}
|
|
|
|
// Prevent reentrancy
|
|
LongestChainCache.Add(Node, 0);
|
|
|
|
uint32 ThisLength = 0;
|
|
|
|
if (FDependencyInfo* Dependencies = Connections.Find(Node))
|
|
{
|
|
auto& ConnectedNodes = Dependencies->GetDirection(Direction);
|
|
|
|
// We only follow unique (1-1) connections
|
|
if (ConnectedNodes.Num() == 1)
|
|
{
|
|
for (auto& NodeToPins : ConnectedNodes)
|
|
{
|
|
ThisLength = FindLongestUniqueChain(NodeToPins.Key, LongestChainCache, Direction) + 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
LongestChainCache[Node] = ThisLength;
|
|
return ThisLength;
|
|
};
|
|
|
|
/** Calculate the depth of dependencies for the specified node */
|
|
uint32 CalculateNodeRank(UEdGraphNode* Node, TMap<UEdGraphNode*, uint32>& LongestChainCache)
|
|
{
|
|
uint32 Rank = 0;
|
|
if (FDependencyInfo* PinMap = Connections.Find(Node))
|
|
{
|
|
for (auto& NodeToPins : PinMap->Outputs)
|
|
{
|
|
Rank += FindLongestUniqueChain(NodeToPins.Key, LongestChainCache, EEdGraphPinDirection::EGPD_Output) + 1;
|
|
}
|
|
for (auto& NodeToPins : PinMap->Inputs)
|
|
{
|
|
Rank += FindLongestUniqueChain(NodeToPins.Key, LongestChainCache, EEdGraphPinDirection::EGPD_Input) + 1;
|
|
}
|
|
}
|
|
return Rank;
|
|
}
|
|
|
|
private:
|
|
|
|
/** A pair of pins */
|
|
struct FPinPair
|
|
{
|
|
TSharedPtr<SGraphPin> SrcPin, DstPin;
|
|
};
|
|
|
|
/** Map of nodes and pins that are connected to the owning pin */
|
|
struct FDependencyInfo
|
|
{
|
|
TMap<UEdGraphNode*, TArray<FPinPair>> Outputs;
|
|
TMap<UEdGraphNode*, TArray<FPinPair>> Inputs;
|
|
uint32 Rank;
|
|
|
|
TMap<UEdGraphNode*, TArray<FPinPair>>& GetDirection(EEdGraphPinDirection Direction)
|
|
{
|
|
return Direction == EEdGraphPinDirection::EGPD_Output ? Outputs : Inputs;
|
|
}
|
|
};
|
|
typedef TMap<UEdGraphNode*, FDependencyInfo> FConnections;
|
|
|
|
FConnections Connections;
|
|
};
|
|
|
|
void SGraphPanel::StraightenConnections()
|
|
{
|
|
FConnectionAligner Aligner;
|
|
for (auto* It : SelectionManager.SelectedNodes)
|
|
{
|
|
UEdGraphNode* SourceNode = Cast<UEdGraphNode>(It);
|
|
if (!SourceNode)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
TSharedRef<SNode>* ThisNodePtr = NodeToWidgetLookup.Find(SourceNode);
|
|
if (!ThisNodePtr)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
for (UEdGraphPin* SourcePin : SourceNode->Pins)
|
|
{
|
|
for (UEdGraphPin* LinkedTo : SourcePin->LinkedTo)
|
|
{
|
|
UEdGraphNode* DestNode = LinkedTo ? LinkedTo->GetOwningNode() : nullptr;
|
|
if (DestNode && SelectionManager.SelectedNodes.Contains(DestNode))
|
|
{
|
|
TSharedRef<SNode>* DestGraphNodePtr = NodeToWidgetLookup.Find(DestNode);
|
|
if (!DestGraphNodePtr)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
TSharedPtr<SGraphPin> PinWidget = StaticCastSharedRef<SGraphNode>(*ThisNodePtr)->FindWidgetForPin(SourcePin);
|
|
TSharedPtr<SGraphPin> LinkedPinWidget = StaticCastSharedRef<SGraphNode>(*DestGraphNodePtr)->FindWidgetForPin(LinkedTo);
|
|
|
|
if (PinWidget.IsValid() && LinkedPinWidget.IsValid())
|
|
{
|
|
Aligner.DefineConnection(SourceNode, PinWidget, DestNode, LinkedPinWidget);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Aligner.Process();
|
|
}
|
|
|
|
void SGraphPanel::StraightenConnections(UEdGraphPin* SourcePin, UEdGraphPin* PinToAlign)
|
|
{
|
|
UEdGraphNode* OwningNode = SourcePin->GetOwningNode();
|
|
|
|
TSharedRef<SNode>* OwningNodeWidgetPtr = NodeToWidgetLookup.Find(OwningNode);
|
|
if (!OwningNodeWidgetPtr)
|
|
{
|
|
return;
|
|
}
|
|
|
|
TSharedRef<SGraphNode> SourceGraphNode = StaticCastSharedRef<SGraphNode>(*OwningNodeWidgetPtr);
|
|
|
|
FConnectionAligner Aligner;
|
|
|
|
auto AddConnectedPin = [&](UEdGraphPin* ConnectedPin){
|
|
UEdGraphNode* ConnectedNode = ConnectedPin ? ConnectedPin->GetOwningNode() : nullptr;
|
|
if (!ConnectedNode)
|
|
{
|
|
return;
|
|
}
|
|
|
|
TSharedRef<SNode>* DestGraphNodePtr = NodeToWidgetLookup.Find(ConnectedNode);
|
|
if (!DestGraphNodePtr)
|
|
{
|
|
return;
|
|
}
|
|
|
|
TSharedPtr<SGraphPin> PinWidget = SourceGraphNode->FindWidgetForPin(SourcePin);
|
|
TSharedPtr<SGraphPin> LinkedPinWidget = StaticCastSharedRef<SGraphNode>(*DestGraphNodePtr)->FindWidgetForPin(ConnectedPin);
|
|
|
|
if (PinWidget.IsValid() && LinkedPinWidget.IsValid())
|
|
{
|
|
Aligner.DefineConnection(OwningNode, PinWidget, ConnectedNode, LinkedPinWidget);
|
|
}
|
|
};
|
|
|
|
if (PinToAlign)
|
|
{
|
|
// If we're only aligning a specific pin, do that
|
|
AddConnectedPin(PinToAlign);
|
|
}
|
|
// Else add all the connected pins
|
|
else for (UEdGraphPin* ConnectedPin : SourcePin->LinkedTo)
|
|
{
|
|
AddConnectedPin(ConnectedPin);
|
|
}
|
|
|
|
Aligner.Process();
|
|
}
|
|
|
|
const TSharedRef<SGraphNode> SGraphPanel::GetChild(int32 ChildIndex)
|
|
{
|
|
return StaticCastSharedRef<SGraphNode>(Children[ChildIndex]);
|
|
}
|
|
|
|
void SGraphPanel::AddNode(UEdGraphNode* Node, AddNodeBehavior Behavior)
|
|
{
|
|
TSharedPtr<SGraphNode> NewNode = FNodeFactory::CreateNodeWidget(Node);
|
|
check(NewNode.IsValid());
|
|
|
|
const bool bWasUserAdded =
|
|
Behavior == WasUserAdded ? true :
|
|
Behavior == NotUserAdded ? false :
|
|
(UserAddedNodes.Find(Node) != nullptr);
|
|
|
|
NewNode->SetIsEditable(IsEditable);
|
|
NewNode->SetDoubleClickEvent(OnNodeDoubleClicked);
|
|
NewNode->SetVerifyTextCommitEvent(OnVerifyTextCommit);
|
|
NewNode->SetTextCommittedEvent(OnTextCommitted);
|
|
NewNode->SetDisallowedPinConnectionEvent(OnDisallowedPinConnection);
|
|
|
|
this->AddGraphNode
|
|
(
|
|
NewNode.ToSharedRef()
|
|
);
|
|
|
|
if (bWasUserAdded)
|
|
{
|
|
// Add the node to visible children, this allows focus to occur on sub-widgets for naming purposes.
|
|
VisibleChildren.Add(NewNode.ToSharedRef());
|
|
|
|
NewNode->PlaySpawnEffect();
|
|
NewNode->RequestRenameOnSpawn();
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::RemoveNode(const UEdGraphNode* Node)
|
|
{
|
|
for (int32 Iter = 0; Iter != Children.Num(); ++Iter)
|
|
{
|
|
TSharedRef<SGraphNode> Child = GetChild(Iter);
|
|
if (Child->GetNodeObj() == Node)
|
|
{
|
|
Children.RemoveAt(Iter);
|
|
break;
|
|
}
|
|
}
|
|
for (int32 Iter = 0; Iter != VisibleChildren.Num(); ++Iter)
|
|
{
|
|
TSharedRef<SGraphNode> Child = StaticCastSharedRef<SGraphNode>(VisibleChildren[Iter]);
|
|
if (Child->GetNodeObj() == Node)
|
|
{
|
|
VisibleChildren.RemoveAt(Iter);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
TSharedPtr<SGraphNode> SGraphPanel::GetNodeWidgetFromGuid(FGuid Guid) const
|
|
{
|
|
return NodeGuidMap.FindRef(Guid).Pin();
|
|
}
|
|
|
|
void SGraphPanel::Update()
|
|
{
|
|
static bool bIsUpdating = false;
|
|
if (bIsUpdating)
|
|
{
|
|
return;
|
|
}
|
|
TGuardValue<bool> ReentrancyGuard(bIsUpdating, true);
|
|
|
|
// Add widgets for all the nodes that don't have one.
|
|
if (GraphObj != nullptr)
|
|
{
|
|
// Scan for all missing nodes
|
|
for (int32 NodeIndex = 0; NodeIndex < GraphObj->Nodes.Num(); ++NodeIndex)
|
|
{
|
|
UEdGraphNode* Node = GraphObj->Nodes[NodeIndex];
|
|
if (Node)
|
|
{
|
|
// Helps detect cases of UE-26998 without causing a crash. Prevents the node from being rendered altogether and provides info on the state of the graph vs the node.
|
|
// Because the editor won't crash, a GLEO can be expected if the node's outer is in the transient package.
|
|
if (ensureMsgf(Node->GetOuter() == GraphObj, TEXT("Found %s ('%s') that does not belong to %s. Node Outer: %s, Node Outer Type: %s, Graph Outer: %s, Graph Outer Type: %s"),
|
|
*Node->GetName(), *Node->GetClass()->GetName(),
|
|
*GraphObj->GetName(),
|
|
*Node->GetOuter()->GetName(), *Node->GetOuter()->GetClass()->GetName(),
|
|
*GraphObj->GetOuter()->GetName(), *GraphObj->GetOuter()->GetClass()->GetName()
|
|
))
|
|
{
|
|
AddNode(Node, CheckUserAddedNodesList);
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogGraphPanel, Error, TEXT("Found %s ('%s') that does not belong to %s. Node Outer: %s, Node Outer Type: %s, Graph Outer: %s, Graph Outer Type: %s"),
|
|
*Node->GetName(), *Node->GetClass()->GetName(),
|
|
*GraphObj->GetName(),
|
|
*Node->GetOuter()->GetName(), *Node->GetOuter()->GetClass()->GetName(),
|
|
*GraphObj->GetOuter()->GetName(), *GraphObj->GetOuter()->GetClass()->GetName()
|
|
);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogGraphPanel, Warning, TEXT("Found NULL Node in GraphObj array of a graph in asset '%s'. A node type has been deleted without creating an ActiveClassRedirector to K2Node_DeadClass."), *GraphObj->GetOutermost()->GetName());
|
|
}
|
|
}
|
|
|
|
// find the last selection action, and execute it
|
|
for (int32 ActionIndex = UserActions.Num() - 1; ActionIndex >= 0; --ActionIndex)
|
|
{
|
|
if (UserActions[ActionIndex].Action & GRAPHACTION_SelectNode)
|
|
{
|
|
DeferredSelectionTargetObjects.Empty();
|
|
for (const UEdGraphNode* Node : UserActions[ActionIndex].Nodes)
|
|
{
|
|
DeferredSelectionTargetObjects.Add(Node);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
RemoveAllNodes();
|
|
}
|
|
|
|
// Clean out set of added nodes
|
|
UserAddedNodes.Empty();
|
|
UserActions.Empty();
|
|
|
|
// Invoke any delegate methods
|
|
OnUpdateGraphPanel.ExecuteIfBound();
|
|
}
|
|
|
|
// Purges the existing visual representation (typically followed by an Update call in the next tick)
|
|
void SGraphPanel::PurgeVisualRepresentation()
|
|
{
|
|
// No need to call OnSplineHoverStateChanged since we're about to destroy all the nodes and pins
|
|
PreviousFrameSplineOverlap = FGraphSplineOverlapResult();
|
|
|
|
// Clear all of the nodes and pins
|
|
RemoveAllNodes();
|
|
}
|
|
|
|
bool SGraphPanel::IsNodeTitleVisible(const class UEdGraphNode* Node, bool bRequestRename)
|
|
{
|
|
bool bTitleVisible = false;
|
|
TSharedRef<SNode>* pWidget = NodeToWidgetLookup.Find(Node);
|
|
|
|
if (pWidget != nullptr)
|
|
{
|
|
TWeakPtr<SGraphNode> GraphNode = StaticCastSharedRef<SGraphNode>(*pWidget);
|
|
if(GraphNode.IsValid() && !HasMouseCapture())
|
|
{
|
|
FSlateRect TitleRect = GraphNode.Pin()->GetTitleRect();
|
|
const FVector2D TopLeft = FVector2D( TitleRect.Left, TitleRect.Top );
|
|
const FVector2D BottomRight = FVector2D( TitleRect.Right, TitleRect.Bottom );
|
|
|
|
if( IsRectVisible( TopLeft, BottomRight ))
|
|
{
|
|
bTitleVisible = true;
|
|
}
|
|
else if( bRequestRename )
|
|
{
|
|
bTitleVisible = JumpToRect( TopLeft, BottomRight );
|
|
}
|
|
|
|
if( bTitleVisible && bRequestRename )
|
|
{
|
|
GraphNode.Pin()->RequestRename();
|
|
SelectAndCenterObject(Node, false);
|
|
}
|
|
}
|
|
}
|
|
return bTitleVisible;
|
|
}
|
|
|
|
bool SGraphPanel::IsRectVisible(const FVector2D &TopLeft, const FVector2D &BottomRight)
|
|
{
|
|
return TopLeft >= PanelCoordToGraphCoord( FVector2D::ZeroVector ) && BottomRight <= PanelCoordToGraphCoord( CachedAllottedGeometryScaledSize );
|
|
}
|
|
|
|
bool SGraphPanel::JumpToRect(const FVector2D &TopLeft, const FVector2D &BottomRight)
|
|
{
|
|
ZoomToTarget(TopLeft, BottomRight);
|
|
|
|
return true;
|
|
}
|
|
|
|
void SGraphPanel::JumpToNode(const UEdGraphNode* JumpToMe, bool bRequestRename, bool bSelectNode)
|
|
{
|
|
if (JumpToMe != nullptr)
|
|
{
|
|
if (bRequestRename)
|
|
{
|
|
TSharedRef<SNode>* pWidget = NodeToWidgetLookup.Find(JumpToMe);
|
|
if (pWidget != nullptr)
|
|
{
|
|
TSharedRef<SGraphNode> GraphNode = StaticCastSharedRef<SGraphNode>(*pWidget);
|
|
GraphNode->RequestRename();
|
|
}
|
|
}
|
|
|
|
if (bSelectNode)
|
|
{
|
|
// Select this node, and request that we jump to it.
|
|
SelectAndCenterObject(JumpToMe, true);
|
|
}
|
|
else
|
|
{
|
|
// Jump to the node
|
|
CenterObject(JumpToMe);
|
|
}
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::JumpToPin(const UEdGraphPin* JumpToMe)
|
|
{
|
|
if (JumpToMe != nullptr)
|
|
{
|
|
JumpToNode(JumpToMe->GetOwningNode(), false, true);
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::OnBeginPIE( const bool bIsSimulating )
|
|
{
|
|
// Play the bounce curve on a continuous loop during PIE
|
|
BounceCurve.Play( this->AsShared(), true );
|
|
}
|
|
|
|
void SGraphPanel::OnEndPIE( const bool bIsSimulating )
|
|
{
|
|
// Stop the bounce curve
|
|
BounceCurve.JumpToEnd();
|
|
}
|
|
|
|
void SGraphPanel::OnGraphChanged(const FEdGraphEditAction& EditAction)
|
|
{
|
|
const bool bWillPurge = GraphObj->GetSchema()->ShouldAlwaysPurgeOnModification();
|
|
if (bWillPurge)
|
|
{
|
|
if ((EditAction.Graph == GraphObj) &&
|
|
(EditAction.Nodes.Num() > 0) &&
|
|
EditAction.bUserInvoked)
|
|
{
|
|
int32 ActionIndex = UserActions.Num();
|
|
if (EditAction.Action & GRAPHACTION_AddNode)
|
|
{
|
|
for (const UEdGraphNode* Node : EditAction.Nodes)
|
|
{
|
|
UserAddedNodes.Add(Node, ActionIndex);
|
|
}
|
|
}
|
|
UserActions.Add(EditAction);
|
|
}
|
|
}
|
|
else if ((EditAction.Graph == GraphObj) && (EditAction.Nodes.Num() > 0) )
|
|
{
|
|
// Remove action handled immediately by SGraphPanel::OnGraphChanged
|
|
const bool bWasAddAction = (EditAction.Action & GRAPHACTION_AddNode) != 0;
|
|
const bool bWasSelectAction = (EditAction.Action & GRAPHACTION_SelectNode) != 0;
|
|
const bool bWasRemoveAction = (EditAction.Action & GRAPHACTION_RemoveNode) != 0;
|
|
|
|
// The *only* reason we defer these actions is because code higher up the call stack
|
|
// assumes that the node is created later (for example, GenerateBlueprintAPIUtils::AddNodeToGraph
|
|
// calls AddNode (which calls this function) before calling AllocateDefaultPins, so if we create
|
|
// the widget immediately it won't be able to create its pins). There are lots of other examples,
|
|
// and I can't be sure that I've found them all....
|
|
|
|
// Minor note, the ugly little lambdas are just to deal with the time values and return values
|
|
// that the timer system requires (and we don't leverage):
|
|
if (bWasRemoveAction)
|
|
{
|
|
const auto RemoveNodeDelegateWrapper = [](double, float, SGraphPanel* Parent, TWeakObjectPtr<UEdGraphNode> NodePtr) -> EActiveTimerReturnType
|
|
{
|
|
if (NodePtr.IsValid())
|
|
{
|
|
UEdGraphNode* Node = NodePtr.Get();
|
|
Parent->RemoveNode(Node);
|
|
}
|
|
return EActiveTimerReturnType::Stop;
|
|
};
|
|
|
|
for (const UEdGraphNode* Node : EditAction.Nodes)
|
|
{
|
|
TWeakObjectPtr<UEdGraphNode> NodePtr = Node;
|
|
RegisterActiveTimer(0.f, FWidgetActiveTimerDelegate::CreateStatic(RemoveNodeDelegateWrapper, this, NodePtr));
|
|
}
|
|
}
|
|
if (bWasAddAction)
|
|
{
|
|
const auto AddNodeDelegateWrapper = [](double, float, SGraphPanel* Parent, TWeakObjectPtr<UEdGraphNode> NodePtr, bool bForceUserAdded) -> EActiveTimerReturnType
|
|
{
|
|
if (NodePtr.IsValid())
|
|
{
|
|
UEdGraphNode* Node = NodePtr.Get();
|
|
Parent->RemoveNode(Node);
|
|
Parent->AddNode(Node, bForceUserAdded ? WasUserAdded : NotUserAdded);
|
|
}
|
|
return EActiveTimerReturnType::Stop;
|
|
};
|
|
|
|
for (const UEdGraphNode* Node : EditAction.Nodes)
|
|
{
|
|
TWeakObjectPtr<UEdGraphNode> NodePtr = Node;
|
|
RegisterActiveTimer(0.f, FWidgetActiveTimerDelegate::CreateStatic(AddNodeDelegateWrapper, this, NodePtr, EditAction.bUserInvoked));
|
|
}
|
|
}
|
|
if (bWasSelectAction)
|
|
{
|
|
const auto SelectNodeDelegateWrapper = [](double, float, SGraphPanel* Parent, TSet< TWeakObjectPtr<UEdGraphNode> > NodePtrs) -> EActiveTimerReturnType
|
|
{
|
|
Parent->DeferredSelectionTargetObjects.Empty();
|
|
for (TWeakObjectPtr<UEdGraphNode>& NodePtr : NodePtrs)
|
|
{
|
|
if (NodePtr.IsValid())
|
|
{
|
|
UEdGraphNode* Node = NodePtr.Get();
|
|
Parent->DeferredSelectionTargetObjects.Add(Node);
|
|
}
|
|
}
|
|
return EActiveTimerReturnType::Stop;
|
|
};
|
|
|
|
TSet< TWeakObjectPtr<UEdGraphNode> > NodePtrSet;
|
|
for (const UEdGraphNode* Node : EditAction.Nodes)
|
|
{
|
|
NodePtrSet.Add(Node);
|
|
}
|
|
|
|
RegisterActiveTimer(0.f, FWidgetActiveTimerDelegate::CreateStatic(SelectNodeDelegateWrapper, this, NodePtrSet));
|
|
}
|
|
}
|
|
}
|
|
|
|
void SGraphPanel::NotifyGraphChanged(const FEdGraphEditAction& EditAction)
|
|
{
|
|
// Forward call
|
|
OnGraphChanged(EditAction);
|
|
}
|
|
|
|
void SGraphPanel::AddReferencedObjects(FReferenceCollector& Collector)
|
|
{
|
|
Collector.AddReferencedObject( GraphObj );
|
|
Collector.AddReferencedObject( GraphObjToDiff );
|
|
}
|
|
|
|
EActiveTimerReturnType SGraphPanel::InvalidatePerTick(double InCurrentTime, float InDeltaTime)
|
|
{
|
|
// Invalidate the layout so it will redraw.
|
|
Invalidate(EInvalidateWidget::Layout);
|
|
|
|
TimeLeftToInvalidatePerTick -= InDeltaTime;
|
|
|
|
// When the time is done, stop the invalidation per tick because the UI will be static once more.
|
|
if (TimeLeftToInvalidatePerTick <= 0.0f)
|
|
{
|
|
TimeLeftToInvalidatePerTick = 0.0f;
|
|
return EActiveTimerReturnType::Stop;
|
|
}
|
|
return EActiveTimerReturnType::Continue;
|
|
}
|