Files
UnrealEngineUWP/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Public/Drawing/PolyEditPreviewMesh.h
michael balzer a49c74b915 MeshModelingToolset: Move ModelingOperators and ModelingOperatorsEditorOnly modules out of experimental plugin
#jira UETOOL-3823
#rb lonnie.li
#preflight 617b1aea5794a500014f544a

#ROBOMERGE-AUTHOR: michael.balzer
#ROBOMERGE-SOURCE: CL 17972239 in //UE5/Release-5.0/... via CL 17972248
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v885-17909292)
#ROBOMERGE[STARSHIP]: UE5-Main

[CL 17972256 by michael balzer in ue5-release-engine-test branch]
2021-10-28 19:47:45 -04:00

83 lines
3.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "PreviewMesh.h"
#include "DynamicMesh/DynamicMesh3.h"
#include "DynamicMesh/DynamicMeshAABBTree3.h"
#include "DynamicSubmesh3.h"
#include "PolyEditPreviewMesh.generated.h"
/**
* UPolyEditPreviewMesh is a variant of UPreviewMesh intended for use as a 'live preview' of
* a mesh creation/editing operation. The class supports initializing the preview mesh in various
* ways, generally as a submesh of a base mesh.
*/
UCLASS(Transient)
class MODELINGCOMPONENTS_API UPolyEditPreviewMesh : public UPreviewMesh
{
GENERATED_BODY()
using FTransform3d = UE::Geometry::FTransform3d;
public:
//
// "Static Type" is just a static mesh
//
void InitializeStaticType(const FDynamicMesh3* SourceMesh, const TArray<int32>& Triangles,
const FTransform3d* MeshTransform = nullptr);
void UpdateStaticType(TFunctionRef<void(FDynamicMesh3&)> UpdateMeshFunc, bool bFullRecalculate);
void MakeStaticTypeTargetMesh(FDynamicMesh3& TargetMesh);
//
// "Extrude Type" duplicates the input faces, offsets them using FExtrudeMesh, and stitches them together
//
void InitializeExtrudeType(const FDynamicMesh3* SourceMesh, const TArray<int32>& Triangles,
const FVector3d& TransformedOffsetDirection,
const FTransform3d* MeshTransform = nullptr,
bool bDeleteExtrudeBaseFaces = true);
void InitializeExtrudeType(FDynamicMesh3&& BaseMesh,
const FVector3d& TransformedOffsetDirection,
const FTransform3d* MeshTransform = nullptr,
bool bDeleteExtrudeBaseFaces = true);
/** Update extrude-type preview mesh by moving existing offset vertices */
void UpdateExtrudeType(double NewOffset, bool bUseNormalDirection = false);
/** Update extrude-type preview mesh by moving existing offset vertices along their connected triangle normals and then averaging positions */
void UpdateExtrudeType_FaceNormalAvg(double NewOffset);
/** Update extrude-type preview mesh using external function. if bFullRecalculate, mesh is re-initialized w/ initial extrusion patch SourceMesh before calling function */
void UpdateExtrudeType(TFunctionRef<void(FDynamicMesh3&)> UpdateMeshFunc, bool bFullRecalculate);
/** Make a hit-target mesh that is an infinite extrusion along extrude direction. If bUseNormalDirection, use per-vertex normals instead */
void MakeExtrudeTypeHitTargetMesh(FDynamicMesh3& TargetMesh, bool bUseNormalDirection = false);
//
// "Inset Type" duplicates the input faces and insets them using FInsetMeshRegion
//
void InitializeInsetType(const FDynamicMesh3* SourceMesh, const TArray<int32>& Triangles,
const FTransform3d* MeshTransform = nullptr);
void UpdateInsetType(double NewOffset, bool bReproject = false, double Softness = 0.0, double AreaScaleT = 1.0, bool bBoundaryOnly = false);
void MakeInsetTypeTargetMesh(FDynamicMesh3& TargetMesh);
const FDynamicMesh3& GetInitialPatchMesh() const { return InitialEditPatch; }
// must be non-const because query functions are non-const
UE::Geometry::FDynamicMeshAABBTree3& GetInitialPatchMeshSpatial() { return InitialEditPatchBVTree; }
protected:
TUniquePtr<UE::Geometry::FDynamicSubmesh3> ActiveSubmesh;
FDynamicMesh3 InitialEditPatch;
UE::Geometry::FDynamicMeshAABBTree3 InitialEditPatchBVTree;
TArray<int32> EditVertices;
TArray<FVector3d> InitialPositions;
TArray<FVector3d> InitialNormals;
TArray<FVector3d> InitialTriNormals;
TMap<int32,int32> ExtrudeToInitialVerts;
FVector3d InputDirection;
UE::Geometry::FTransform3d MeshTransform;
bool bHaveMeshTransform;
};