2020-01-27 20:11:15 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
# pragma once
# include "PreviewMesh.h"
2021-06-13 00:35:22 -04:00
# include "DynamicMesh/DynamicMesh3.h"
# include "DynamicMesh/DynamicMeshAABBTree3.h"
2020-01-27 20:11:15 -05:00
# include "DynamicSubmesh3.h"
# include "EdgeLoop.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 ( )
2021-03-09 19:33:56 -04:00
using FTransform3d = UE : : Geometry : : FTransform3d ;
2020-01-27 20:11:15 -05:00
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 ) ;
2020-10-29 13:38:15 -04:00
/** Update extrude-type preview mesh by moving existing offset vertices along their connected triangle normals and then averaging positions */
void UpdateExtrudeType_FaceNormalAvg ( double NewOffset ) ;
2020-01-27 20:11:15 -05:00
/** 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 ) ;
2020-09-01 14:07:48 -04:00
void UpdateInsetType ( double NewOffset , bool bReproject = false , double Softness = 0.0 , double AreaScaleT = 1.0 , bool bBoundaryOnly = false ) ;
2020-01-27 20:11:15 -05:00
void MakeInsetTypeTargetMesh ( FDynamicMesh3 & TargetMesh ) ;
const FDynamicMesh3 & GetInitialPatchMesh ( ) const { return InitialEditPatch ; }
// must be non-const because query functions are non-const
2021-03-09 19:33:56 -04:00
UE : : Geometry : : FDynamicMeshAABBTree3 & GetInitialPatchMeshSpatial ( ) { return InitialEditPatchBVTree ; }
2020-01-27 20:11:15 -05:00
protected :
2021-03-09 19:33:56 -04:00
TUniquePtr < UE : : Geometry : : FDynamicSubmesh3 > ActiveSubmesh ;
2020-01-27 20:11:15 -05:00
FDynamicMesh3 InitialEditPatch ;
2021-03-09 19:33:56 -04:00
UE : : Geometry : : FDynamicMeshAABBTree3 InitialEditPatchBVTree ;
2020-01-27 20:11:15 -05:00
TArray < int32 > EditVertices ;
TArray < FVector3d > InitialPositions ;
TArray < FVector3d > InitialNormals ;
2020-10-29 13:38:15 -04:00
TArray < FVector3d > InitialTriNormals ;
TMap < int32 , int32 > ExtrudeToInitialVerts ;
2020-01-27 20:11:15 -05:00
FVector3d InputDirection ;
2021-03-09 19:33:56 -04:00
UE : : Geometry : : FTransform3d MeshTransform ;
2020-01-27 20:11:15 -05:00
bool bHaveMeshTransform ;
} ;