The mecanism to select something wihtout emiting a notification was clearing the existing pending notifications and it wasn't interacting properly with the old bacth notification system.
Also fixed a batch selection notification issue when unselecting all the selected actors from the scene outliner.
#rb Jamie.Dale
#preflight 61b3732fee0de9822e452275
#ROBOMERGE-AUTHOR: julien.stjean
#ROBOMERGE-SOURCE: CL 18436445 in //UE5/Release-5.0/... via CL 18437432
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v897-18405271)
[CL 18437918 by julien stjean in ue5-release-engine-test branch]
This represents UE4/Main @17911760, Release-5.0 @17915875 and Dev-PerfTest @17914035
[CL 17918595 by aurel cordonnier in ue5-release-engine-test branch]
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
#ROBOMERGE-SOURCE: CL 16776547 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v836-16769935)
[CL 16776582 by jamie dale in ue5-release-engine-test branch]
Previously we relied on element implementations to know what their parent or child elements might be, and to deal with them correctly in the following cases:
1) When "normalising" a selection to be safe for operations like a move or delete, eg) removing elements that are children of other selected elements.
2) When deleting an element, also ensuring that any implicitly destroyed child elements were deselected, eg) deleting an ISM component that has selected static mesh instances.
This approach hurts the modularity of the elements themselves, as it requires that the element implementations have intrinsic knowledge of any other child (or parent) element types that may exist, and to deal with them accordingly when needed. As a concrete example, an ISM component may have child elements in the form of static mesh instance elements, however the generic component element type does not (and should not) directly know that static mesh instance elements exist.
To address this issue, we've added a new interface, UTypedElementHierarchyInterface, which can be used to provide information about the logical parent<->child hierarchy information of elements. This is implemented as follows for our current element types:
- Actor:
- GetParentElement returns an invalid element handle.
- GetChildElements returns the element handles of any components on the actor.
- Component:
- GetParentElement returns its owner actor element handle.
- GetChildElements returns nothing by default, but UActorComponent::GetComponentChildElements may be overridden to control this behavior.
- eg) UInstancedStaticMeshComponent overrides it to return its static mesh instance element handles.
- SMInstance:
- GetParentElement returns its owner ISM component element handle.
- GetChildElements returns nothing.
Now the problems listed above can be solved by using this interface instead of relying on the element implementations:
1) Selection normalization is now handled by UTypedElementSelectionSet, replacing the previous duplicate implementations of UTypedElementCommonActions and UTypedElementViewportInteraction.
2) UTypedElementSelectionSet will now walk and also update the selection state of child elements, when asked to via the FTypedElementSelectionOptions.
Breaking Changes:
- UTypedElementCommonActions::GetElementsForAction and UTypedElementViewportInteraction::GetSelectedElementsToMove have been removed, in favor of using the selection normalization functions of UTypedElementSelectionSet.
- Note: You may still favor using FLevelEditorViewportClient::GetElementsToManipulate, as it will have removed normalized elements that also cannot be moved by a gizmo.
- UTypedElementCommonActions::DeleteElements and UTypedElementCommonActions::DuplicateElements have been removed, as these functions operated on an unnormalized selection and could be unsafe. UTypedElementCommonActions::DeleteNormalizedElements and UTypedElementCommonActions::DuplicateNormalizedElements should be used instead.
- AGroupActor::ForEachActorInGroup and AGroupActor::ForEachMovableActorInGroup now take a second AGroupActor* argument in their callback.
#rb Brooke.Hubert
#preflight 60ca33a678c3b00001e8f5df
#ROBOMERGE-SOURCE: CL 16705229 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v835-16672529)
[CL 16705233 by jamie dale in ue5-release-engine-test branch]
This avoids the calculation being made repeatedly when nothing has changed (eg, it used to be cached 3-4 times during a selection change event), as well as not needing to calculate it each frame (eg, for the gizmo visibility, or during a drag operation)
#jira UE-108343
#rb Brooke.Hubert
#ROBOMERGE-SOURCE: CL 15471413 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668)
[CL 15471421 by jamie dale in ue5-main branch]
- 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]
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]
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]
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]
#rnx
#rb none
#ROBOMERGE-SOURCE: CL 10869241 via CL 10869527 via CL 10869904
#ROBOMERGE-BOT: (v613-10869866)
[CL 10870586 by ryan durand in Main branch]
#rb none
[CODEREVIEW] Matt.Kuhlenschmidt
#ROBOMERGE-SOURCE: CL 10058660 via CL 10058666
#ROBOMERGE-BOT: (v566-10053404)
[CL 10058668 by chris gagnon in Main branch]
#ROBOMERGE-OWNER: matt.kuhlenschmidt
#ROBOMERGE-AUTHOR: matt.kuhlenschmidt
#ROBOMERGE-SOURCE: CL 9870262 via CL 9870265
#ROBOMERGE-BOT: (v548-9842178)
#rb chris.gagnon
[CL 9872761 by Matt Kuhlenschmidt in Main branch]
#rb chris.gagnon
[FYI] michael.noland
#ROBOMERGE-SOURCE: CL 7393650 via CL 7393694 via CL 7402553
#ROBOMERGE-BOT: (v371-7306989)
[CL 7402870 by andrew ladenberger in Main branch]
-120 seconds to select 6000 actors to instantaneous to select 60 000.
From dev-enterprise[at]7039407
#rb Chris.Gagnon, Francis.Hurteau
#jira UE-76972
#ROBOMERGE-SOURCE: CL 7248140 in //UE4/Release-4.23/...
#ROBOMERGE-BOT: RELEASE (Release-4.23 -> Main) (v367-6836689)
[CL 7248141 by danny couture in Main branch]