UPolygonSelectionMechanic

[UPolygonSelectionMechanic](API\Plugins\ModelingComponents\Selection\UPolygonSelectionMechanic) implements the interaction for selecting a set of faces/vertices/edges from a FGroupTopology on a [UDynamicMeshComponent](API\Runtime\GeometryFramework\Components\UDynamicMeshComponent).

Choose your operating system:

Windows

macOS

Linux

Inheritance Hierarchy

References

Module

ModelingComponents

Header

/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Public/Selection/PolygonSelectionMechanic.h

Include

#include "Selection/PolygonSelectionMechanic.h"

Syntax

UCLASS()
class UPolygonSelectionMechanic :
    public UInteractionMechanic,
    public IClickBehaviorTarget,
    public IHoverBehaviorTarget

Remarks

UPolygonSelectionMechanic implements the interaction for selecting a set of faces/vertices/edges from a FGroupTopology on a UDynamicMeshComponent.

Variables

Name Description

Protected variable

TUniquePtr< FPo...

 

ActiveChange

Public variable

bool

 

bAddSelectionFilterPropertiesToParentTool

Configuration variables that must be set before bSetup is called

Protected variable

FInputCapturePr...

 

BasePriority

Protected variable

bool

 

bCtrlToggle

Protected variable

bool

 

bIsEnabled

Protected variable

bool

 

bShiftToggle

Protected variable

FViewCameraStat...

 

CameraState

Protected variable UProperty

TObjectPtr< USi...

 

ClickOrDragBehavior

Protected variable

TSet< int >

 

CurrentlyHighlightedGroups

Protected variable UProperty

TObjectPtr< UTr...

 

DrawnTriangleSetComponent

Protected variable

TFunction< FDyn...

 

GetSpatialFunc

Protected variable UProperty

TObjectPtr< UMa...

 

HighlightedFaceMaterial

Public variable

FToolDataVisual...

 

HilightRenderer

Protected variable

FGroupTopologyS...

 

HilightSelection

Protected variable UProperty

TObjectPtr< UMo...

 

HoverBehavior

Protected variable

FVector3d

 

LastClickedHitNormal

Protected variable

FVector3d

 

LastClickedHitPosition

Protected variable UProperty

TObjectPtr< URe...

 

MarqueeMechanic

Protected variable

const FDynamicM...

 

Mesh

Public variable

FSimpleMulticas...

 

OnSelectionChanged

OnSelectionChanged is broadcast whenever the selection is modified (including by FChanges, which means that called functions should not issue undo transactions.

Protected variable

FGroupTopologyS...

 

PersistentSelection

Public variable

FToolDataVisual...

 

PolyEdgesRenderer

Protected variable

FGroupTopologyS...

 

PreDragPersistentSelection

Used for box selection.

Protected variable

FGroupTopologyS...

 

PreDragTopoSelectorSettings

Protected variable UProperty

TObjectPtr< APr...

 

PreviewGeometryActor

The actor we create internally to own the DrawnTriangleSetComponent

Public variable UProperty

TObjectPtr< UPo...

 

Properties

TODO: Is it worth issuing separate callbacks in normal selection changes and in FChange ones, to allow the user to bundle in some FChanges into the normal callback?

Public variable

FToolDataVisual...

 

SelectionRenderer

Protected variable

int32

 

SelectionTimestamp

Protected variable

TFunction< bool...

 

ShouldAddToSelectionFunc

Protected variable

TFunction< bool...

 

ShouldRemoveFromSelectionFunc

Protected variable

TFunction< bool...

 

ShouldSelectEdgeLoopsFunc

When bSelectEdgeLoops is true, this function is tested to see if we should select edge loops, to allow edge loop selection to be toggled with some key (setting bSelectEdgeLoops to false overrides this function).

Protected variable

TFunction< bool...

 

ShouldSelectEdgeRingsFunc

When bSelectEdgeRings is true, this function is tested to see if we should select edge rings, to allow edge ring selection to be toggled with some key (setting bSelectEdgeRings to false overrides this function).

Protected variable

FTransform3d

 

TargetTransform

Protected variable

const FGroupTop...

 

Topology

Protected variable

TSharedPtr< FGr...

 

TopoSelector

Destructors

Name Description

Public function Virtual

~UPolygonSelectionMechanic()

Functions

Name Description

Public function

void

 

BeginChange()

Change Tracking Begin a change record.

Public function

void

 

ClearHighlight()

Clear current hover-highlight

Public function

void

 

ClearSelection()

Clear the current selection.

Public function

void

 

DisableBehaviors

(
    UInteractiveTool* ParentToolIn
)

Removes the mechanic's own click/hover handlers, which means that the parent tool will need to call UpdateSelection(), UpdateHighlight(), ClearHighlight(), and ClearSelection() from its own hover/click handlers.

Public function Virtual

void

 

DrawHUD

(
    FCanvas* Canvas,
    IToolsContextRenderAPI* Render...
)

Public function

TUniquePtr< ...

 

EndChange()

End the active change and return it. Returns empty change if the selection was not modified!

Public function

bool

 

EndChangeAndEmitIfModified()

Ends the active change and emits it via the parent tool, if the selection has been modified.

Public function Const

const FGroup...

 

GetActiveSelection()

Public function Const

void

 

GetClickedHitPosition

(
    FVector3d& PositionOut,
    FVector3d& NormalOut
)

Can be used by in an OnSelectionChanged event to inspect the clicked location (i.e., the values returned by the UpdateSelection() function when the click happened).

Public function Const

TPair< FInpu...

 

GetPriorityRange()

Gets the current priority range used by behaviors in the mechanic.

Public function Const

void

 

GetSelection

(
    UPersistentMeshSelection& Selectio...,
    const FCompactMaps* CompactMap...
)

Gives the current selection as a storable selection object.

Public function Const

FAxisAligned...

 

GetSelectionBounds

(
    bool bWorld
)

Public function Const

FFrame3d

 

GetSelectionFrame

(
    bool bWorld,
    FFrame3d* InitialLocalFrame
)

Public function

TSharedPtr< ...

 

GetTopologySelector()

Protected function

FGroupTopolo...

 

GetTopoSelectorSettings

(
    bool bUseOrthoSettings
)

Get the topology selector settings to use given the current selection settings.

Public function Const

bool

 

HasSelection()

Public function

void

 

Initialize

(
    const FDynamicMesh3* Mesh,
    FTransform TargetTransform,
    UWorld* World,
    const FGroupTopology* Topology,
    TFunction< FDynamicMeshAABBTree3&#...
)

Initializes the mechanic.

Public function

void

 

Initialize

(
    UDynamicMeshComponent* MeshCom...,
    const FGroupTopology* Topology,
    TFunction< FDynamicMeshAABBTree3&#...
)

Public function

void

 

LoadSelection

(
    const UPersistentMeshSelection& Se...
)

Sets the current selection using the given storable selection object.

Public function

void

 

NotifyMeshChanged

(
    bool bTopologyModified
)

Notify internal data structures that the associated MeshComponent has been modified.

Protected function Virtual

void

 

OnDragRectangleChanged

(
    const FCameraRectangle& CurrentRec...
)

Protected function Virtual

void

 

OnDragRectangleFinished

(
    const FCameraRectangle& Rectangle,
    bool bCancelled
)

Protected function Virtual

void

 

OnDragRectangleStarted()

These get bound to marquee mechanic delegates.

Public function

void

 

SetBasePriority

(
    const FInputCapturePriority& Prior...
)

Sets the base priority so that tools can make sure that their own behaviors are higher priority.

Public function

void

 

SetIsEnabled

(
    bool bOn
)

Enable/disable the mechanic without permanently removing behaviors or shutting it down.

Public function

void

 

SetSelection

(
    const FGroupTopologySelection& Sel...,
    bool bBroadcast
)

Replace the current selection with an external selection.

Public function

void

 

SetShouldAddToSelectionFunc

(
    TFunction< bool)> Func
)

