Commit Graph

30 Commits

Author SHA1 Message Date
logan buchy
87012153c4 Remove TypedElementViewportInteractionGizmoManipulation from TypedElement ViewportInteraction
* The same functionality is provided by the GizmoManipulationStarted and GizmoManipulationStopped.
* This simplifies the interface and removes the bespoke parameter added to branch between when manipulation starts and when it is ongoing to avoid expensive rendering invalidations
* There are some clients of TypedElementViewportInteractionGizmoManipulation::ApplyDeltaToActor, this CL does not address usage of this function.  Doing so will require further adoption of TypedElements among those systems

#jira UE-187188
#rb Brooke.Hubert

[CL 25964466 by logan buchy in ue5-main branch]
2023-06-13 17:28:30 -04:00
jason hoerner
2a816e5ad4 Further optimization for moving actor with many static mesh components. Only invalidate the static lighting cache at the start of a move operation. We don't invalidate the cache in "GizmoManipulationStarted", because the user can click on a handle (calling the start function) without actually moving, which should have no effect. So a flag is used to detect the first time "GizmoManipulationDeltaUpdate" is called, and subsequent calls can skip repeatedly invalidating the lighting cache.
With this fix, on my machine, the cost of moving a blueprint with 1000 items drops from 45 ms to 7 ms.  Baseline tick is 8 ms (120 fps) when idling, so the results while moving improve from 19 fps to 65 fps.  The remaining time is mostly split between physics and navigation update.  Invalidating the static lighting cache is so costly because it both invalidates the render state of every item, and notifies packages of the change.

#jira UE-147154
#rnx
#rb jamie.dale
#preflight 63ff4748e32cdb7d9aacab16

[CL 25050136 by jason hoerner in ue5-main branch]
2023-04-14 17:02:21 -04:00
bryan sefcik
0837230669 Ran IWYU again on half of the Engine/Source/Editor/... source files.
#jira

[CL 21716414 by bryan sefcik in ue5-main branch]
2022-08-30 23:03:03 -04:00
julien stjean
6f120bb052 Fixing the SMInstanceElements rotating differently to an offseted pivot then a normal actor or component.
The issue was that weren't using the same pivot  and the same quaternion math for the rotation.

#jira UE-130496
#brooke.hubert
#preflight 61a83b83ad6629a51eac6537

#ROBOMERGE-AUTHOR: julien.stjean
#ROBOMERGE-SOURCE: CL 18349318 in //UE5/Release-5.0/... via CL 18349329
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18350076 by julien stjean in ue5-release-engine-test branch]
2021-12-02 02:13:23 -05:00
julien stjean
9af8446874 Changed the TypedElementInterface to use UInterfaces instead of an object base api.
#jira UETOOL-4054
#preflight 6132413c1a52e20001dce90d
#rb Jamie.Dale

#ROBOMERGE-SOURCE: CL 17424653 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v865-17346139)

[CL 17424661 by julien stjean in ue5-release-engine-test branch]
2021-09-03 14:18:34 -04:00
zach rammell
1c5e438e41 Extend viewport focusing to work with typed elements
#jira UETOOL-3744
#rb [at]brooke.hubert
#preflight 61144bdcb2dc4b00015438c5

#ROBOMERGE-SOURCE: CL 17145332 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v855-17104924)

[CL 17145336 by zach rammell in ue5-release-engine-test branch]
2021-08-11 21:16:26 -04:00
jamie dale
6e412af28b Fixed incorrect comment
#rb none
#rnx

#ROBOMERGE-SOURCE: CL 17059694 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v850-17047176)

[CL 17059716 by jamie dale in ue5-release-engine-test branch]
2021-08-04 17:02:08 -04:00
jamie dale
afa943050c 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

