Commit Graph

8 Commits

Author SHA1 Message Date
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
2c21b4c695 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

[CL 16705229 by Jamie Dale in ue5-main branch]
2021-06-17 11:19:23 -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
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
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