UDrawPolygonTool

This tool allows the user to draw and extrude 2D polygons

Choose your operating system:

Windows

macOS

Linux

Inheritance Hierarchy

References

Module

MeshModelingTools

Header

/Engine/Plugins/Runtime/MeshModelingToolset/Source/MeshModelingTools/Public/DrawPolygonTool.h

Include

#include "DrawPolygonTool.h"

Syntax

UCLASS()
class UDrawPolygonTool :
    public UInteractiveTool,
    public IClickSequenceBehaviorTarget

Remarks

This tool allows the user to draw and extrude 2D polygons

Variables

Name Description

Protected variable

bool

 

bAbortActivePolygonDraw

Protected variable

bool

 

bHasSavedExtrudeHeight

Protected variable

bool

 

bHaveSelfIntersection

Protected variable

bool

 

bHaveSurfaceHit

Only used when SnapSettings.bSnapToSurfaces = true

Protected variable

bool

 

bIgnoreSnappingToggle

Protected variable

bool

 

bInFixedPolygonMode

Protected variable

bool

 

bInInteractiveExtrude

Protected variable

bool

 

bPreviewUpdatePending

Protected variable

FViewCameraStat...

 

CameraState

Protected variable

int32

 

CurrentCurveTimestamp

Protected variable

UE::Geometry::F...

 

DrawPlaneOrientation

Orientation of plane we will draw polygon on

Protected variable

FVector3d

 

DrawPlaneOrigin

Origin of plane we will draw polygon on

Protected variable

TArray< FVector...

 

FixedPolygonClickPoints

Protected variable UProperty

TObjectPtr< UPl...

 

HeightMechanic

Protected variable

UE::Geometry::F...

 

HitPosFrameWorld

Protected variable

FVector3d

 

LastGridSnapPoint

Protected variable

ToolSceneQuerie...

 

LastSnapGeometry

Protected variable UProperty

TObjectPtr< UNe...

 

MaterialProperties

Protected variable UProperty

TObjectPtr< UCr...

 

OutputTypeProperties

Property set for type of output object (StaticMesh, Volume, etc)

Protected variable UProperty

TObjectPtr< UCo...

 

PlaneTransformGizmo

Protected variable UProperty

TObjectPtr< UTr...

 

PlaneTransformProxy

Protected variable

TArray< TArray<...

 

PolygonHolesVertices

Vertices of holes in current preview polygon

Protected variable UProperty

TObjectPtr< UDr...

 

PolygonProperties

Properties that control polygon generation exposed to user via details view

Protected variable

TArray< FVector...

 

PolygonVertices

Vertices of current preview polygon

Protected variable UProperty

TObjectPtr< UPr...

 

PreviewMesh

Protected variable

FVector3d

 

PreviewVertex

Last vertex of polygon that is actively being updated as input device is moved

Protected variable

float

 

SavedExtrudeHeight

Protected variable

FVector3d

 

SelfIntersectionPoint

Protected variable

int

 

SelfIntersectSegmentIdx

Protected variable

IClickBehaviorT...

 

SetPointInWorldConnector

Calls SetDrawPlaneFromWorldPos when user ctrl+clicks on scene

Protected variable

UE::Geometry::F...

 

SnapEngine

Protected variable UProperty

TObjectPtr< UDr...

 

SnapProperties

Protected variable

FVector3d

 

SurfaceHitPoint

Protected variable

FVector3d

 

SurfaceOffsetPoint

Protected variable

UWorld *

 

TargetWorld

Constructors

Name Description

Public function

UDrawPolygonTool()

Functions

Name Description

Protected function

bool

 

AllowDrawPlaneUpdates()

Whether to allow the draw plane to be updated in the UI returns false if there is an in-progress shape relying on the current draw plane

Public function Virtual

void

 

AppendVertex

(
    const FVector3d& Vertex
)

Public function Virtual

void

 

ApplyUndoPoints

(
    const TArray< FVector3d >& ClickPo...,
    const TArray< FVector3d >& Polygon...
)

Public function Virtual

void

 

BeginInteractiveExtrude()

Protected function Const

bool

 

CheckInCurve

(
    int32 Timestamp
)

Public function Virtual

void

 

EmitCurrentPolygon()

Public function Virtual

void

 

EndInteractiveExtrude()

Public function Virtual

bool

 

FindDrawPlaneHitPoint

(
    const FInputDeviceRay& ClickPos,
    FVector3d& HitPosOut
)

Protected function

void

 

