Navigation
API > API/Plugins > API/Plugins/ModelingComponents
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.
| Name | UPreviewMesh |
| Type | class |
| Header File | /Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Public/PreviewMesh.h |
| Include Path | #include "PreviewMesh.h" |
Syntax
UCLASS (MinimalAPI, Transient)
class UPreviewMesh :
public UObject ,
public IMeshVertexCommandChangeTarget ,
public IMeshCommandChangeTarget ,
public IMeshReplacementCommandChangeTarget
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → UPreviewMesh
Implements Interfaces
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
UPreviewMesh() |
PreviewMesh.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual ~UPreviewMesh() |
PreviewMesh.h |
Enums
Public
| Name | Remarks |
|---|---|
| ERenderUpdateMode | Render data update hint (values mirror EDynamicMeshComponentRenderUpdateMode) |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bBuildSpatialDataStructure | bool | If true, we build a spatial data structure internally for the preview mesh, which allows for hit-testing | PreviewMesh.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
bool CalculateTangents () |
Calculate tangents for the underlying component. | PreviewMesh.h | |
void ClearOverrideRenderMaterial() |
Clear the override material for the preview mesh. | PreviewMesh.h | |
void ClearOverrideSecondaryWireframeRenderMaterial() |
Clear the wireframe override material for the preview mesh. | PreviewMesh.h | |
void ClearOverrideWireframeRenderMaterial() |
Clear the wireframe override material for the preview mesh. | PreviewMesh.h | |
void ClearPreview() |
Read access to internal mesh Clear the preview mesh | PreviewMesh.h | |
void ClearSecondaryRenderMaterial() |
Clear the secondary material for the preview mesh. | PreviewMesh.h | |
void ClearTriangleColorFunction
(
ERenderUpdateMode UpdateMode |
Clear the triangle color function for rendering / render data construction | PreviewMesh.h | |
void CreateInWorld
(
UWorld* World, |
Construction / destruction Create preview mesh in the World with the given transform | PreviewMesh.h | |
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. | PreviewMesh.h | |
void DisableSecondaryTriangleBuffers() |
Disable secondary triangle buffers | PreviewMesh.h | |
void Disconnect() |
Remove and destroy preview mesh | PreviewMesh.h | |
void EditMesh
(
TFunctionRef< void(FDynamicMesh3&)> EditFunc |
Apply EditFunc to the internal mesh and update internal data structures as necessary | PreviewMesh.h | |
void EnableSecondaryTriangleBuffers
(
TUniqueFunction< bool(const FDynamicMesh3*, int32)> TriangleFilterFunc |
Enable secondary triangle buffers. | PreviewMesh.h | |
void EnableWireframe
(
bool bEnable |
Visualization parameters Enable/disable wireframe overlay rendering | PreviewMesh.h | |
TUniquePtr< FDynamicMesh3 > ExtractPreviewMesh() |
PreviewMesh.h | ||
| Call this after updating the secondary triangle sorting. | PreviewMesh.h | ||
FVector3d FindNearestPoint
(
const FVector3d& WorldPoint, |
Find nearest point on current mesh to given WorldPoint Requires that bBuildSpatialDataStructure = true unless bLinearSearch = true | PreviewMesh.h | |
bool FindRayIntersection
(
const FRay3d& WorldRay, |
Find ray intersection with the preview mesh. | PreviewMesh.h | |
void ForceRebuildSpatial () |
Force rebuild of internal spatial data structure. | PreviewMesh.h | |
UMaterialInterface * GetActiveMaterial
(
int MaterialIndex |
PreviewMesh.h | ||
AActor * GetActor() |
PreviewMesh.h | ||
bool GetIsRenderMeshDecompositionEnabled() |
PreviewMesh.h | ||
UMaterialInterface * GetMaterial
(
int MaterialIndex |
Get material from the preview mesh | PreviewMesh.h | |
void GetMaterials
(
TArray< UMaterialInterface* >& OutMaterials |
Get the entire materials array from the preview mesh. Appends to OutMaterials without clearing it. | PreviewMesh.h | |
const FDynamicMesh3 * GetMesh () |
Read access to the internal mesh. | PreviewMesh.h | |
int32 GetNumMaterials() |
Get number of materials in the preview mesh (base materials, i.e., not including override material) | PreviewMesh.h | |
FSimpleMulticastDelegate & GetOnMeshChanged() |
PreviewMesh.h | ||
const FDynamicMesh3 * GetPreviewDynamicMesh() |
PreviewMesh.h | ||
UPrimitiveComponent * GetRootComponent() |
PreviewMesh.h | ||
UE::Geometry::FDynamicMeshAABBTree3 * GetSpatial () |
This has to return non-const because of current FDynamicMeshAABBTree3 API, but you should not modify this! | PreviewMesh.h | |
FTransform GetTransform() |
Get the current transform on the preview mesh | PreviewMesh.h | |
bool IsVisible() |
PreviewMesh.h | ||
void NotifyDeferredEditCompleted
(
ERenderUpdateMode UpdateMode, |
Notify that a DeferredEditMesh sequence is complete and cause update of rendering data structures. | PreviewMesh.h | |
void NotifyRegionDeferredEditCompleted
(
const TSet< int32 >& Triangles, |
Notify that a deferred edit is completed and cause update of rendering data structures for modified Triangles. | PreviewMesh.h | |
void NotifyRegionDeferredEditCompleted
(
const TArray< int32 >& Triangles, |
Notify that a deferred edit is completed and cause update of rendering data structures for modified Triangles. | PreviewMesh.h | |
virtual void ProcessMesh
(
TFunctionRef< void(const UE::Geometry::FDynamicMesh3&)> ProcessFunc |
Give external code direct read access to the internal FDynamicMesh3. | PreviewMesh.h | |
void ReplaceMesh
(
FDynamicMesh3&& NewMesh |
Replace mesh with new mesh | PreviewMesh.h | |
void ReplaceMesh
(
const FDynamicMesh3& NewMesh |
Edit access to internal mesh, and change-tracking/notification Replace mesh with new mesh | PreviewMesh.h | |
virtual void SetEnableRenderMeshDecomposition
(
bool bEnable |
Enable automatically-computed decomposition of internal mesh into subregions when rendering (ie inside the Component). | PreviewMesh.h | |
void SetMaterial
(
int MaterialIndex, |
Set material on the preview mesh | PreviewMesh.h | |
void SetMaterial
(
UMaterialInterface* Material |
Set material on the preview mesh | PreviewMesh.h | |
void SetMaterials
(
const TArray< UMaterialInterface* >& Materials |
Set the entire material set on the preview mesh | PreviewMesh.h | |
void SetOverrideRenderMaterial
(
UMaterialInterface* Material |
Set an override material for the preview mesh. This material will override all the given materials. | PreviewMesh.h | |
void SetOverrideSecondaryWireframeRenderMaterial
(
UMaterialInterface* Material |
Set an override secondary wireframe material for the preview mesh. | PreviewMesh.h | |
void SetOverrideWireframeRenderMaterial
(
UMaterialInterface* Material |
Set a override wireframe material for the preview mesh. | PreviewMesh.h | |
void SetSecondaryBuffersVisibility
(
bool bSecondaryVisibility |
Show/Hide the secondary triangle buffers. | PreviewMesh.h | |
void SetSecondaryRenderMaterial
(
UMaterialInterface* Material |
Set an secondary material for the preview mesh. | PreviewMesh.h | |
void SetShadowsEnabled
(
bool bEnable |
Enable/disable shadow rendering | PreviewMesh.h | |
void SetTangentsMode
(
EDynamicMeshComponentTangentsMode TangentsType |
Set the tangents mode for the underlying component, if available. | PreviewMesh.h | |
void SetTransform
(
const FTransform& UseTransform |
Set the transform on the preview mesh | PreviewMesh.h | |
void SetTriangleColorFunction
(
TFunction< FColor(const FDynamicMesh3*, int)> TriangleColorFunc, |
Set the triangle color function for rendering / render data construction | PreviewMesh.h | |
void SetVisible
(
bool bVisible |
Set visibility state of the preview mesh | PreviewMesh.h | |
bool TestRayIntersection
(
const FRay3d& WorldRay, |
Queries Test for ray intersection with the preview mesh. | PreviewMesh.h | |
TUniquePtr< FMeshChange > TrackedEditMesh
(
TFunctionRef< void(FDynamicMesh3&, UE::Geometry::FDynamicMeshChangeTracker&)> EditFunc |
Apply EditFunc to the internal mesh and update internal data structures as necessary. | PreviewMesh.h | |
void UpdatePreview
(
const FDynamicMesh3* Mesh, |
Update the internal mesh by copying the given Mesh | PreviewMesh.h | |
void UpdatePreview
(
FDynamicMesh3&& Mesh, |
Update the internal mesh by moving in the given Mesh | PreviewMesh.h |
Overridden from IMeshVertexCommandChangeTarget
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void ApplyChange
(
const FMeshVertexChange* Change, |
Apply/Revert a vertex deformation change to the internal mesh (implements IMeshVertexCommandChangeTarget) | PreviewMesh.h |
Overridden from IMeshCommandChangeTarget
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void ApplyChange
(
const FMeshChange* Change, |
Apply/Revert a general mesh change to the internal mesh (implements IMeshCommandChangeTarget) | PreviewMesh.h |
Overridden from IMeshReplacementCommandChangeTarget
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void ApplyChange
(
const FMeshReplacementChange* Change, |
Apply/Revert a general mesh change to the internal mesh (implements IMeshReplacementCommandChangeTarget) | PreviewMesh.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void NotifyWorldPathTracedOutputInvalidated() |
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 | PreviewMesh.h | |
void UpdateRenderMeshDecomposition() |
Update chunk decomposition | PreviewMesh.h |