2020-06-23 18:40:00 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
# include "VoxelBlendMeshesTool.h"
# include "CompositionOps/VoxelBlendMeshesOp.h"
# include "InteractiveToolManager.h"
# include "ToolBuilderUtil.h"
# include "ToolSetupUtil.h"
# include "Selection/ToolSelectionUtil.h"
2021-06-13 00:36:02 -04:00
# include "DynamicMesh/DynamicMesh3.h"
# include "DynamicMesh/MeshTransforms.h"
2020-06-23 18:40:00 -04:00
# include "MeshDescriptionToDynamicMesh.h"
# include "DynamicMeshToMeshDescription.h"
# include "InteractiveGizmoManager.h"
# include "BaseGizmos/GizmoComponents.h"
2021-09-30 08:27:39 -04:00
# include "BaseGizmos/CombinedTransformGizmo.h"
2020-06-23 18:40:00 -04:00
# include "CompositionOps/VoxelBlendMeshesOp.h"
2021-03-09 19:33:56 -04:00
using namespace UE : : Geometry ;
2020-06-23 18:40:00 -04:00
# define LOCTEXT_NAMESPACE "UVoxelBlendMeshesTool"
/*
* Tool
*/
2020-08-11 01:36:57 -04:00
void UVoxelBlendMeshesTool : : SetupProperties ( )
2020-06-23 18:40:00 -04:00
{
2020-08-11 01:36:57 -04:00
Super : : SetupProperties ( ) ;
2020-06-23 18:40:00 -04:00
BlendProperties = NewObject < UVoxelBlendMeshesToolProperties > ( this ) ;
BlendProperties - > RestoreProperties ( this ) ;
AddToolPropertySource ( BlendProperties ) ;
2020-09-24 00:43:27 -04:00
2021-02-08 17:02:09 -04:00
SetToolDisplayName ( LOCTEXT ( " VoxelBlendMeshesToolName " , " Voxel Blend " ) ) ;
2020-09-24 00:43:27 -04:00
GetToolManager ( ) - > DisplayMessage (
2020-10-22 19:19:16 -04:00
LOCTEXT ( " VoxelBlendMeshesToolDescription " , " Compute a volumetric Blend of the input meshes, controlled by the Blend Power/Falloff. UVs, sharp edges, and small/thin features will be lost. Increase Voxel Count to enhance accuracy. " ) ,
2020-09-24 00:43:27 -04:00
EToolMessageLevel : : UserNotification ) ;
2020-06-23 18:40:00 -04:00
}
2020-08-11 01:36:57 -04:00
void UVoxelBlendMeshesTool : : SaveProperties ( )
2020-06-23 18:40:00 -04:00
{
2020-08-11 01:36:57 -04:00
Super : : SaveProperties ( ) ;
2020-06-23 18:40:00 -04:00
BlendProperties - > SaveProperties ( this ) ;
}
TUniquePtr < FDynamicMeshOperator > UVoxelBlendMeshesTool : : MakeNewOperator ( )
{
TUniquePtr < FVoxelBlendMeshesOp > Op = MakeUnique < FVoxelBlendMeshesOp > ( ) ;
2021-03-11 11:40:03 -04:00
Op - > Transforms . SetNum ( Targets . Num ( ) ) ;
Op - > Meshes . SetNum ( Targets . Num ( ) ) ;
for ( int Idx = 0 ; Idx < Targets . Num ( ) ; Idx + + )
2020-06-23 18:40:00 -04:00
{
Op - > Meshes [ Idx ] = OriginalDynamicMeshes [ Idx ] ;
2021-02-03 19:00:42 -04:00
Op - > Transforms [ Idx ] = TransformProxies [ Idx ] - > GetTransform ( ) ;
2020-06-23 18:40:00 -04:00
}
Op - > BlendFalloff = BlendProperties - > BlendFalloff ;
Op - > BlendPower = BlendProperties - > BlendPower ;
2021-01-21 23:50:44 -04:00
Op - > bSubtract = BlendProperties - > Operation = = EVoxelBlendOperation : : Subtract ;
2021-01-15 17:33:35 -04:00
Op - > bVoxWrap = BlendProperties - > bVoxWrap ;
Op - > bRemoveInternalsAfterVoxWrap = BlendProperties - > bRemoveInternalsAfterVoxWrap ;
Op - > ThickenShells = BlendProperties - > ThickenShells ;
2020-06-23 18:40:00 -04:00
2020-08-11 01:36:57 -04:00
VoxProperties - > SetPropertiesOnOp ( * Op ) ;
2020-06-23 18:40:00 -04:00
return Op ;
}
2020-08-11 01:36:57 -04:00
FString UVoxelBlendMeshesTool : : GetCreatedAssetName ( ) const
2020-06-23 18:40:00 -04:00
{
2020-08-11 01:36:57 -04:00
return TEXT ( " Blended " ) ;
2020-06-23 18:40:00 -04:00
}
2020-08-11 01:36:57 -04:00
FText UVoxelBlendMeshesTool : : GetActionName ( ) const
2020-06-23 18:40:00 -04:00
{
2020-08-11 01:36:57 -04:00
return LOCTEXT ( " VoxelBlendMeshes " , " Voxel Blend " ) ;
2020-06-23 18:40:00 -04:00
}
# undef LOCTEXT_NAMESPACE