Commit Graph

16 Commits

Author SHA1 Message Date
julien stjean
51e563b9a0 Fixed the typed element scripting api issues.
Added the FScriptTypedElementHandle. These handles are disarmed when the element they pointing to is destroyed instead of crashing the engine. They do have a performance overhead so using these should be restricted to exposing stuff to blueprint/python.

Reworked the TypedElementList to be a template so that we have both a FTypedElementList and a FScriptTypedElementList from the same source code.

Changed the api of the interfaces so that can now accept and use the scripted version of the handle and list instead of the native ones.

#jira UE-133667
#rb Brooke.Hubert
#preflight 61f89bfaf657e25a5908db48

#ROBOMERGE-AUTHOR: julien.stjean
#ROBOMERGE-SOURCE: CL 18816318 in //UE5/Release-5.0/... via CL 18816336 via CL 18822818
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042)

[CL 18824371 by julien stjean in ue5-main branch]
2022-02-02 07:40:00 -05:00
Julien StJean
0ebac3a7ff Changed the TypedElementInterface to use UInterfaces instead of an object base api.
#jira UETOOL-4054
#preflight 6132413c1a52e20001dce90d
#rb Jamie.Dale

[CL 17424653 by Julien StJean in ue5-main branch]
2021-09-03 14:17:38 -04:00
Jamie Dale
dd96f734b2 Converted UTypedElementList to no longer be a UObject
Storing typed elements in UObjects can easily lead to reference leaks if the elements aren't cleared prior to the UObject being left pending GC. This actually made UTypedElementList tricky to use, as you had to remember to manually empty it when you'd finished with it to avoid reference leaks, and we've had several cases now where that was done incorrectly.

To address this issue, we've moved element lists back to being a normal C++ class, FTypedElementList. However, unlike the original version of FTypedElementList (which was itself a UStruct), this version is always heap-allocated and referenced via a TSharedPtr/TSharedRef.

This gives us a nice middle-ground of a well defined lifetime (ie, no lingering references prior to GC) while still being efficient to pass around, including for scripting APIs via FTypedElementListProxy (which just wraps the TSharedPtr in a UStruct).

The downside of this approach is that we need to wrap the FTypedElementList functions that we want to expose to the scripting API (see UTypedElementListLibrary), however that is a far more reasonable burden than requring every user of the typed element framework to know and understand that UTypedElementList had to be manually cleared to avoid potentially hard to find reference leaks (especially if via leaked via scripting APIs).

The core of this change is to TypedElementList.h/.cpp, with TypedElementListFwd.h existing to forward declare the pointer types, and TypedElementListProxy.h and TypedElementListLibrary.h existing to declare the proxy type and wrapped functions used for scripting APIs. TypedElementSelectionInterface.h (and its implementations) provide an example of using FTypedElementListProxy within a scripting API, and the rest of the change is mostly just fallout to transform const UTypedElementList* to FTypedElementListConstRef and UTypedElementList* to FTypedElementListRef.

#rb Brooke.Hubert
#preflight 60d2720c634cd100016c804b

[CL 16776547 by Jamie Dale in ue5-main branch]
2021-06-24 14:29:38 -04:00
Jamie Dale
4ed253dbf2 Removed the class count from USelection, in favor of using the counter on the underlying element list
#rb Brooke.Hubert
#preflight 6088582c04a11d000155b34f

[CL 16131462 by Jamie Dale in ue5-main branch]
2021-04-27 15:37:04 -04:00
jamie dale
82ca162aa8 Initial support for manipulating Static Mesh instances directly in the editor
Adds support for selection, gizmo manipulation, property editing, duplication, deletion, and undo/redo for Static Mesh instances within the main Level Editor, without having to enter an alternative editing mode.

Note: This is currently disabled via UE_ENABLE_SMINSTANCE_ELEMENTS

#rb Brooke.Hubert

#ROBOMERGE-SOURCE: CL 15481362 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668)

[CL 15481376 by jamie dale in ue5-main branch]
2021-02-19 22:02:09 -04:00
Jamie Dale
ff7d47fbf4 Made typed element includes more consistent
- Moved all the "framework" code under "Elements/Framework".
 - Moved all the "interface" code under "Elements/Interfaces".

This lets the code be split over multiple modules (including the Engine and Editor) while retaining consistent include paths with things like "Elements/Actor", "Elements/Component", etc, as well as letting new interfaces and frameworky things be added outside of the core typed element modules while still maintaining a coherent include scheme.

#fyi Brooke.Hubert
#rb Chris.Gagnon

[CL 14585700 by Jamie Dale in ue5-main branch]
2020-10-27 07:00:04 -04:00
Jamie Dale
db7459f98e Migrated undo/redo support from USelection to UTypedElementSelectionSet
This adds some new functions to UTypedElementSelectionInterface to deal with writing the underlying data needed by an element (WriteTransactedElement) to factory it again later (ReadTransactedElement) when restoring a prior selection state.

#rb Chris.Gagnon

