Navigation
API > API/Plugins > API/Plugins/ModelingComponents
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- UMeshOpPreviewWithBackgroundCompute
References
| Module | ModelingComponents |
| Header | /Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Public/MeshOpPreviewHelpers.h |
| Include | #include "MeshOpPreviewHelpers.h" |
Syntax
UCLASS&40;Transient&41;
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
| Type | Name | Description | |
|---|---|---|---|
| TUniquePtr< FBackgroundDynamicMeshComputeSource > | BackgroundCompute | This object manages the background computes | |
| bool | bAllowDirtyResultUpdates | 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). | |
| bool | bMeshInitialized | ||
| bool | bMeshTopologyIsConstant | Used for partial/fast updates of the preview mesh render proxy. | |
| bool | bResultValid | State flag, if true then we have valid result | |
| bool | bVisible | ||
| EMeshRenderAttributeFlags | ChangingAttributeFlags | ||
| UE::Geometry::EBackgroundComputeTaskStatus | LastComputeStatus | Stored status of last compute, mainly so that we know when we should show the "busy" material. | |
| FOnMeshUpdated | OnMeshUpdated | This delegate is broadcast whenever the embedded preview mesh is updated | |
| FOnOpCompleted | OnOpCompleted | ||
| TObjectPtr< UMaterialInterface > | OverrideMaterial | Override material to forward to PreviewMesh if set | |
| TObjectPtr< UPreviewMesh > | PreviewMesh | Preview of MeshOperator result | |
| TWeakObjectPtr< UWorld > | PreviewWorld | ||
| TObjectPtr< UMaterialInterface > | SecondaryMaterial | Secondary render material to forward to PreviewMesh if set | |
| float | SecondsBeforeWorkingMaterial | ||
| TArray< TObjectPtr< UMaterialInterface > > | StandardMaterials | Input set of materials to assign to PreviewMesh | |
| double | ValidResultComputeTimeSeconds | ||
| TObjectPtr< UMaterialInterface > | WorkingMaterial | If non-null, this material is swapped in when a background compute is active |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | Cancel () |
Terminate any active computation without returning anything. Destroys the preview mesh. | |
| void | Cancel the active computation without returning anything. Doesn't destroy the mesh. | ||
| void | ChangeOpFactory
(
UE::Geometry::IDynamicMeshOperatorFactory* OpGenerator |
Stops any running computes and swaps in a different op generator. | |
| void | |||
| void | ConfigureMaterials
(
TArray< UMaterialInterface* > StandardMaterials, |
Configure the Standard and In-Progress materials | |
| void | ConfigureMaterials
(
UMaterialInterface* StandardMaterial, |
Optional configuration Configure the Standard and In-Progress materials | |
| void | ConfigurePreviewMaterials
(
UMaterialInterface* InProgressMaterial, |
Configure the In-Progress and Secondary Materials | |
| void | Disable the In Progress and Secondary Materials | ||
| bool | GetCurrentResultCopy
(
FDynamicMesh3& MeshOut, |
Read back a copy of current preview mesh. | |
| double | |||
| UWorld * | GetWorld () |
||
| bool | |||
| bool | |||
| bool | |||
| void | Control flow Request that the current computation be canceled and a new one started | ||
| bool | |||
| bool | ProcessCurrentMesh
(
TFunctionRef< void(const UE::Geometry::FDynamicMesh3&)> ProcessFunc, |
Allow an external function to safely access the PreviewMesh's mesh | |
| 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. | |
| void | |||
| void | Setup
(
UWorld* InWorld, |
Required calls to setup/update/shutdown this object | |
| void | SetVisibility
(
bool bVisible |
Set the visibility of the Preview mesh | |
| void | SetWorkingMaterialDelay
(
float TimeInSeconds |
Set time that Preview will wait before showing working material | |
| FDynamicMeshOpResult | Shutdown () |
Terminate any active computation and return the current Preview Mesh/Transform | |
| void | Tick
(
float DeltaTime |
Tick the background computation and Preview update. | |
| void | Update the PreviewMesh if a new result is available from BackgroundCompute |
Typedefs
| Name | Description |
|---|---|
| FOnMeshUpdated | Change notification |
| FOnOpCompleted |