#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]
2021-06-24 14:31:49 -04:00
jamie dale
a2c2b50c07 Provided an interface to query element parent<->child hierarchy information and used it to unify selection normalization
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]
2021-06-17 11:19:53 -04:00
Jamie Dale
2b4fd7e927 Ensure GizmoManipulationStarted and GizmoManipulationStopped are called in pairs
The editor viewport would previously skip the GizmoManipulationStopped call if nothing had actually moved, but this causes an imbalance in the APIs which call NotifyMovementStarted and NotifyMovementEnded.

GizmoManipulationStopped is now always called, but with an extra argument saying if anything actually moved.

#rb Brooke.Hubert
#preflight 60aeb2de1db8a70001cbe077

[CL 16537833 by Jamie Dale in ue5-main branch]
2021-06-02 15:11:28 -04:00
jamie dale
ef31a91045 Removed finalizer from FTypedElementViewportInteractionCustomization::GetElementsToMove
This was to optimize selecting groups, but we've handled this case elsewhere by just skipping the group logic if the group is already in the list of things that we've processed. This applies that approach to getting the elements to move.

#rb Brooke.Hubert

#ROBOMERGE-SOURCE: CL 15890607 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v786-15839533)

[CL 15890762 by jamie dale in ue5-main branch]
2021-04-01 12:41:54 -04:00
jamie dale
668850b187 Moved TypedElementCommonActions into Engine
This means it can also be used by the InteractiveToolsFramework, and makes sense as the type has Engine dependencies in its API

#rb Brooke.Hubert
#rnx

#ROBOMERGE-SOURCE: CL 15668129 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v779-15635321)

[CL 15668794 by jamie dale in ue5-main branch]
2021-03-10 15:25:20 -04:00
jamie dale
c922ceb04e Optimized GetElementsToMove for large group actors
Each group actor is now only enumerated once at the end, rather than once for each selected actor within a group

#jira UE-108343
#rb Brooke.Hubert

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

[CL 15475131 by jamie dale in ue5-main branch]
2021-02-19 15:51:43 -04:00
Jamie Dale
38a52472be Added support for deleting typed elements from a world
#rb Brooke.Hubert

[CL 15265153 by Jamie Dale in ue5-main branch]
2021-01-31 11:46:45 -04:00
Jamie Dale
3e06018cf5 Renamed TypedElementInterfaces to TypedElementRuntime and moved UTypedElementSelectionSet to it
This lets UTypedElementSelectionSet (which has minimal dependencies) to be used by the Engine and InteractiveToolsFramework modules

#rb Brooke.Hubert

[CL 15219316 by Jamie Dale in ue5-main branch]
2021-01-27 14:25:08 -04:00
Jamie Dale
3f3e0e7a67 Updated actor property editing to be typed element based
SActorDetails now operates on a given UTypedElementSelectionSet (removing its dependence on the global selection), and also operates based on the list of selected top-level elements rather than the selected actors.

UTypedElementDetailsInterface provides the interface needed for an element to be used with the details panel, with ITypedElementDetailsObject being the underlying glue object.
The ITypedElementDetailsObject instance will exist as long as the details panel is using it, so gives a lifetime to potentially synthesized UObject instances that are created purely for editing (eg, on instances).

This change removes almost all direct use of UpdateFloatingPropertyWindowsFromActorList, with only a single use-case in the reference viewer remaining.
Most code was already using UpdateFloatingPropertyWindows anyway, which now emits an extra OnElementSelectionChanged event in addition to its previous OnActorSelectionChanged event.
UpdateFloatingPropertyWindowsFromActorList now only emits an OnOverridePropertyEditorSelection event and no longer emits an OnActorSelectionChanged event.
SActorDetails is updated from both OnElementSelectionChanged and OnOverridePropertyEditorSelection, with the OnActorSelectionChanged event remaining for backwards compatability with existing code.

#jira
#rb Chris.Gagnon, Brooke.Hubert

[CL 15037524 by Jamie Dale in ue5-main branch]
2021-01-11 11:14:52 -04:00
Jamie Dale
5160047ddd Added SetSelection helper to UTypedElementSelectionSet
This is equivalent to calling ClearSelection then SelectElements, but happens in a single batch.

