UCurveControlPointsMechanic

A mechanic for displaying a sequence of control points and moving them about.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

ModelingComponents

Header

/Engine/Plugins/Experimental/MeshModelingToolset/Source/ModelingComponents/Public/Mechanics/CurveControlPointsMechanic.h

Include

#include "Mechanics/CurveControlPointsMechanic.h"

Syntax

[UCLASS](Programming/UnrealArchitecture/Reference/Classes#classdeclaration)()
class UCurveControlPointsMechanic :
    public UInteractionMechanic,
    public IClickBehaviorTarget,
    public IHoverBehaviorTarget

Remarks

A mechanic for displaying a sequence of control points and moving them about. Has an interactive initialization mode for first setting the points.

When editing, hold shift to select multiple points. Hold Ctrl to add an extra point along an edge. To add points to either end of the sequence, first select either the first or last point and then hold Ctrl. Backspace deletes currently selected points. In edit mode, holding Shift generally toggles the snapping behavior (makes it opposite of the current SnappingEnabled setting), though this is not yet implemented while the gizmo is being dragged.

TODO:

  • Make it possible to open/close loop in edit mode

  • Improve display of occluded control points (checkerboard the material)

  • Allow deselection of vertices by clicking away?

  • Lump the point/line set components into PreviewGeometryActor.

Variables

Name Description

Protected variable

bool

 

bAddToSelectionToggle

Support for Shift and Ctrl toggles.

Protected variable

bool

 

bAutoRevertToInteractiveInitialization

Protected variable

bool

 

bGizmoBeingDragged

Used to make it easy to tell whether the gizmo was moved by the user or by undo/redo or some other change that we shoulnd't respond to.

Protected variable

bool

 

bInsertPointToggle

Protected variable

bool

 

bInteractiveInitializationMode

Protected variable

bool

 

bIsLoop

Protected variable

bool

 

bSnappingEnabled

Protected variable

bool

 

bSnapToggle

Protected variable

FViewCameraStat...

 

CameraState

Support for hovering.

Public variable UProperty

USingleClickInp...

 

ClickBehavior

Behaviors used for moving points around and hovering them.

Protected variable

FOrderedPoints

 

ControlPoints

This actually stores the sequence of point IDs, and their coordinates.

Protected variable

int32

 

CtrlModifierId

Protected variable

int32

 

CurrentChangeStamp

Used for expiring undo/redo changes, which compare this to their stored value and expire themselves if they do not match.

Protected variable

FColor

 

CurrentPointsColor

Protected variable

FColor

 

CurrentSegmentsColor

Protected variable

float

 

DepthBias

Protected variable UProperty

UPointSetCompon...

 

DrawnControlPoints

Protected variable UProperty

ULineSetCompone...

 

DrawnControlSegments

Protected variable

FFrame3d

 

DrawPlane

Used for adding new points on the ends and for limiting point movement.

Protected variable

int32

 

EndpointSnapPriority

Protected variable

int32

 

FirstPointSnapID

Used for snapping to the start/end of the curve to get out of initialization mode.

Protected variable

FGeometrySet3

 

GeometrySet

Used for spatial queries.

Protected variable

TFunction< bool...

 

GeometrySetToleranceTest

Protected variable

FVector

 

GizmoStartPosition

The starting point of the gizmo is needed to determine the offset by which to move the points.

Public variable UProperty

UMouseHoverBeha...

 

HoverBehavior

Protected variable

FColor

 

HoverColor

Protected variable

int32

 

HoveredPointID

Protected variable

FColor

 

InitializationCurveColor

Variables for drawing.

Protected variable

int32

 

LastPointSnapID

Protected variable

int32

 

LineSnapIDMin

When storing user-defined lines to snap to, we add this to the user-provided id to avoid conflicting with any lines generated by the snap engine.

Protected variable

int32

 

LineSnapPriority

Protected variable

int32

 

MinPointsForLoop

Protected variable

int32

 

MinPointsForNonLoop

Protected variable

FColor

 

NormalCurveColor

Public variable

OnModeChangedEv...

 

OnModeChanged

Public variable

OnPointsChanged...

 

OnPointsChanged

Protected variable

float

 

PointsSize

Protected variable UProperty

UTransformGizmo...

 

PointTransformGizmo

Protected variable UProperty

UTransformProxy...

 

PointTransformProxy

Support for gizmo.

Protected variable

FColor

 

PreHoverPointColor

Used to unhover a point, since this will differ depending on whether the point is selected.

Protected variable

FColor

 

PreviewColor

Protected variable UProperty

APreviewGeometr...

 

PreviewGeometryActor

Used for displaying points/segments

Protected variable UProperty

UPointSetCompon...

 

PreviewPoint

These get drawn separately because the other components have to be 1:1 with the control points structure, which would make it complicated to keep track of special id's.

Protected variable UProperty

ULineSetCompone...

 

PreviewSegment

Protected variable

float

 

SegmentsThickness

Protected variable

FColor

 

SelectedColor

Protected variable

TArray< int32 >

 

SelectedPointIDs

Support for selection.

Protected variable

TArray< FVector...

 

SelectedPointStartPositions

We need the selected point start positions so we can move multiple points appropriately.

Protected variable

int32

 

ShiftModifierId

Protected variable

FPointPlanarSna...

 

SnapEngine

Protected variable

FColor

 

SnapLineColor

Destructors

Name Description

Public function Virtual

~UCurveControlPointsMechanic()

Some other standard functions.

Functions

Name Description

Public function

void

 

AddSnapLine

(
    int32 LineID,
    const FLine3d& Line
)

Adds additional line to snap points to.

Public function

int32

 

AppendPoint

(
    const FVector3d& PointCoordinates
)

Protected function

void

 

ChangeSelection

(
    int32 NewPointID,
    bool AddToSelection
)

These issue undo/redo change objects, and must therefore not be called in undo/redo code.

Protected function

void

 

ClearHover()

Public function

void

 

ClearPoints()

Clears all points in the mechanic.

Protected function

void

 

ClearSelection()

Protected function

int32

 

DeletePoint

(
    int32 SequencePosition
)

Public function

void

 

DeleteSelectedPoints()

Deletes currently selected points- can be called on a key press from the parent tool.

Protected function

bool

 

DeselectPoint

(
    int32 PointID
)

Public function

void

 

ExpireChanges()

Expires any changes currently associated with the mechanic in the undo/redo stack.

Public function

void

 

ExtractPointPositions

(
    TArray< FVector3d >& PositionsOut
)

Outputs the positions of the points in the control point sequence.

Public function

bool

 

GetIsLoop()

Returns whether the underlying sequence of control points is a loop.

Public function

int32

 

GetNumPoints()

Gives number of points currently managed by the mechanic.

Protected function

void

 

GizmoTransformChanged

(
    UTransformProxy* Proxy,
    FTransform Transform
)

Callbacks we'll receive from the gizmo proxy.

Protected function

void

 

GizmoTransformEnded

(
    UTransformProxy* Proxy
)

Protected function

void

 

GizmoTransformStarted

(
    UTransformProxy* Proxy
)

Protected function

bool

 

HitTest

(
    const FInputDeviceRay& ClickPos,
    FInputRayHit& ResultOut
)

Public function Virtual

void

 

Initialize

(
    const TArray< FVector3d >& Points,
    bool bIsLoop
)

Functions used for initializing the mechanic.

Protected function

int32

 

InsertPointAt

(
    int32 SequencePosition,
    const FVector3d& NewPointCoordinat...,
    const int32* KnownPointID
)

All of the following do not issue undo/redo change objects.

Public function

bool

 

IsInInteractiveIntialization()

Public function

void

 

RemoveSnapLine

(
    int32 LineID
)

Protected function

void

 

SelectPoint

(
    int32 PointID
)

Public function

void

 

SetAutoRevertToInteractiveInitialization

(
    bool bOn
)

When true, if the number of control points falls below the mins required (through deletion by the user), the mechanic automatically falls back into interactive intialization mode.

Public function

void

 

SetInteractiveInitialization

(
    bool bOn
)

Interactive initialization mode allows the user to click multiple times to initialize the curve (without having to hold Ctrl), and to transition to edit mode by clicking the last or first points (provided the minimal numbers of points have been met)

Public function

void

 

SetIsLoop

(
    bool bIsLoop
)

Public function

void

 

SetMinPointsToLeaveInteractiveInitialization

(
    int32 MinForLoop,
    int32 MinForNonLoop
)

In interactive intialization mode, these minimums determine how many points must exist before initialization mode can be left.

Public function

void

 

SetPlane

(
    const FFrame3d& DrawPlaneIn
)

Sets the plane on which new points are added on the ends and in which the points are moved.

Public function

void

 

SetSnappingEnabled

(
    bool bOn
)

TODO: It is simple to allow the points to be moved arbitrarily, not just inside the plane, if we ever want to use the mechanic somewhere where that is desirable.

Public function

void

 

SetWorld

(
    UWorld* World
)

Protected function

void

 

UpdateGizmoLocation()

Protected function

void

 

UpdateGizmoVisibility()

Protected function

void

 

UpdatePointLocation

(
    int32 PointID,
    const FVector3d& NewLocation
)

Protected function

void

 

UpdateSnapHistoryPoint

(
    int32 Index,
    FVector3d NewPosition
)

Protected function

void

 

UpdateSnapTargetsForHover()

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
)

IModifierToggleBehaviorTarget implementation, inherited through IClickBehaviorTarget.

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

Classes

Name

Description

Protected class

FOrderedPoints

We want some way to store the control point sequence that lets us easily associate points with their renderable and hit-testable representations, since we need to alter all of these together as points get moved or added.

Typedefs

Name

Description

OnModeChangedEvent

This delegate is called when the mode of the mechanic changes (i.e., we leave or re-enter interactive initialization)

OnPointsChangedEvent

This delegate is called every time the control point sequence is altered.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss