UDynamicMeshComponent

[UDynamicMeshComponent](API\Runtime\GeometryFramework\Components\UDynamicMeshComponent) is a mesh component similar to [UProceduralMeshComponent](API\Plugins\ProceduralMeshComponent\UProceduralMeshComponent), except it bases the renderable geometry off an internal [UDynamicMesh](API\Runtime\GeometryFramework\UDynamicMesh) instance (which encapsulates a FDynamicMesh3).

Choose your operating system:

Windows

macOS

Linux

Inheritance Hierarchy

References

Module

GeometryFramework

Header

/Engine/Source/Runtime/GeometryFramework/Public/Components/DynamicMeshComponent.h

Include

#include "Components/DynamicMeshComponent.h"

Syntax

class UDynamicMeshComponent :
    public UBaseDynamicMeshComponent,
    public IInterface_CollisionDataProvider

Remarks

UDynamicMeshComponent is a mesh component similar to UProceduralMeshComponent, except it bases the renderable geometry off an internal UDynamicMesh instance (which encapsulates a FDynamicMesh3).

There is extensive support for partial updates to render buffers, customizing colors, internally decomposing the mesh into separate chunks for more efficient render updates, and support for attaching a 'Postprocessor' to generate a render mesh on-the-fly See comment sections below for details.

Variables

Name Description

Protected variable

UE::Geometry::F...

 

AutoCalculatedTangents

Set of per-triangle-vertex tangents computed for the current mesh.

Protected variable

bool

 

bAutoCalculatedTangentsValid

True if AutoCalculatedTangents has been computed for current mesh

Protected variable

bool

 

bCollisionUpdatePending

Public variable

bool

 

bDeferCollisionUpdates

If true, updates to the mesh will not result in immediate collision regeneration.

Public variable

bool

 

bEnableComplexCollision

If true, current mesh will be used as Complex Collision source mesh.

Protected variable

bool

 

bInvalidateProxyOnChange

If false, we don't completely invalidate the RenderProxy when ApplyChange() is called (assumption is it will be handled elsewhere)

Protected variable

bool

 

bProxyValid

If the render proxy is invalidated (eg by MarkRenderStateDirty()), it will be destroyed at the end of the frame, but the base SceneProxy pointer is not nulled out immediately.

Public variable

TEnumAsByte< en...

 

CollisionType

Type of Collision Geometry to use for this Mesh

Protected variable

TUniquePtr< FMe...

 

Decomposition

Protected variable

UE::Geometry::F...

 

LocalBounds

Standard Component internals, for computing bounds and managing the SceneProxyCurrent local-space bounding box of Mesh

Protected variable

TObjectPtr< UBo...

 

MeshBodySetup

Protected variable

TObjectPtr< UDy...

 

MeshObject

Internal FDynamicMesh is stored inside a UDynamicMesh container, which allows it to be used from BP, shared with other UObjects, and so on

Protected variable

FDelegateHandle

 

MeshObjectChangedHandle

Handle for OnMeshObjectChanged which is registered with MeshObject::OnMeshChanged delegate

Public variable

FComponentChild...

 

OnChildAttachmentModified

The OnChildAttached() and OnChildDetached() implementations (from USceneComponent API) broadcast this delegate.

Public variable

FSimpleMulticas...

 

OnMeshChanged

This delegate fires when the mesh has been changed

Public variable

FMeshVerticesMo...

 

OnMeshVerticesChanged

Protected variable

TUniquePtr< FDy...

 

RenderMesh

Protected variable

TUniquePtr< IRe...

 

RenderMeshPostProcessor

Protected variable

TUniqueFunction...

 

SecondaryTriFilterFunc

Protected variable

EDynamicMeshCom...

 

TangentsType

How should Tangents be calculated/handled

Protected variable

TUniqueFunction...

 

TriangleColorFunc

If this function is set, we will use these colors instead of vertex colors

Constructors

Name Description

Public function

UDynamicMeshComponent

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function Virtual

void

 

ClearTriangleColorFunction

Clear an active triangle color function if one exists, and update the mesh

Public function

void

 

ConfigureMaterialSet

(
    const TArray< UMaterialInterface&#...
)

Material Set API. DynamicMeshComponent supports changing the Material Set dynamically, even at Runtime.

Public function Virtual

void

 

DisableSecondaryTriangleBuffers()

Disable secondary triangle buffers. This invalidates the SceneProxy.

Public function Virtual

void

 

EditMesh

Allow external code to to edit the internal mesh.

Public function

void

 

EnableComplexAsSimpleCollision()

Physics APIs calls SetComplexAsSimpleCollisionEnabled(true, true)

Public function Virtual

void

 

EnableSecondaryTriangleBuffers

(
    TUniqueFunction< bool...
)

Support for Secondary triangle index buffers.

Public function

void

 

FastNotifyColorsUpdated()

Call this instead of NotifyMeshUpdated() if you have only updated the vertex colors (or triangle color function).

Public function

void

 

