UMeshOpPreviewWithBackgroundCompute

[UMeshOpPreviewWithBackgroundCompute](API\Plugins\ModelingComponents\UMeshOpPreviewWithBackgroundComp-) is an infrastructure object that implements a common UI pattern in interactive 3D tools, where we want to run an expensive computation on a mesh that is based on user-specified parameters, and show a preview of the result.

Windows
MacOS
Linux

Inheritance Hierarchy

UObjectBase

UObjectBaseUtility

UObject

UMeshOpPreviewWithBackgroundCompute

References

Module

ModelingComponents

Header

/Engine/Plugins/Experimental/MeshModelingToolset/Source/ModelingComponents/Public/MeshOpPreviewHelpers.h

Include

#include "MeshOpPreviewHelpers.h"

Syntax

[UCLASS](Programming/UnrealArchitecture/Reference/Classes#classdeclaration)(Transient)
class UMeshOpPreviewWithBackgroundCompute : public UObject

Remarks

UMeshOpPreviewWithBackgroundCompute is an infrastructure object that implements a common UI pattern in interactive 3D tools, where we want to run an expensive computation on a mesh that is based on user-specified parameters, and show a preview of the result. The expensive computation (a MeshOperator) must run in a background thread so as to not block the UI. If the user changes parameters while the Operator is running, it should be canceled and restarted. When it completes, the Preview will be updated. When the user is happy, the current Mesh is returned to the owner of this object.

The MeshOperators are provided by the owner via a IDynamicMeshOperatorFactory implementation. The owner must also Tick() this object regularly to allow the Preview to update when the background computations complete.

If an InProgress Material is set (via ConfigureMaterials) then when a background computation is active, this material will be used to draw the previous Preview result, to give the user a visual indication that work is happening.

Variables

Name Description

Protected variable

TUniquePtr< FBa...

 

BackgroundCompute

This object manages the background computes

Protected variable

bool

 

bResultValid

State flag, if true then we have valid result

Protected variable

bool

 

bVisible

Public variable

FOnMeshUpdated

 

OnMeshUpdated

This delegate is broadcast whenever the embedded preview mesh is updated

Public variable

FOnOpCompleted

 

OnOpCompleted

Public variable UProperty

UMaterialInterf...

 

OverrideMaterial

Override material to forward to PreviewMesh if set

Public variable UProperty

UPreviewMesh &#...

 

PreviewMesh

Preview of MeshOperator result

Protected variable

float

 

SecondsBeforeWorkingMaterial

Public variable UProperty

TArray< UMateri...

 

StandardMaterials

Input set of materials to assign to PreviewMesh

Public variable UProperty

UMaterialInterf...

 

WorkingMaterial

If non-null, this material is swapped in when a background compute is active

Functions

Name Description

Public function

void

 

Cancel()

Terminate any active computation without returning anything

Public function

void

 

ConfigureMaterials

(
    UMaterialInterface* StandardMa...,
    UMaterialInterface* InProgress...
)

Optional configuration Configure the Standard and In-Progress materials

Public function

void

 

ConfigureMaterials

(
    TArray< UMaterialInterface* > ...,
    UMaterialInterface* InProgress...
)

Configure the Standard and In-Progress materials

Public function

bool

 

GetCurrentResultCopy

(
    FDynamicMesh3& MeshOut,
    bool bOnlyIfValid
)

Read back a copy of current preview mesh.

Public function Const

bool

 

HaveValidResult()

Public function

void

 

InvalidateResult()

Control flow Request that the current computation be canceled and a new one started

Public function

bool

 

IsUsingWorkingMaterial()

Public function

void

 

Setup

(
    UWorld* InWorld,
    IDynamicMeshOperatorFactory* O...
)

Required calls to setup/update/shutdown this object

Public function

void

 

SetVisibility

(
    bool bVisible
)

Set the visibility of the Preview mesh

Public function

void

 

SetWorkingMaterialDelay

(
    float TimeInSeconds
)

Set time that Preview will wait before showing working material

Public function

FDynamicMesh...

 

Shutdown()

Terminate any active computation and return the current Preview Mesh/Transform

Public function

void

 

Tick

(
    float DeltaTime
)

Tick the background computation and Preview update.

Protected function

void

 

UpdateResults()

Update the PreviewMesh if a new result is available from BackgroundCompute

Typedefs

Name

Description

FOnMeshUpdated

Change notification

FOnOpCompleted

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