[CL 14585511 by Jamie Dale in ue5-main branch]
2020-10-27 05:49:47 -04:00
Jamie Dale
e3ac0f1b0f Updated USelection to be a legacy shim around a UTypedElementSelectionSet
This change removes the original UObject-array based USelection implementation that was still being used for generic UObject selection, in favor of always using a UTypedElementSelectionSet to back the USelection.

 - Added an "Object" element type, so that generic objects can be stored in a UTypedElementSelectionSet.
 - Added UEngineElementsLibrary to manage the creation and destruction of "Object" elements, as CoreUObject cannot directly use the TypedElementFramework.
   - Also migrated "Actor" and "Component" element creation and destruction to UEngineElementsLibrary for consistency.
 - Fixed a race condition in the AcquireEditorXElementHandle functions due to the TTypedElementOwnerStore lock being released between the find and the add (see TTypedElementOwnerStore::FindOrRegisterElementOwner).
 - Moved the GetObject function onto a new UTypedElementObjectInterface, as that function will likely be needed by legacy code outside of selection.
 - Removed UTypedElementSelectionSet::GetMutableElementList in favor of selectively exposing certain functions from the underlying UTypedElementList, which should avoid potential abuse or misuse of the underlying list.

#rb Brooke.Hubert
#rnx

[CL 14535062 by Jamie Dale in ue5-main branch]
2020-10-21 12:09:05 -04:00
Jamie Dale
64b075c319 First phase of converting Level Editor viewport selection to use typed elements
This phase focuses on the minimum set of changes needed to port the UnrealEd logic for handling the selection of actors and components within the Level Editor viewport to use typed element interfaces. There is still future work to be done to clean this up further.

This change adds a new framework type, UTypedElementSelectionSet, which manages the concept of "selection" for typed elements. Internally this owns its own UTypedElementList, and ensures that mutation of that list goes via the UTypedElementSelectionInterface implementations.

To allow specific asset editors to customize their selection behavior, UTypedElementSelectionSet may have "selection proxies" that implement UTypedElementAssetEditorSelectionProxy registered to it. This is what's used to allow the level editor to implement its type specific rules.

The core Level Editor selection implementation for actors and components now lives inside UActorElementLevelEditorSelectionProxy and UComponentElementLevelEditorSelectionProxy, and the existing UUnrealEdEngine functions that used to deal with this logic now proxy through to those implementations via UTypedElementSelectionSet. This means that the implementation has moved into the LevelEditor module without UnrealEd even knowing.

Future work will focus on:
 - Cleaning up the legacy USelection bridge, so that all USelection instances are just a proxy around a UTypedElementSelectionSet.
   - This will involve making a basic "Object" element type to handle the generic UObject based selection (for assets) that USelection also handles.
   - This should allow GetMutableElementList to be removed from UTypedElementSelectionSet, to avoid potential abuse or misuse.
 - Investigating the best way to integrate element based selection into the editor modes.

#rb Chris.Gagnon, Brooke.Hubert
#rnx

[CL 14470181 by Jamie Dale in ue5-main branch]
2020-10-11 12:40:44 -04:00
Jamie Dale
149fbb70c4 Improved scripting support for typed elements
- Ported the typed element list (FTypedElementList) to be a UObject (UTypedElementList) so that it can be used with UFUNCTION arguments.
   - This also removes FTypedElementListPtr, and exposes UTypedElementList functions to scripting.
 - Exposed UTypedElementRegistry functions to scripting.
 - Added UTypedElementHandleLibrary to expose basic FTypedElementHandle functionality to scripting.
 - Exposed AActor and UActorComponent functions for getting an element handle.

#rb Chris.Gagnon
#rnx

[CL 14311016 by Jamie Dale in ue5-main branch]
2020-09-14 13:57:25 -04:00
Jamie Dale
fd0f8d6d49 Fixed leak of FAssetEditorModeManager instances
FEditorViewportClient would only unregister and destroy the mode manager if it had created it, and some places were passing in a new instance which was being leaked

#rb Brooke.Hubert
#rnx

[CL 14291699 by Jamie Dale in ue5-main branch]
2020-09-10 15:18:12 -04:00
Jamie Dale
3af9d6c7c8 Fix ensure when notifying selection change during a batch
#jira UE-97103
#rb none

[CL 14173210 by Jamie Dale in ue5-main branch]
2020-08-24 14:07:47 -04:00
Jamie Dale
ab38dab3ac Fixed static analysis warning
#rb none
#rnx

[CL 14146092 by Jamie Dale in ue5-main branch]
2020-08-19 14:49:52 -04:00
Jamie Dale
f8138bbb01 Switching USelection to use element lists by default for actors and components
#rb Chris.Gagnon
#rnx

[CL 14127286 by Jamie Dale in ue5-main branch]
2020-08-17 16:52:54 -04:00
Jamie Dale
1ec3c71366 Updated USelection to be optionally driven by an element list
USelection can now operate on two different backends; FObjectSelectionStore (which is the old, object-array implementation), or FElementSelectionStore (which is the newer element list based implementation).

Breaking changes:
 - USelection::MarkBatchDirty is now USelection::ForceBatchDirty.
 - USelection::Initialize is now private. Use one of USelection::CreateObjectSelection, USelection::CreateActorSelection, or USelection::CreateComponentSelection to create your USelection instance instead.
 - USelection::SelectionChangedEvent and USelection::SelectObjectEvent are now events, and should not have their Broadcast called externally (use USelection::NoteSelectionChanged or USelection::NoteUnknownSelectionChanged if you must manually notify).

Note: The element list implementation is currently disabled (via UE_USE_ELEMENT_LIST_SELECTION) until actor and component element support is submitted.

#rb Chris.Gagnon

[CL 14126915 by Jamie Dale in ue5-main branch]
2020-08-17 16:27:02 -04:00
Jamie Dale
70a54d23ca Moved USelection to UnrealEd
#rb Chris.Gagnon
#rnx

[CL 14037101 by Jamie Dale in ue5-main branch]
2020-08-05 10:28:16 -04:00