Navigation
API > API/Plugins > API/Plugins/ModelingComponents
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.
| Name | UMeshOpPreviewWithBackgroundCompute |
| Type | class |
| Header File | /Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Public/MeshOpPreviewHelpers.h |
| Include Path | #include "MeshOpPreviewHelpers.h" |
Syntax
UCLASS (MinimalAPI, Transient)
class UMeshOpPreviewWithBackgroundCompute : public UObject
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → UMeshOpPreviewWithBackgroundCompute
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FOnMeshUpdated | TMulticastDelegate_OneParam< void, UMeshOpPreviewWithBackgroundCompute * > | Change notification | MeshOpPreviewHelpers.h |
| FOnOpCompleted | TMulticastDelegate_OneParam< void, const UE::Geometry::FDynamicMeshOperator * > | MeshOpPreviewHelpers.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bAllowDirtyResultUpdates | bool | When true, the preview mesh is allowed to be temporarily updated using results that we know are dirty (i.e., the preview was invalidated, but a result became available before the operation was restarted, so we can at least show that while we wait for the new result). | MeshOpPreviewHelpers.h | |
| OnMeshUpdated | FOnMeshUpdated | This delegate is broadcast whenever the embedded preview mesh is updated | MeshOpPreviewHelpers.h | |
| OnOpCompleted | FOnOpCompleted | MeshOpPreviewHelpers.h | ||
| OverrideMaterial | TObjectPtr< UMaterialInterface > | Override material to forward to PreviewMesh if set | MeshOpPreviewHelpers.h | |
| PreviewMesh | TObjectPtr< UPreviewMesh > | Preview of MeshOperator result | MeshOpPreviewHelpers.h | |
| PreviewWorld | TWeakObjectPtr< UWorld > | MeshOpPreviewHelpers.h | ||
| SecondaryMaterial | TObjectPtr< UMaterialInterface > | Secondary render material to forward to PreviewMesh if set | MeshOpPreviewHelpers.h | |
| StandardMaterials | TArray< TObjectPtr< UMaterialInterface > > | Input set of materials to assign to PreviewMesh | MeshOpPreviewHelpers.h | |
| WorkingMaterial | TObjectPtr< UMaterialInterface > | If non-null, this material is swapped in when a background compute is active | MeshOpPreviewHelpers.h |
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bWaitingForBackgroundTasks | bool | MeshOpPreviewHelpers.h | ||
| MaxActiveBackgroundTasks | int32 | MeshOpPreviewHelpers.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Cancel() |
Terminate any active computation without returning anything. Destroys the preview mesh. | MeshOpPreviewHelpers.h | |
void CancelCompute() |
Cancel the active computation without returning anything. Doesn't destroy the mesh. | MeshOpPreviewHelpers.h | |
void ChangeOpFactory
(
UE::Geometry::IDynamicMeshOperatorFactory* OpGenerator |
Stops any running computes and swaps in a different op generator. | MeshOpPreviewHelpers.h | |
void ClearOpFactory() |
MeshOpPreviewHelpers.h | ||
void ConfigureMaterials
(
TArray< UMaterialInterface* > StandardMaterials, |
Configure the Standard and In-Progress materials | MeshOpPreviewHelpers.h | |
void ConfigureMaterials
(
UMaterialInterface* StandardMaterial, |
Optional configuration Configure the Standard and In-Progress materials | MeshOpPreviewHelpers.h | |
void ConfigurePreviewMaterials
(
UMaterialInterface* InProgressMaterial, |
Configure the In-Progress and Secondary Materials | MeshOpPreviewHelpers.h | |
void DisablePreviewMaterials() |
Disable the In Progress and Secondary Materials | MeshOpPreviewHelpers.h | |
bool GetCurrentResultCopy
(
FDynamicMesh3& MeshOut, |
Read back a copy of current preview mesh. | MeshOpPreviewHelpers.h | |
double GetValidResultComputeTime() |
MeshOpPreviewHelpers.h | ||
virtual UWorld * GetWorld() |
MeshOpPreviewHelpers.h | ||
bool HaveEmptyResult() |
MeshOpPreviewHelpers.h | ||
bool HaveValidNonEmptyResult() |
MeshOpPreviewHelpers.h | ||
bool HaveValidResult() |
MeshOpPreviewHelpers.h | ||
void InvalidateResult() |
Control flow Request that the current computation be canceled and a new one started | MeshOpPreviewHelpers.h | |
bool IsUsingWorkingMaterial() |
MeshOpPreviewHelpers.h | ||
bool ProcessCurrentMesh
(
TFunctionRef< void(const UE::Geometry::FDynamicMesh3&)> ProcessFunc, |
Allow an external function to safely access the PreviewMesh's mesh | MeshOpPreviewHelpers.h | |
void SetIsMeshTopologyConstant
(
bool bOn, |
If set to true, then it will be assumed that the mesh topology (i.e. triangle/edge connectivity) remains constant, which will allow updates after the first one to modify existing render proxy buffers rather than creating entirely new ones. | MeshOpPreviewHelpers.h | |
void SetMaxActiveBackgroundTasks
(
int32 NewMaxTasks |
Configure the maximum allowed number of background tasks. | MeshOpPreviewHelpers.h | |
void SetMaxActiveBackgroundTasksFromMeshSizeHeuristic
(
int32 InputMeshTriangleCount, |
Configure maximum allowed number of background tasks heuristically from the input triangle count. | MeshOpPreviewHelpers.h | |
| MeshOpPreviewHelpers.h | |||
void Setup
(
UWorld* InWorld, |
Required calls to setup/update/shutdown this object | MeshOpPreviewHelpers.h | |
void SetVisibility
(
bool bVisible |
Set the visibility of the Preview mesh | MeshOpPreviewHelpers.h | |
void SetWorkingMaterialDelay
(
float TimeInSeconds |
Set time that Preview will wait before showing working material | MeshOpPreviewHelpers.h | |
FDynamicMeshOpResult Shutdown() |
Terminate any active computation and return the current Preview Mesh/Transform | MeshOpPreviewHelpers.h | |
void Tick
(
float DeltaTime |
Tick the background computation and Preview update. | MeshOpPreviewHelpers.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void UpdateResults() |
Update the PreviewMesh if a new result is available from BackgroundCompute | MeshOpPreviewHelpers.h |