FastNotifyPositionsUpdated

(
    bool bNormals,
    bool bColors,
    bool bUVs
)

Call this instead of NotifyMeshUpdated() if you have only updated the vertex positions (and possibly some attributes).

Public function

void

 

FastNotifySecondaryTrianglesChanged()

Call this instead of NotifyMeshUpdated() if you have only updated secondary triangle sorting.

Public function

void

 

FastNotifyTriangleVerticesUpdated

(
    const TSet< int32 >& Triangles,
    EMeshRenderAttributeFlags UpdatedAt...
)

This function updates vertex positions/attributes of existing SceneProxy render buffers if possible, for the given triangles.

Public function

void

 

FastNotifyTriangleVerticesUpdated

(
    const TArray< int32 >& Triangles,
    EMeshRenderAttributeFlags UpdatedAt...
)

This function updates vertex positions/attributes of existing SceneProxy render buffers if possible, for the given triangles.

Public function

void

 

FastNotifyTriangleVerticesUpdated_ApplyPrecompute

(
    const TArray< int32 >& Triangles,
    EMeshRenderAttributeFlags UpdatedAt...,
    TFuture< bool >& Precompute,
    const TArray< int32 >& UpdateSets,
    const UE::Geometry::FAxisAlignedBox...
)

This function updates vertex positions/attributes of existing SceneProxy render buffers if possible, for the given triangles.

Public function

TFuture< boo...

 

FastNotifyTriangleVerticesUpdated_TryPrecompute

(
    const TArray< int32 >& Triangles,
    TArray< int32 >& UpdateSetsOut,
    UE::Geometry::FAxisAlignedBox3d& B...
)

If a Decomposition is set on this Component, and everything is currently valid (proxy/etc), precompute the set of buffers that will be modified, as well as the bounds of the modified region.

Public function

void

 

FastNotifyUVsUpdated()

Call this instead of NotifyMeshUpdated() if you have only updated the vertex uvs.

Public function

void

 

FastNotifyVertexAttributesUpdated

(
    EMeshRenderAttributeFlags UpdatedAt...
)

Call this instead of NotifyMeshUpdated() if you have only updated the vertex positions/attributes This function will update the existing RenderProxy buffers if possible, rather than create new ones.

Public function

void

 

FastNotifyVertexAttributesUpdated

(
    bool bNormals,
    bool bColors,
    bool bUVs
)

Call this instead of NotifyMeshUpdated() if you have only updated the vertex attributes (but not positions).

Public function

const UE::Ge...

 

GetAutoCalculatedTangents()

Public function Virtual Const

const UBodyS...

 

GetBodySetup()

Protected function

FDynamicMesh...

 

GetCurrentSceneProxy()

Public function Const

bool

 

GetInvalidateProxyOnChangeEnabled()

Public function Virtual Const

const FDynam...

 

GetRenderMesh()

The SceneProxy should call these functions to get the post-processed RenderMesh.

Public function Virtual

FDynamicMesh...

 

GetRenderMesh()

The SceneProxy should call these functions to get the post-processed RenderMesh.

Public function Const

EDynamicMesh...

 

GetTangentsType()

Protected function

FColor

 

GetTriangleColor

(
    const FDynamicMesh3* Mesh,
    int TriangleID
)

This function is passed via lambda to the RenderProxy to be able to access TriangleColorFunc

Public function Virtual

bool

 

HasTriangleColorFunction()

Public function Virtual

void

 

InvalidateAutoCalculatedTangents()

This function marks the auto tangents as dirty, they will be recomputed before they are used again

Protected function Virtual

void

 

InvalidatePhysicsData()

Protected function

void

 

OnMeshObjectChanged

(
    UDynamicMesh* ChangedMeshObjec...,
    FDynamicMeshChangeInfo ChangeInfo
)

Called whenever internal MeshObject is modified, fires OnMeshChanged and OnMeshVerticesChanged above

Protected function Virtual

void

 

RebuildPhysicsData()

Protected function

void

 

ResetProxy()

Fully invalidate all rendering data for this Component.

Public function Virtual

void

 

SetBodySetup

(
    UBodySetup* NewSetup
)

Public function

void

 

SetComplexAsSimpleCollisionEnabled

(
    bool bEnabled,
    bool bImmediateUpdate
)

If bEnabled=true, sets bEnableComplexCollision=true and CollisionType=CTF_UseComplexAsSimple If bEnabled=true, sets bEnableComplexCollision=false and CollisionType=CTF_UseDefault

Public function

void

 

SetDeferredCollisionUpdatesEnabled

(
    bool bEnabled,
    bool bImmediateUpdate
)

Set value of bDeferCollisionUpdates, when enabled, collision is not automatically recomputed each time the mesh changes.

Public function

void

 

SetDynamicMesh

(
    UDynamicMesh* NewMesh
)

Set the child UDynamicMesh.

Public function Virtual

void

 

SetExternalDecomposition