By default, the shift key will cause new clicks to add to the selection.

Public function

void

 

SetShouldRemoveFromSelectionFunc

(
    TFunction< bool)> Func
)

By default, the Ctrl key will cause new clicks to remove from the existing selection.

Public function

void

 

SetShouldSelectEdgeLoopsFunc

(
    TFunction< bool)> Func
)

Public function

void

 

SetShouldSelectEdgeRingsFunc

(
    TFunction< bool)> Func
)

Public function

bool

 

TopologyHitTest

(
    const FRay& WorldRay,
    FHitResult& OutHit,
    bool bUseOrthoSettings
)

Perform a hit test on the topology using the current selection settings.

Public function

bool

 

TopologyHitTest

(
    const FRay& WorldRay,
    FHitResult& OutHit,
    FGroupTopologySelection& OutSelect...,
    bool bUseOrthoSettings
)

Perform a hit test on the topology using the current selection settings.

Public function

bool

 

UpdateHighlight

(
    const FRay& WorldRay
)

Hover API Update the hover highlight based on the hit elements at the given World Ray

Protected function Virtual

void

 

UpdateMarqueeEnabled()

Public function

bool

 

UpdateSelection

(
    const FRay& WorldRay,
    FVector3d& LocalHitPositionOut,
    FVector3d& LocalHitNormalOut
)

Selection API Intersect the ray with the mesh and update the selection based on the hit element, modifier states, etc

Overridden from UInteractionMechanic

Name Description

Public function Virtual

void

 

Render

(
    IToolsContextRenderAPI* Render...
)

Allow the Mechanic to do any custom drawing (ie via PDI/RHI)

Public function Virtual

void

 

Setup

(
    UInteractiveTool* ParentTool
)

Called to initialize the InteractionMechanic

Public function Virtual

void

 

Shutdown()

Called to clean up the InteractionMechanic

Overridden from IClickBehaviorTarget

Name Description

Public function Virtual

FInputRayHit

 

IsHitByClick

(
    const FInputDeviceRay& ClickPos
)

IClickBehaviorTarget implementation.

Public function Virtual

void

 

OnClicked

(
    const FInputDeviceRay& ClickPos
)

Notify Target that click ocurred

Overridden from IModifierToggleBehaviorTarget

Name Description

Public function Virtual

void

 

OnUpdateModifierState

(
    int ModifierID,
    bool bIsOn
)

Notify target of current modifier state

Overridden from IHoverBehaviorTarget

Name Description

Public function Virtual

FInputRayHit

 

BeginHoverSequenceHitTest

(
    const FInputDeviceRay& PressPos
)

IHoverBehaviorTarget implementation.

Public function Virtual

void

 

OnBeginHover

(
    const FInputDeviceRay& DevicePos
)

Initialize hover sequence at given position

Public function Virtual

void

 

OnEndHover()

Terminate active hover sequence

Public function Virtual

bool

 

OnUpdateHover

(
    const FInputDeviceRay& DevicePos
)

Update active hover sequence with new input position

Typedefs

Constants

Name

Description

CtrlModifierID

ShiftModifierID