GenerateFixedPolygon

(
    const TArray< FVector3d >& FixedPo...,
    TArray< FVector3d >& VerticesOut,
    TArray< TArray< FVector3d >>& Hole...
)

Protected function

bool

 

GeneratePolygonMesh

(
    const TArray< FVector3d >& Polygon,
    const TArray< TArray< FVector3d >> ...,
    FDynamicMesh3* ResultMeshOut,
    UE::Geometry::FFrame3d& WorldFrame...,
    bool bIncludePreviewVtx,
    double ExtrudeDistance,
    bool bExtrudeSymmetric
)

Generate extruded meshes. Returns true on success.

Protected function

void

 

GetPolygonParametersFromFixedPoints

(
    const TArray< FVector3d >& FixedPo...,
    FVector2d& FirstReferencePt,
    FVector2d& BoxSize,
    double& YSign,
    double& AngleRad
)

Protected function

void

 

PlaneTransformChanged

(
    UTransformProxy* Proxy,
    FTransform Transform
)

Called on PlaneTransformProxy.OnTransformChanged

Public function Virtual

void

 

ResetPolygon()

Polygon drawing functions

Protected function Virtual

void

 

SetDrawPlaneFromWorldPos

(
    const FVector3d& Position,
    const FVector3d& Normal
)

Updates plane and gizmo position

Public function Virtual

void

 

SetWorld

(
    UWorld* World
)

Protected function

void

 

ShowExtrudeMessage()

Protected function

void

 

ShowStartupMessage()

User feedback messages

Protected function

void

 

UndoCurrentOperation

(
    const TArray< FVector3d >& ClickPo...,
    const TArray< FVector3d >& Polygon...
)

Protected function

void

 

UpdateLivePreview()

Public function Virtual

void

 

UpdatePreviewVertex

(
    const FVector3d& PreviewVertex
)

Protected function

bool

 

UpdateSelfIntersection()

Can close poly if current segment intersects existing segment

Protected function

void

 

UpdateShowGizmoState

(
    bool bNewVisibility
)

Overridden from UInteractiveTool

Name Description

Public function Virtual Const

bool

 

CanAccept()

Public function Virtual Const

bool

 

HasAccept()

Public function Virtual Const

bool

 

HasCancel()

Public function Virtual

void

 

OnTick

(
    float DeltaTime
)

Action support/system

Public function Virtual

void

 

RegisterActions

(
    FInteractiveToolActionSet& ActionS...
)

Override this function to register the set of Actions this Tool supports, using FInteractiveToolActionSet::RegisterAction.

Public function Virtual

void

 

Render

(
    IToolsContextRenderAPI* Render...
)

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

Public function Virtual

void

 

Setup()

Called by ToolManager to initialize the Tool after ToolBuilder::BuildTool() has been called

Public function Virtual

void

 

Shutdown

(
    EToolShutdownType ShutdownType
)

Called by ToolManager to shut down the Tool

Overridden from IClickSequenceBehaviorTarget

Name Description

Public function Virtual

bool

 

CanBeginClickSequence

(
    const FInputDeviceRay& ClickPos
)

Test if target would like to begin sequence based on this click.

Public function Virtual

void

 

OnBeginClickSequence

(
    const FInputDeviceRay& ClickPos
)

Notify Target about the first click in the sequence.

Public function Virtual

void

 

OnBeginSequencePreview

(
    const FInputDeviceRay& ClickPos
)

Notify Target device position has changed but a click sequence hasn't begun yet (eg for interactive previews)

Public function Virtual

bool

 

OnNextSequenceClick

(
    const FInputDeviceRay& ClickPos
)

Notify Target about next click in sqeuence

Public function Virtual

void

 

OnNextSequencePreview

(
    const FInputDeviceRay& ClickPos
)

Notify Target device position has changed but a click hasn't ocurred yet (eg for interactive previews)

Public function Virtual

void

 

OnTerminateClickSequence()

Notify Target that click sequence has been explicitly terminated (eg by escape key, cancel tool, etc).

Public function Virtual

bool

 

RequestAbortClickSequence()

Target overrides this and returns true if it wants to abort click sequence.

Overridden from IModifierToggleBehaviorTarget

Name Description

Public function Virtual

void

 

OnUpdateModifierState

(
    int ModifierID,
    bool bIsOn
)

Notify target of current modifier state

Constants

Name

Description

AngleSnapModifier

IgnoreSnappingModifier

Flags used to identify modifier keys/buttons