Support for a Render Decomposition, which is basically a segmentation of the mesh triangles into subsets which will be turned into separate RenderBuffers in the Render Proxy.

Public function

void

 

SetInvalidateProxyOnChangeEnabled

(
    bool bEnabled
)

When a FMeshChange or FMeshVertexChange is applied, by default we currently fully invalidate the render proxy.

Public function Virtual

void

 

SetRenderMeshPostProcessor

IRenderMeshPostProcessor Support.

Public function

void

 

SetTangentsType

Triangle-Vertex Tangents support.

Public function Virtual

void

 

SetTriangleColorFunction

Support for specifying per-triangle colors as vertex colors.

Protected function

void

 

UpdateAutoCalculatedTangents()

Public function Virtual

void

 

UpdateCollision

(
    bool bOnlyIfPending
)

Force an update of the Collision/Physics data for this Component.

Protected function

void

 

UpdateLocalBounds()

Recompute LocalBounds from the current Mesh

Public function

bool

 

ValidateMaterialSlots

(
    bool bCreateIfMissing,
    bool bDeleteExtraSlots
)

Compute the maximum MaterialID on the DynamicMesh, and ensure that Material Slots match.

Overridden from UBaseDynamicMeshComponent

Name Description

Public function Virtual

void

 

ApplyTransform

(
    const UE::Geometry::FTransform3d& ...,
    bool bInvert
)

Apply transform to internal mesh. In some cases this can be more efficient than a general edit.

Protected function Virtual

FBaseDynamic...

 

GetBaseSceneProxy()

Subclass must implement this to return scene proxy if available, or nullptr

Public function Virtual

UDynamicMesh...

 

GetDynamicMesh()

Public function Virtual Const

const FDynam...

 

GetMesh()

Avoid usage of this function, access via GetDynamicMesh() instead

Public function Virtual

FDynamicMesh...

 

GetMesh()

Mesh Access.

Protected function Virtual

void

 

NotifyMaterialSetUpdated()

This is called to tell our RenderProxy about modifications to the material set.

Public function Virtual

void

 

NotifyMeshUpdated()

RenderBuffer Update API.

Public function Virtual Const

void

 

ProcessMesh

(
    TFunctionRef< void...
)

Allow external code to read the internal mesh.

Public function Virtual

void

 

SetMesh

(
    UE::Geometry::FDynamicMesh3&& Move...
)

Initialize the internal mesh from a DynamicMesh

Overridden from UPrimitiveComponent

Name Description

Protected function Virtual

FPrimitiveSc...

 

CreateSceneProxy()

Creates a proxy to represent the primitive to the scene manager in the rendering thread.

Public function Virtual

UBodySetup &...

 

GetBodySetup()

Return the BodySetup to use for this PrimitiveComponent (single body case)

Overridden from USceneComponent

Name Description

Protected function Virtual Const

FBoxSphereBo...

 

CalcBounds

(
    const FTransform& LocalToWorld
)

Calculate the bounds of the component. Default behavior is a bounding box/sphere of zero size.

Protected function Virtual

void

 

OnChildAttached

(
    USceneComponent* ChildComponen...
)

Called after a child scene component is attached to this component.

Protected function Virtual

void

 

OnChildDetached

(
    USceneComponent* ChildComponen...
)

Called after a child scene component is detached from this component.

Overridden from UObject

Name Description

Protected function Virtual

void

 

PostEditChangeProperty

(
    FPropertyChangedEvent& PropertyCha...
)

Called when a property on this object has been modified externally

Protected function Virtual

void

 

PostLoad()

Do any object-specific cleanup required immediately after loading an object.

Overridden from IMeshVertexCommandChangeTarget

Name Description

Public function Virtual

void

 

ApplyChange

(
    const FMeshVertexChange* Chang...,
    bool bRevert
)

Change Support.

Overridden from IMeshCommandChangeTarget

Name Description

Public function Virtual

void

 

ApplyChange

(
    const FMeshChange* Change,
    bool bRevert
)

Apply a general mesh change to the mesh

Overridden from IMeshReplacementCommandChangeTarget

Name Description

Public function Virtual

void

 

ApplyChange

(
    const FMeshReplacementChange* ...,
    bool bRevert
)

Apply a mesh replacement change to mesh

Overridden from IInterface_CollisionDataProvider

Name Description

Public function Virtual Const

bool

 

ContainsPhysicsTriMeshData

(
    bool InUseAllTriData
)

Interface for checking if the implementing objects contains triangle mesh collision data

Public function Virtual

bool

 

GetPhysicsTriMeshData

(
    FTriMeshCollisionData* Collisi...,
    bool InUseAllTriData
)

Interface for retrieving triangle mesh collision data from the implementing object

Public function Virtual

bool

 

WantsNegXTriMesh()

Do we want to create a negative version of this mesh

Typedefs

Name

Description

FComponentChildrenChangedDelegate

Support for Component attachment change notifications via delegates.

FMeshVerticesModified

This delegate fires when the mesh vertices have been changed via an FMeshVertexChange