You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
UMeshElementsVisualizer::SetMeshAccessFunction() now takes a TFunction with a TFunctionRef argument, instead of with a FDynamicMesh3* argument. This allows the UMeshElementsVisualizer to access the target mesh via the ProcessMesh()-style call on a UPreviewMesh, UDynamicMesh, etc, rather than receiving direct pointer access. See UWeldMeshEdgesTool::Setup() for example usage. Add UMeshOpPreviewWithBackgroundCompute::ProcessCurrentMesh(), which forwards to the embedded UPreviewMesh::ProcessMesh() (which can be used with the above) Add UE::ToolTarget::GetMeshDescriptionCopy() to ModelingToolTargetUtil, similar to existing DynamicMesh variant that will auto-compute tangents if necessary. #rb none #rnx #jira none #preflight 60c8def586ce760001d8de51 #fyi semion.piskarev [CL 16679472 by Ryan Schmidt in ue5-main branch]
129 lines
4.3 KiB
C++
129 lines
4.3 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "UObject/NoExportTypes.h"
|
|
#include "BaseTools/SingleSelectionMeshEditingTool.h"
|
|
#include "MeshOpPreviewHelpers.h"
|
|
#include "Properties/RemeshProperties.h"
|
|
#include "CleaningOps/SimplifyMeshOp.h" // required in header for enum types
|
|
#include "SimplifyMeshTool.generated.h"
|
|
|
|
class UMeshStatisticsProperties;
|
|
class UMeshElementsVisualizer;
|
|
PREDECLARE_GEOMETRY(class FDynamicMesh3);
|
|
PREDECLARE_GEOMETRY(typedef TMeshAABBTree3<FDynamicMesh3> FDynamicMeshAABBTree3);
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UCLASS()
|
|
class MESHMODELINGTOOLSEDITORONLY_API USimplifyMeshToolBuilder : public USingleSelectionMeshEditingToolBuilder
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
virtual USingleSelectionMeshEditingTool* CreateNewTool(const FToolBuilderState& SceneState) const override;
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
* Standard properties of the Simplify operation
|
|
*/
|
|
UCLASS()
|
|
class MESHMODELINGTOOLSEDITORONLY_API USimplifyMeshToolProperties : public UMeshConstraintProperties
|
|
{
|
|
GENERATED_BODY()
|
|
public:
|
|
USimplifyMeshToolProperties();
|
|
|
|
/** Simplification Scheme */
|
|
UPROPERTY(EditAnywhere, Category = Options)
|
|
ESimplifyType SimplifierType;
|
|
|
|
/** Simplification Target Type */
|
|
UPROPERTY(EditAnywhere, Category = Options)
|
|
ESimplifyTargetType TargetMode;
|
|
|
|
/** Target percentage of original triangle count */
|
|
UPROPERTY(EditAnywhere, Category = Options, meta = (UIMin = "0", UIMax = "100", EditCondition = "TargetMode == ESimplifyTargetType::Percentage"))
|
|
int TargetPercentage;
|
|
|
|
/** Target edge length */
|
|
UPROPERTY(EditAnywhere, Category = Options, meta = (UIMin = "3.0", UIMax = "10.0", ClampMin = "0.001", ClampMax = "1000.0", EditCondition = "TargetMode == ESimplifyTargetType::EdgeLength && SimplifierType != ESimplifyType::UEStandard"))
|
|
float TargetEdgeLength;
|
|
|
|
/** Target triangle count */
|
|
UPROPERTY(EditAnywhere, Category = Options, meta = (UIMin = "4", UIMax = "10000", ClampMin = "1", ClampMax = "9999999999", EditCondition = "TargetMode == ESimplifyTargetType::TriangleCount || TargetMode == ESimplifyTargetType::VertexCount"))
|
|
int TargetCount;
|
|
|
|
/** If true, UVs and Normals are discarded */
|
|
UPROPERTY(EditAnywhere, Category = Options)
|
|
bool bDiscardAttributes;
|
|
|
|
/** If true, then simplification will consider geometric deviation with the input mesh */
|
|
UPROPERTY(EditAnywhere, Category = Options)
|
|
bool bGeometricConstraint;
|
|
|
|
/** Geometric deviation tolerance used when bGeometricConstraint is enabled, to limit the geometric deviation between the simplified and original meshes */
|
|
UPROPERTY(EditAnywhere, Category = Options, meta = (UIMin = "0.0", UIMax = "10.0", ClampMin = "0.0", ClampMax = "10000000.0", EditCondition = "bGeometricConstraint && SimplifierType != ESimplifyType::UEStandard"))
|
|
float GeometricTolerance;
|
|
|
|
/** Display colors corresponding to the mesh's polygon groups */
|
|
UPROPERTY(EditAnywhere, Category = Display)
|
|
bool bShowGroupColors = false;
|
|
|
|
/** Enable projection back to input mesh */
|
|
UPROPERTY(EditAnywhere, Category = Options, AdvancedDisplay)
|
|
bool bReproject;
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Simple Mesh Simplifying Tool
|
|
*/
|
|
UCLASS()
|
|
class MESHMODELINGTOOLSEDITORONLY_API USimplifyMeshTool : public USingleSelectionMeshEditingTool, public UE::Geometry::IDynamicMeshOperatorFactory
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
virtual void Setup() override;
|
|
virtual void Shutdown(EToolShutdownType ShutdownType) override;
|
|
|
|
virtual void OnTick(float DeltaTime) override;
|
|
|
|
virtual bool HasCancel() const override { return true; }
|
|
virtual bool HasAccept() const override { return true; }
|
|
virtual bool CanAccept() const override;
|
|
|
|
virtual void OnPropertyModified(UObject* PropertySet, FProperty* Property) override;
|
|
|
|
// IDynamicMeshOperatorFactory API
|
|
virtual TUniquePtr<UE::Geometry::FDynamicMeshOperator> MakeNewOperator() override;
|
|
|
|
private:
|
|
UPROPERTY()
|
|
USimplifyMeshToolProperties* SimplifyProperties;
|
|
|
|
UPROPERTY()
|
|
UMeshStatisticsProperties* MeshStatisticsProperties;
|
|
|
|
UPROPERTY()
|
|
UMeshOpPreviewWithBackgroundCompute* Preview;
|
|
|
|
UPROPERTY()
|
|
UMeshElementsVisualizer* MeshElementsDisplay;
|
|
|
|
TSharedPtr<FMeshDescription, ESPMode::ThreadSafe> OriginalMeshDescription;
|
|
// Dynamic Mesh versions precomputed in Setup (rather than recomputed for every simplify op)
|
|
TSharedPtr<UE::Geometry::FDynamicMesh3, ESPMode::ThreadSafe> OriginalMesh;
|
|
TSharedPtr<UE::Geometry::FDynamicMeshAABBTree3, ESPMode::ThreadSafe> OriginalMeshSpatial;
|
|
|
|
void UpdateVisualization();
|
|
};
|