#rb Brooke.Hubert

[CL 14891193 by Jamie Dale in ue5-main branch]
2020-12-09 15:57:48 -04:00
Jamie Dale
2eba45e383 Ported viewport drag-duplication to use typed elements
This involved splitting and converting several UUnrealEdEngine functions to no longer operate on or manipulate the current selection set:
 - edactCopySelected:
   - Split into CopyComponents and CopyActors, which take an array of components and actors to copy rather than use the selection state.
   - Breaking: If a DestinationData is provided, it is now used *instead of* the clipboard rather than *as well as* the clipboard.
     - In practice nothing seemed to rely on this old method, and in fact some places stashed and restored the clipboard data to workaround it!
 - edactPasteSelected:
   - Split into PasteComponents and PasteActors, which now returns an array of components or actors that were pasted rather than make them the active selection.
   - Note: PasteActors does still update the selection via FactoryCreateText, but we restore it again afterwards.
 - edactDuplicateSelected:
   - Split into DuplicateComponents and DuplicateActors, which take an array of components or actors to duplicate, and also returns an array of components or actors that were created.

The "edact" versions still use and update the selection state when calling into the internal functions, but the typed element layer does not, and handles duplication via UEngineElementsLibrary::DuplicateElements and UTypedElementWorldInterface, with the level editor viewport handling updating the selection state afterwards.

#rb Brooke.Hubert, Chris.Gagnon

[CL 14838341 by Jamie Dale in ue5-main branch]
2020-12-02 16:08:03 -04:00
Jamie Dale
c54ffb854e Ported the actor snap/align functions to use typed elements internally
The following options from the actor viewport menu are now elemenent based:
 - Snap/Align (excluding layers)
 - Delta Transform
 - Mirror X/Y/Z

#rb Brooke.Hubert

[CL 14830849 by Jamie Dale in ue5-main branch]
2020-12-01 16:57:10 -04:00
Jamie Dale
ca08dfb897 Removed GLevelEditorModeTools use from typed element interface implementations
#rb Brooke.Hubert
#rnx

[CL 14828542 by Jamie Dale in ue5-main branch]
2020-12-01 12:05:35 -04:00
Jamie Dale
5e11829221 Fixed incorrect interface signature
#rb none
#rnx

[CL 14818390 by Jamie Dale in ue5-main branch]
2020-11-28 14:50:45 -04:00
Jamie Dale
cf9fcc3e71 Implemented initial support for element based viewport interaction
There are two parts to this:
 - UTypedElementWorldInterface, which provides the lower-level access to things like element transforms.
 - UTypedElementViewportInteraction, which provides the higher-level access for things like gizmo manipulation.
   - The default implementation is implemented purely in terms of get/set transform via UTypedElementWorldInterface.
   - The level editor overrides this to continue to go through the current code path for gizmo manipulation.

#rb Brooke.Hubert

[CL 14813510 by Jamie Dale in ue5-main branch]
2020-11-25 14:31:59 -04:00
Jamie Dale
2771f192b1 Added utils for getting the existence/count of the number of elements/objects within a element list and selection set
#rb Lauren.Barnes
#rnx

[CL 14793994 by Jamie Dale in ue5-main branch]
2020-11-19 21:42:20 -04:00
Jamie Dale
fe22bc2cbd Allow the UObject utils for element selection to be used with element lists as well as the wrapper selection set
#rb Brooke.Hubert
#rnx

[CL 14779934 by Jamie Dale in ue5-main branch]
2020-11-18 14:27:25 -04:00
Jamie Dale
bbb6877579 Added functions to enumerate selected objects from the typed element selection set
Moved the typed element list to also use enumeration functions for consistency

#fyi Lauren.Barnes
#rb Chris.Gagnon

[CL 14758753 by Jamie Dale in ue5-main branch]
2020-11-16 17:19:10 -04:00