Navigation
API > API/Plugins > API/Plugins/ModelingComponents
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- UPreviewMesh
- UPolyEditPreviewMesh
References
| Module | ModelingComponents |
| Header | /Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Public/PreviewMesh.h |
| Include | #include "PreviewMesh.h" |
Syntax
UCLASS&40;Transient&41;
class UPreviewMesh :
public UObject,
public IMeshVertexCommandChangeTarget,
public IMeshCommandChangeTarget,
public IMeshReplacementCommandChangeTarget
Remarks
UPreviewMesh is a utility object that spawns and owns a transient mesh object in the World. This can be used to show live preview geometry during modeling operations. Call CreateInWorld() to set it up, and Disconnect() to shut it down.
Currently implemented via an internal Actor that has a UDynamicMeshComponent root component, with an AABBTree created/updated if FProperty bBuildSpatialDataStructure=true. The Actor is destroyed on Disconnect().
The intention with UPreviewMesh is to provide a higher-level interface than the Component. In future the internal Component may be replaced with another class (eg OctreeDynamicMeshComponent), or automatically swap between the two, etc.
As a result direct access to the Actor/Component, or a non-const FDynamicMesh3, is intentionally not provided. Wrapper functions are provided (or should be added) for necessary Actor/Component parameters. To edit the mesh either a copy is done, or EditMesh()/ApplyChange() must be used. These functions automatically update necessary internal data structures.
Variables
| Type | Name | Description | |
|---|---|---|---|
| bool | bBuildSpatialDataStructure | If true, we build a spatial data structure internally for the preview mesh, which allows for hit-testing | |
| bool | bDecompositionEnabled | If true, mesh will be chunked into multiple render buffers inside the DynamicMeshComponent | |
| TObjectPtr< UDynamicMeshComponent > | DynamicMeshComponent | This component is set as the root component of TemporaryParentActor | |
| UE::Geometry::FDynamicMeshAABBTree3 | MeshAABBTree | Spatial data structure that is initialized if bBuildSpatialDataStructure = true when UpdatePreview() is called | |
| APreviewMeshActor * | TemporaryParentActor | The temporary actor we create internally to own the preview mesh component |
Constructors
| Type | Name | Description | |
|---|---|---|---|
UPreviewMesh () |
Destructors
| Type | Name | Description | |
|---|---|---|---|
Functions
| Type | Name | Description | |
|---|---|---|---|
| bool | Calculate tangents for the underlying component. | ||
| void | Clear the override material for the preview mesh. | ||
| void | ClearPreview () |
Read access to internal mesh Clear the preview mesh | |
| void | Clear the secondary material for the preview mesh. | ||
| void | ClearTriangleColorFunction
(
ERenderUpdateMode UpdateMode |
Clear the triangle color function for rendering / render data construction | |
| void | CreateInWorld
(
UWorld* World, |
Construction / destruction Create preview mesh in the World with the given transform | |
| void | DeferredEditMesh
(
TFunctionRef< void(FDynamicMesh3&)> EditFunc, |
Apply EditFunc to the internal mesh, and update spatial data structure if requested, but do not update/rebuild rendering data structures. | |
| void | Disable secondary triangle buffers | ||
| void | Disconnect () |
Remove and destroy preview mesh | |
| void | EditMesh
(
TFunctionRef< void(FDynamicMesh3&)> EditFunc |
Apply EditFunc to the internal mesh and update internal data structures as necessary | |
| void | EnableSecondaryTriangleBuffers
(
TUniqueFunction< bool(const FDynamicMesh3*, int32)> TriangleFilterFunc |
Enable secondary triangle buffers. | |
| void | EnableWireframe
(
bool bEnable |
Visualization parameters Enable/disable wireframe overlay rendering | |
| TUniquePtr< FDynamicMesh3 > | |||
| void | Call this after updating the secondary triangle sorting. | ||
| FVector3d | FindNearestPoint
(
const FVector3d& WorldPoint, |
Find nearest point on current mesh to given WorldPoint Requires that bBuildSpatialDataStructure = true unless bLinearSearch = true | |
| bool | FindRayIntersection
(
const FRay3d& WorldRay, |
Find ray intersection with the preview mesh. | |
| void | Force rebuild of internal spatial data structure. | ||
| UMaterialInterface * | GetActiveMaterial
(
int MaterialIndex |
||
| AActor * | GetActor () |
||
| bool | |||
| UMaterialInterface * | GetMaterial
(
int MaterialIndex |
Get material from the preview mesh | |
| void | GetMaterials
(
TArray< UMaterialInterface* >& OutMaterials |
Get the entire materials array from the preview mesh. Appends to OutMaterials without clearing it. | |
| const FDynamicMesh3 * | GetMesh () |
Read access to the internal mesh. | |
| int32 | Get number of materials in the preview mesh (base materials, i.e., not including override material) | ||
| FSimpleMulticastDelegate & | |||
| const FDynamicMesh3 * | |||
| UPrimitiveComponent * | |||
| UE::Geometry::FDynamicMeshAABBTree3 * | GetSpatial () |
This has to return non-const because of current FDynamicMeshAABBTree3 API, but you should not modify this! | |
| FTransform | GetTransform () |
Get the current transform on the preview mesh | |
| bool | IsVisible () |
||
| void | NotifyDeferredEditCompleted
(
ERenderUpdateMode UpdateMode, |
Notify that a DeferredEditMesh sequence is complete and cause update of rendering data structures. | |
| void | NotifyRegionDeferredEditCompleted
(
const TArray< int32 >& Triangles, |
Notify that a deferred edit is completed and cause update of rendering data structures for modified Triangles. | |
| void | NotifyRegionDeferredEditCompleted
(
const TSet< int32 >& Triangles, |
Notify that a deferred edit is completed and cause update of rendering data structures for modified Triangles. | |
| void | This function is called internally on some changes, to let the path tracer know that this mesha/actor has been modified in a way that will require invalidating the current path tracing result | ||
| void | ProcessMesh
(
TFunctionRef< void(const UE::Geometry::FDynamicMesh3&)> ProcessFunc |
Give external code direct read access to the internal FDynamicMesh3. | |
| void | ReplaceMesh
(
FDynamicMesh3&& NewMesh |
Replace mesh with new mesh | |
| void | ReplaceMesh
(
const FDynamicMesh3& NewMesh |
Edit access to internal mesh, and change-tracking/notification Replace mesh with new mesh | |
| void | SetEnableRenderMeshDecomposition
(
bool bEnable |
Enable automatically-computed decomposition of internal mesh into subregions when rendering (ie inside the Component). | |
| void | SetMaterial
(
int MaterialIndex, |
Set material on the preview mesh | |
| void | SetMaterial
(
UMaterialInterface* Material |
Set material on the preview mesh | |
| void | SetMaterials
(
const TArray< UMaterialInterface* >& Materials |
Set the entire material set on the preview mesh | |
| void | SetOverrideRenderMaterial
(
UMaterialInterface* Material |
Set an override material for the preview mesh. This material will override all the given materials. | |
| void | SetSecondaryBuffersVisibility
(
bool bSecondaryVisibility |
Show/Hide the secondary triangle buffers. | |
| void | SetSecondaryRenderMaterial
(
UMaterialInterface* Material |
Set an secondary material for the preview mesh. | |
| void | SetShadowsEnabled
(
bool bEnable |
Enable/disable shadow rendering | |
| void | SetTangentsMode
(
EDynamicMeshComponentTangentsMode TangentsType |
Set the tangents mode for the underlying component, if available. | |
| void | SetTransform
(
const FTransform& UseTransform |
Set the transform on the preview mesh | |
| void | SetTriangleColorFunction
(
TFunction< FColor(const FDynamicMesh3*, int)> TriangleColorFunc, |
Set the triangle color function for rendering / render data construction | |
| void | SetVisible
(
bool bVisible |
Set visibility state of the preview mesh | |
| bool | TestRayIntersection
(
const FRay3d& WorldRay |
Queries Test for ray intersection with the preview mesh. | |
| TUniquePtr< FMeshChange > | TrackedEditMesh
(
TFunctionRef< void(FDynamicMesh3&, UE::Geometry::FDynamicMeshChangeTracker&)> EditFunc |
Apply EditFunc to the internal mesh and update internal data structures as necessary. | |
| void | UpdatePreview
(
const FDynamicMesh3* Mesh, |
Update the internal mesh by copying the given Mesh | |
| void | UpdatePreview
(
FDynamicMesh3&& Mesh, |
Update the internal mesh by moving in the given Mesh | |
| void | Update chunk decomposition |
Overridden from IMeshVertexCommandChangeTarget
| Type | Name | Description | |
|---|---|---|---|
| void | ApplyChange
(
const FMeshVertexChange* Change, |
Apply/Revert a vertex deformation change to the internal mesh (implements IMeshVertexCommandChangeTarget) |
Overridden from IMeshCommandChangeTarget
| Type | Name | Description | |
|---|---|---|---|
| void | ApplyChange
(
const FMeshChange* Change, |
Apply/Revert a general mesh change to the internal mesh (implements IMeshCommandChangeTarget) |
Overridden from IMeshReplacementCommandChangeTarget
| Type | Name | Description | |
|---|---|---|---|
| void | ApplyChange
(
const FMeshReplacementChange* Change, |
Apply/Revert a general mesh change to the internal mesh (implements IMeshReplacementCommandChangeTarget) |
Enums
| Type | Name | Description | |
|---|---|---|---|
| ERenderUpdateMode | Render data update hint (values mirror EDynamicMeshComponentRenderUpdateMode) |