2020-01-27 20:11:15 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
# include "CombineMeshesTool.h"
# include "InteractiveToolManager.h"
# include "ToolBuilderUtil.h"
# include "ToolSetupUtil.h"
2021-06-13 00:35:22 -04:00
# include "DynamicMesh/DynamicMesh3.h"
2020-01-27 20:11:15 -05:00
# include "DynamicMeshEditor.h"
2021-06-13 00:35:22 -04:00
# include "DynamicMesh/MeshTransforms.h"
2020-01-27 20:11:15 -05:00
2021-06-02 15:58:00 -04:00
# include "ModelingObjectsCreationAPI.h"
2020-01-27 20:11:15 -05:00
# include "Selection/ToolSelectionUtil.h"
2021-03-01 12:11:10 -04:00
# include "Physics/ComponentCollisionUtil.h"
# include "ShapeApproximation/SimpleShapeSet3.h"
2020-01-27 20:11:15 -05:00
2020-09-24 00:43:27 -04:00
# include "Components/StaticMeshComponent.h"
# include "Engine/StaticMesh.h"
2021-02-23 18:03:26 -04:00
# include "TargetInterfaces/MaterialProvider.h"
# include "TargetInterfaces/MeshDescriptionCommitter.h"
# include "TargetInterfaces/MeshDescriptionProvider.h"
# include "TargetInterfaces/PrimitiveComponentBackedTarget.h"
# include "ToolTargetManager.h"
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
# include "ModelingToolTargetUtil.h"
2021-02-23 18:03:26 -04:00
2020-01-27 20:11:15 -05:00
# if WITH_EDITOR
# include "Misc/ScopedSlowTask.h"
# endif
2021-03-09 19:33:56 -04:00
# include "ExplicitUseGeometryMathTypes.h" // using UE::Geometry::(math types)
using namespace UE : : Geometry ;
2020-01-27 20:11:15 -05:00
# define LOCTEXT_NAMESPACE "UCombineMeshesTool"
/*
* ToolBuilder
*/
2021-02-23 18:03:26 -04:00
const FToolTargetTypeRequirements & UCombineMeshesToolBuilder : : GetTargetRequirements ( ) const
{
static FToolTargetTypeRequirements TypeRequirements ( {
UMeshDescriptionCommitter : : StaticClass ( ) ,
UMeshDescriptionProvider : : StaticClass ( ) ,
UPrimitiveComponentBackedTarget : : StaticClass ( ) ,
UMaterialProvider : : StaticClass ( )
} ) ;
return TypeRequirements ;
}
2020-01-27 20:11:15 -05:00
bool UCombineMeshesToolBuilder : : CanBuildTool ( const FToolBuilderState & SceneState ) const
{
2020-03-09 16:10:47 -04:00
return ( bIsDuplicateTool ) ?
2021-06-02 15:58:00 -04:00
( SceneState . TargetManager - > CountSelectedAndTargetable ( SceneState , GetTargetRequirements ( ) ) = = 1 )
: ( SceneState . TargetManager - > CountSelectedAndTargetable ( SceneState , GetTargetRequirements ( ) ) > 1 ) ;
2020-01-27 20:11:15 -05:00
}
UInteractiveTool * UCombineMeshesToolBuilder : : BuildTool ( const FToolBuilderState & SceneState ) const
{
UCombineMeshesTool * NewTool = NewObject < UCombineMeshesTool > ( SceneState . ToolManager ) ;
2021-02-23 18:03:26 -04:00
TArray < TObjectPtr < UToolTarget > > Targets = SceneState . TargetManager - > BuildAllSelectedTargetable ( SceneState , GetTargetRequirements ( ) ) ;
NewTool - > SetTargets ( MoveTemp ( Targets ) ) ;
2020-01-27 20:11:15 -05:00
NewTool - > SetWorld ( SceneState . World ) ;
2020-03-09 16:10:47 -04:00
NewTool - > SetDuplicateMode ( bIsDuplicateTool ) ;
2020-01-27 20:11:15 -05:00
return NewTool ;
}
/*
* Tool
*/
void UCombineMeshesTool : : SetWorld ( UWorld * World )
{
this - > TargetWorld = World ;
}
2020-03-09 16:10:47 -04:00
void UCombineMeshesTool : : SetDuplicateMode ( bool bDuplicateModeIn )
{
this - > bDuplicateMode = bDuplicateModeIn ;
}
2020-01-27 20:11:15 -05:00
void UCombineMeshesTool : : Setup ( )
{
UInteractiveTool : : Setup ( ) ;
BasicProperties = NewObject < UCombineMeshesToolProperties > ( this ) ;
AddToolPropertySource ( BasicProperties ) ;
2020-10-22 19:19:16 -04:00
BasicProperties - > RestoreProperties ( this ) ;
BasicProperties - > bIsDuplicateMode = this - > bDuplicateMode ;
2021-06-23 22:13:32 -04:00
OutputTypeProperties = NewObject < UCreateMeshObjectTypeProperties > ( this ) ;
OutputTypeProperties - > InitializeDefaultWithAuto ( ) ;
OutputTypeProperties - > OutputType = UCreateMeshObjectTypeProperties : : AutoIdentifier ;
OutputTypeProperties - > RestoreProperties ( this , TEXT ( " OutputTypeFromInputTool " ) ) ;
OutputTypeProperties - > WatchProperty ( OutputTypeProperties - > OutputType , [ this ] ( FString ) { OutputTypeProperties - > UpdatePropertyVisibility ( ) ; } ) ;
AddToolPropertySource ( OutputTypeProperties ) ;
2020-10-22 19:19:16 -04:00
BasicProperties - > WatchProperty ( BasicProperties - > WriteOutputTo , [ & ] ( ECombineTargetType NewType )
{
if ( NewType = = ECombineTargetType : : NewAsset )
{
BasicProperties - > OutputAsset = TEXT ( " " ) ;
2021-06-23 22:13:32 -04:00
SetToolPropertySourceEnabled ( OutputTypeProperties , true ) ;
2020-10-22 19:19:16 -04:00
}
else
{
2021-02-23 18:03:26 -04:00
int32 Index = ( BasicProperties - > WriteOutputTo = = ECombineTargetType : : FirstInputAsset ) ? 0 : Targets . Num ( ) - 1 ;
2021-06-23 22:13:32 -04:00
BasicProperties - > OutputAsset = UE : : Modeling : : GetComponentAssetBaseName ( UE : : ToolTarget : : GetTargetComponent ( Targets [ Index ] ) , false ) ;
SetToolPropertySourceEnabled ( OutputTypeProperties , false ) ;
2020-10-22 19:19:16 -04:00
}
} ) ;
2021-06-23 22:13:32 -04:00
SetToolPropertySourceEnabled ( OutputTypeProperties , BasicProperties - > WriteOutputTo = = ECombineTargetType : : NewAsset ) ;
2020-10-22 19:19:16 -04:00
if ( bDuplicateMode )
{
2021-02-08 17:02:09 -04:00
SetToolDisplayName ( LOCTEXT ( " DuplicateMeshesToolName " , " Duplicate " ) ) ;
2021-06-23 22:13:32 -04:00
BasicProperties - > OutputName = UE : : Modeling : : GetComponentAssetBaseName ( UE : : ToolTarget : : GetTargetComponent ( Targets [ 0 ] ) ) ;
2020-10-22 19:19:16 -04:00
}
else
{
2021-02-08 17:02:09 -04:00
SetToolDisplayName ( LOCTEXT ( " CombineMeshesToolName " , " Append " ) ) ;
2020-10-22 19:19:16 -04:00
BasicProperties - > OutputName = FString ( " Combined " ) ;
}
HandleSourceProperties = NewObject < UOnAcceptHandleSourcesProperties > ( this ) ;
AddToolPropertySource ( HandleSourceProperties ) ;
HandleSourceProperties - > RestoreProperties ( this ) ;
2020-03-10 13:59:45 -04:00
if ( bDuplicateMode )
{
GetToolManager ( ) - > DisplayMessage (
2020-03-11 10:31:26 -04:00
LOCTEXT ( " OnStartToolDuplicate " , " This Tool duplicates input Asset into a new Asset, and optionally replaces the input Actor with a new Actor containing the new Asset. " ) ,
2020-03-10 13:59:45 -04:00
EToolMessageLevel : : UserNotification ) ;
}
else
{
GetToolManager ( ) - > DisplayMessage (
2020-03-11 10:31:26 -04:00
LOCTEXT ( " OnStartToolCombine " , " This Tool appends the meshes from the input Assets into a new Asset, and optionally replaces the source Actors with a new Actor containing the new Asset. " ) ,
2020-03-10 13:59:45 -04:00
EToolMessageLevel : : UserNotification ) ;
}
2020-01-27 20:11:15 -05:00
}
void UCombineMeshesTool : : Shutdown ( EToolShutdownType ShutdownType )
{
2020-10-22 19:19:16 -04:00
BasicProperties - > SaveProperties ( this ) ;
2021-06-23 22:13:32 -04:00
OutputTypeProperties - > SaveProperties ( this , TEXT ( " OutputTypeFromInputTool " ) ) ;
2020-10-22 19:19:16 -04:00
HandleSourceProperties - > SaveProperties ( this ) ;
2020-01-27 20:11:15 -05:00
if ( ShutdownType = = EToolShutdownType : : Accept )
{
2020-10-22 19:19:16 -04:00
if ( bDuplicateMode | | BasicProperties - > WriteOutputTo = = ECombineTargetType : : NewAsset )
{
CreateNewAsset ( ) ;
}
else
{
UpdateExistingAsset ( ) ;
}
2020-01-27 20:11:15 -05:00
}
}
2020-10-22 19:19:16 -04:00
void UCombineMeshesTool : : CreateNewAsset ( )
2020-01-27 20:11:15 -05:00
{
2021-06-23 22:13:32 -04:00
// Make sure meshes are available before we open transaction. This is to avoid potential stability issues related
// to creation/load of meshes inside a transaction, for assets that possibly do not have bulk data currently loaded.
TArray < FDynamicMesh3 > InputMeshes ;
InputMeshes . Reserve ( Targets . Num ( ) ) ;
2021-03-01 12:11:10 -04:00
for ( int32 ComponentIdx = 0 ; ComponentIdx < Targets . Num ( ) ; ComponentIdx + + )
{
2021-06-23 22:13:32 -04:00
InputMeshes . Add ( UE : : ToolTarget : : GetDynamicMeshCopy ( Targets [ ComponentIdx ] , true ) ) ;
2021-03-01 12:11:10 -04:00
}
2021-06-23 22:13:32 -04:00
GetToolManager ( ) - > BeginUndoTransaction ( bDuplicateMode ?
2020-06-23 18:40:00 -04:00
LOCTEXT ( " DuplicateMeshToolTransactionName " , " Duplicate Mesh " ) :
LOCTEXT ( " CombineMeshesToolTransactionName " , " Combine Meshes " ) ) ;
2020-01-27 20:11:15 -05:00
FBox Box ( ForceInit ) ;
2021-02-23 18:03:26 -04:00
for ( int32 ComponentIdx = 0 ; ComponentIdx < Targets . Num ( ) ; ComponentIdx + + )
2020-01-27 20:11:15 -05:00
{
2021-06-23 22:13:32 -04:00
Box + = UE : : ToolTarget : : GetTargetComponent ( Targets [ ComponentIdx ] ) - > Bounds . GetBox ( ) ;
2020-01-27 20:11:15 -05:00
}
TArray < UMaterialInterface * > AllMaterials ;
2021-06-23 22:13:32 -04:00
TArray < TArray < int32 > > MaterialIDRemaps ;
BuildCombinedMaterialSet ( AllMaterials , MaterialIDRemaps ) ;
2020-01-27 20:11:15 -05:00
FDynamicMesh3 AccumulateDMesh ;
AccumulateDMesh . EnableTriangleGroups ( ) ;
AccumulateDMesh . EnableAttributes ( ) ;
2021-06-23 22:13:32 -04:00
AccumulateDMesh . Attributes ( ) - > EnableTangents ( ) ;
2020-01-27 20:11:15 -05:00
AccumulateDMesh . Attributes ( ) - > EnableMaterialID ( ) ;
2021-04-19 10:47:52 -04:00
AccumulateDMesh . Attributes ( ) - > EnablePrimaryColors ( ) ;
2020-01-27 20:11:15 -05:00
FTransform AccumToWorld ( Box . GetCenter ( ) ) ;
FTransform ToAccum ( - Box . GetCenter ( ) ) ;
2021-03-01 12:11:10 -04:00
FSimpleShapeSet3d SimpleCollision ;
UE : : Geometry : : FComponentCollisionSettings CollisionSettings ;
2020-01-27 20:11:15 -05:00
{
2021-06-02 15:58:00 -04:00
# if WITH_EDITOR
2021-02-23 18:03:26 -04:00
FScopedSlowTask SlowTask ( Targets . Num ( ) + 1 ,
2020-06-23 18:40:00 -04:00
bDuplicateMode ?
LOCTEXT ( " DuplicateMeshBuild " , " Building duplicate mesh ... " ) :
2020-01-27 20:11:15 -05:00
LOCTEXT ( " CombineMeshesBuild " , " Building combined mesh ... " ) ) ;
SlowTask . MakeDialog ( ) ;
2021-06-02 15:58:00 -04:00
# endif
2021-04-19 10:47:52 -04:00
bool bNeedColorAttr = false ;
2020-01-27 20:11:15 -05:00
int MatIndexBase = 0 ;
2021-02-23 18:03:26 -04:00
for ( int32 ComponentIdx = 0 ; ComponentIdx < Targets . Num ( ) ; ComponentIdx + + )
2020-01-27 20:11:15 -05:00
{
2021-06-02 15:58:00 -04:00
# if WITH_EDITOR
2020-01-27 20:11:15 -05:00
SlowTask . EnterProgressFrame ( 1 ) ;
2021-06-02 15:58:00 -04:00
# endif
2021-06-23 22:13:32 -04:00
UPrimitiveComponent * PrimitiveComponent = UE : : ToolTarget : : GetTargetComponent ( Targets [ ComponentIdx ] ) ;
2020-01-27 20:11:15 -05:00
2021-06-23 22:13:32 -04:00
FDynamicMesh3 & ComponentDMesh = InputMeshes [ ComponentIdx ] ;
2021-04-19 10:47:52 -04:00
bNeedColorAttr = bNeedColorAttr | | ( ComponentDMesh . HasAttributes ( ) & & ComponentDMesh . Attributes ( ) - > HasPrimaryColors ( ) ) ;
2020-01-27 20:11:15 -05:00
2021-05-27 18:34:25 -04:00
if ( ComponentDMesh . HasAttributes ( ) & & ComponentDMesh . Attributes ( ) - > NumUVLayers ( ) > AccumulateDMesh . Attributes ( ) - > NumUVLayers ( ) )
{
AccumulateDMesh . Attributes ( ) - > SetNumUVLayers ( ComponentDMesh . Attributes ( ) - > NumUVLayers ( ) ) ;
}
2021-06-23 22:13:32 -04:00
UE : : Geometry : : FTransform3d XF = ( UE : : Geometry : : FTransform3d ) ( ( FTransform ) UE : : ToolTarget : : GetLocalToWorldTransform ( Targets [ ComponentIdx ] ) * ToAccum ) ;
2020-02-14 17:47:09 -05:00
if ( XF . GetDeterminant ( ) < 0 )
{
ComponentDMesh . ReverseOrientation ( false ) ;
}
2020-01-27 20:11:15 -05:00
// update material IDs to account for combined material set
FDynamicMeshMaterialAttribute * MatAttrib = ComponentDMesh . Attributes ( ) - > GetMaterialID ( ) ;
for ( int TID : ComponentDMesh . TriangleIndicesItr ( ) )
{
2021-06-23 22:13:32 -04:00
int MatID = MatAttrib - > GetValue ( TID ) ;
MatAttrib - > SetValue ( TID , MaterialIDRemaps [ ComponentIdx ] [ MatID ] ) ;
2020-01-27 20:11:15 -05:00
}
FDynamicMeshEditor Editor ( & AccumulateDMesh ) ;
FMeshIndexMappings IndexMapping ;
2020-03-25 19:50:01 -04:00
if ( bDuplicateMode ) // no transform if duplicating
{
Editor . AppendMesh ( & ComponentDMesh , IndexMapping ) ;
2021-06-23 22:13:32 -04:00
if ( UE : : Geometry : : ComponentTypeSupportsCollision ( PrimitiveComponent ) )
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
{
2021-06-23 22:13:32 -04:00
CollisionSettings = UE : : Geometry : : GetCollisionSettings ( PrimitiveComponent ) ;
UE : : Geometry : : AppendSimpleCollision ( PrimitiveComponent , & SimpleCollision , UE : : Geometry : : FTransform3d : : Identity ( ) ) ;
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
}
2020-03-25 19:50:01 -04:00
}
else
{
Editor . AppendMesh ( & ComponentDMesh , IndexMapping ,
[ & XF ] ( int Unused , const FVector3d P ) { return XF . TransformPosition ( P ) ; } ,
[ & XF ] ( int Unused , const FVector3d N ) { return XF . TransformNormal ( N ) ; } ) ;
2021-06-23 22:13:32 -04:00
if ( UE : : Geometry : : ComponentTypeSupportsCollision ( PrimitiveComponent ) )
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
{
2021-06-23 22:13:32 -04:00
UE : : Geometry : : AppendSimpleCollision ( PrimitiveComponent , & SimpleCollision , XF ) ;
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
}
2020-03-25 19:50:01 -04:00
}
2020-01-27 20:11:15 -05:00
2021-06-23 22:13:32 -04:00
FComponentMaterialSet MaterialSet = UE : : ToolTarget : : GetMaterialSet ( Targets [ ComponentIdx ] ) ;
MatIndexBase + = MaterialSet . Materials . Num ( ) ;
2020-01-27 20:11:15 -05:00
}
2021-04-19 10:47:52 -04:00
if ( ! bNeedColorAttr )
{
AccumulateDMesh . Attributes ( ) - > DisablePrimaryColors ( ) ;
}
2021-06-02 15:58:00 -04:00
# if WITH_EDITOR
2020-01-27 20:11:15 -05:00
SlowTask . EnterProgressFrame ( 1 ) ;
2021-06-02 15:58:00 -04:00
# endif
2020-01-27 20:11:15 -05:00
2020-03-25 19:50:01 -04:00
if ( bDuplicateMode )
{
// TODO: will need to refactor this when we support duplicating multiple
2021-02-23 18:03:26 -04:00
check ( Targets . Num ( ) = = 1 ) ;
2021-06-23 22:13:32 -04:00
AccumToWorld = ( FTransform ) UE : : ToolTarget : : GetLocalToWorldTransform ( Targets [ 0 ] ) ;
2020-03-25 19:50:01 -04:00
}
2020-10-22 19:19:16 -04:00
2020-10-29 13:38:15 -04:00
// max len explicitly enforced here, would ideally notify user
FString UseBaseName = BasicProperties - > OutputName . Left ( 250 ) ;
2020-10-22 19:19:16 -04:00
if ( UseBaseName . IsEmpty ( ) )
{
UseBaseName = ( bDuplicateMode ) ? TEXT ( " Duplicate " ) : TEXT ( " Combined " ) ;
}
2021-06-02 15:58:00 -04:00
FCreateMeshObjectParams NewMeshObjectParams ;
NewMeshObjectParams . TargetWorld = TargetWorld ;
NewMeshObjectParams . Transform = AccumToWorld ;
NewMeshObjectParams . BaseName = UseBaseName ;
NewMeshObjectParams . Materials = AllMaterials ;
NewMeshObjectParams . SetMesh ( & AccumulateDMesh ) ;
2021-06-23 22:13:32 -04:00
if ( OutputTypeProperties - > OutputType = = UCreateMeshObjectTypeProperties : : AutoIdentifier )
{
UE : : ToolTarget : : ConfigureCreateMeshObjectParams ( Targets [ 0 ] , NewMeshObjectParams ) ;
}
else
{
OutputTypeProperties - > ConfigureCreateMeshObjectParams ( NewMeshObjectParams ) ;
}
2021-06-02 15:58:00 -04:00
FCreateMeshObjectResult Result = UE : : Modeling : : CreateMeshObject ( GetToolManager ( ) , MoveTemp ( NewMeshObjectParams ) ) ;
if ( Result . IsOK ( ) & & Result . NewActor ! = nullptr )
2020-01-27 20:11:15 -05:00
{
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
// if any inputs have Simple Collision geometry we will forward it to new mesh.
if ( UE : : Geometry : : ComponentTypeSupportsCollision ( Result . NewComponent ) & & SimpleCollision . TotalElementsNum ( ) > 0 )
2020-09-24 00:43:27 -04:00
{
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
UE : : Geometry : : SetSimpleCollision ( Result . NewComponent , & SimpleCollision , CollisionSettings ) ;
2021-03-01 12:11:10 -04:00
}
2020-09-24 00:43:27 -04:00
// select the new actor
2021-06-02 15:58:00 -04:00
ToolSelectionUtil : : SetNewActorSelection ( GetToolManager ( ) , Result . NewActor ) ;
2020-01-27 20:11:15 -05:00
}
}
2020-10-22 19:19:16 -04:00
TArray < AActor * > Actors ;
2021-02-23 18:03:26 -04:00
for ( int32 Idx = 0 ; Idx < Targets . Num ( ) ; Idx + + )
2020-01-27 20:11:15 -05:00
{
2021-06-23 22:13:32 -04:00
Actors . Add ( UE : : ToolTarget : : GetTargetActor ( Targets [ Idx ] ) ) ;
2020-01-27 20:11:15 -05:00
}
2020-10-22 19:19:16 -04:00
HandleSourceProperties - > ApplyMethod ( Actors , GetToolManager ( ) ) ;
2020-01-27 20:11:15 -05:00
GetToolManager ( ) - > EndUndoTransaction ( ) ;
}
2020-10-22 19:19:16 -04:00
void UCombineMeshesTool : : UpdateExistingAsset ( )
{
2021-06-23 22:13:32 -04:00
// Make sure meshes are available before we open transaction. This is to avoid potential stability issues related
// to creation/load of meshes inside a transaction, for assets that possibly do not have bulk data currently loaded.
TArray < FDynamicMesh3 > InputMeshes ;
InputMeshes . Reserve ( Targets . Num ( ) ) ;
2021-03-11 11:40:03 -04:00
for ( int32 ComponentIdx = 0 ; ComponentIdx < Targets . Num ( ) ; ComponentIdx + + )
2021-03-01 12:11:10 -04:00
{
2021-06-23 22:13:32 -04:00
InputMeshes . Add ( UE : : ToolTarget : : GetDynamicMeshCopy ( Targets [ ComponentIdx ] , true ) ) ;
2021-03-01 12:11:10 -04:00
}
2020-10-22 19:19:16 -04:00
check ( ! bDuplicateMode ) ;
GetToolManager ( ) - > BeginUndoTransaction ( LOCTEXT ( " CombineMeshesToolTransactionName " , " Combine Meshes " ) ) ;
AActor * SkipActor = nullptr ;
TArray < UMaterialInterface * > AllMaterials ;
2021-06-23 22:13:32 -04:00
TArray < TArray < int32 > > MaterialIDRemaps ;
BuildCombinedMaterialSet ( AllMaterials , MaterialIDRemaps ) ;
2020-10-22 19:19:16 -04:00
FDynamicMesh3 AccumulateDMesh ;
AccumulateDMesh . EnableTriangleGroups ( ) ;
AccumulateDMesh . EnableAttributes ( ) ;
2021-06-23 22:13:32 -04:00
AccumulateDMesh . Attributes ( ) - > EnableTangents ( ) ;
2020-10-22 19:19:16 -04:00
AccumulateDMesh . Attributes ( ) - > EnableMaterialID ( ) ;
2021-04-19 10:47:52 -04:00
AccumulateDMesh . Attributes ( ) - > EnablePrimaryColors ( ) ;
2020-10-22 19:19:16 -04:00
2021-02-23 18:03:26 -04:00
int32 SkipIndex = ( BasicProperties - > WriteOutputTo = = ECombineTargetType : : FirstInputAsset ) ? 0 : ( Targets . Num ( ) - 1 ) ;
2021-06-23 22:13:32 -04:00
UPrimitiveComponent * UpdateComponent = UE : : ToolTarget : : GetTargetComponent ( Targets [ SkipIndex ] ) ;
SkipActor = UE : : ToolTarget : : GetTargetActor ( Targets [ SkipIndex ] ) ;
2020-10-22 19:19:16 -04:00
2021-06-23 22:13:32 -04:00
UE : : Geometry : : FTransform3d TargetToWorld = ( UE : : Geometry : : FTransform3d ) UE : : ToolTarget : : GetLocalToWorldTransform ( Targets [ SkipIndex ] ) ;
2021-03-18 12:46:27 -04:00
UE : : Geometry : : FTransform3d WorldToTarget = TargetToWorld . Inverse ( ) ;
2020-10-22 19:19:16 -04:00
2021-03-01 12:11:10 -04:00
FSimpleShapeSet3d SimpleCollision ;
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
UE : : Geometry : : FComponentCollisionSettings CollisionSettings ;
2021-06-23 22:13:32 -04:00
bool bOutputComponentSupportsCollision = UE : : Geometry : : ComponentTypeSupportsCollision ( UpdateComponent ) ;
if ( bOutputComponentSupportsCollision )
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
{
2021-06-23 22:13:32 -04:00
CollisionSettings = UE : : Geometry : : GetCollisionSettings ( UpdateComponent ) ;
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
}
2021-03-18 12:46:27 -04:00
TArray < UE : : Geometry : : FTransform3d > Transforms ;
2021-03-01 12:11:10 -04:00
Transforms . SetNum ( 2 ) ;
2020-10-22 19:19:16 -04:00
{
2021-06-02 15:58:00 -04:00
# if WITH_EDITOR
2021-02-23 18:03:26 -04:00
FScopedSlowTask SlowTask ( Targets . Num ( ) + 1 ,
2020-10-22 19:19:16 -04:00
bDuplicateMode ?
LOCTEXT ( " DuplicateMeshBuild " , " Building duplicate mesh ... " ) :
LOCTEXT ( " CombineMeshesBuild " , " Building combined mesh ... " ) ) ;
SlowTask . MakeDialog ( ) ;
2021-06-02 15:58:00 -04:00
# endif
2021-04-19 10:47:52 -04:00
bool bNeedColorAttr = false ;
2021-02-23 18:03:26 -04:00
for ( int32 ComponentIdx = 0 ; ComponentIdx < Targets . Num ( ) ; ComponentIdx + + )
2020-10-22 19:19:16 -04:00
{
2021-06-02 15:58:00 -04:00
# if WITH_EDITOR
2020-10-22 19:19:16 -04:00
SlowTask . EnterProgressFrame ( 1 ) ;
2021-06-02 15:58:00 -04:00
# endif
2021-06-23 22:13:32 -04:00
UPrimitiveComponent * PrimitiveComponent = UE : : ToolTarget : : GetTargetComponent ( Targets [ ComponentIdx ] ) ;
2020-10-22 19:19:16 -04:00
2021-06-23 22:13:32 -04:00
FDynamicMesh3 & ComponentDMesh = InputMeshes [ ComponentIdx ] ;
2021-04-19 10:47:52 -04:00
bNeedColorAttr = bNeedColorAttr | | ( ComponentDMesh . HasAttributes ( ) & & ComponentDMesh . Attributes ( ) - > HasPrimaryColors ( ) ) ;
2020-10-22 19:19:16 -04:00
// update material IDs to account for combined material set
FDynamicMeshMaterialAttribute * MatAttrib = ComponentDMesh . Attributes ( ) - > GetMaterialID ( ) ;
for ( int TID : ComponentDMesh . TriangleIndicesItr ( ) )
{
2021-06-23 22:13:32 -04:00
int MatID = MatAttrib - > GetValue ( TID ) ;
MatAttrib - > SetValue ( TID , MaterialIDRemaps [ ComponentIdx ] [ MatID ] ) ;
2020-10-22 19:19:16 -04:00
}
if ( ComponentIdx ! = SkipIndex )
{
2021-06-23 22:13:32 -04:00
UE : : Geometry : : FTransform3d ComponentToWorld = ( UE : : Geometry : : FTransform3d ) UE : : ToolTarget : : GetLocalToWorldTransform ( Targets [ ComponentIdx ] ) ;
2020-10-22 19:19:16 -04:00
MeshTransforms : : ApplyTransform ( ComponentDMesh , ComponentToWorld ) ;
if ( ComponentToWorld . GetDeterminant ( ) < 0 )
{
ComponentDMesh . ReverseOrientation ( true ) ;
}
MeshTransforms : : ApplyTransform ( ComponentDMesh , WorldToTarget ) ;
if ( WorldToTarget . GetDeterminant ( ) < 0 )
{
ComponentDMesh . ReverseOrientation ( true ) ;
}
2021-03-01 12:11:10 -04:00
Transforms [ 0 ] = ComponentToWorld ;
Transforms [ 1 ] = WorldToTarget ;
2021-06-23 22:13:32 -04:00
if ( bOutputComponentSupportsCollision & & UE : : Geometry : : ComponentTypeSupportsCollision ( PrimitiveComponent ) )
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
{
2021-06-23 22:13:32 -04:00
UE : : Geometry : : AppendSimpleCollision ( PrimitiveComponent , & SimpleCollision , Transforms ) ;
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
}
2021-03-01 12:11:10 -04:00
}
else
{
2021-06-23 22:13:32 -04:00
if ( bOutputComponentSupportsCollision & & UE : : Geometry : : ComponentTypeSupportsCollision ( PrimitiveComponent ) )
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
{
2021-06-23 22:13:32 -04:00
UE : : Geometry : : AppendSimpleCollision ( PrimitiveComponent , & SimpleCollision , UE : : Geometry : : FTransform3d : : Identity ( ) ) ;
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
}
2020-10-22 19:19:16 -04:00
}
FDynamicMeshEditor Editor ( & AccumulateDMesh ) ;
FMeshIndexMappings IndexMapping ;
Editor . AppendMesh ( & ComponentDMesh , IndexMapping ) ;
}
2021-04-19 10:47:52 -04:00
if ( ! bNeedColorAttr )
{
AccumulateDMesh . Attributes ( ) - > DisablePrimaryColors ( ) ;
}
2021-06-02 15:58:00 -04:00
# if WITH_EDITOR
2020-10-22 19:19:16 -04:00
SlowTask . EnterProgressFrame ( 1 ) ;
2021-06-02 15:58:00 -04:00
# endif
2020-10-22 19:19:16 -04:00
2021-06-23 22:13:32 -04:00
FComponentMaterialSet NewMaterialSet ;
NewMaterialSet . Materials = AllMaterials ;
UE : : ToolTarget : : CommitDynamicMeshUpdate ( Targets [ SkipIndex ] , AccumulateDMesh , true , FConversionToMeshDescriptionOptions ( ) , & NewMaterialSet ) ;
2020-10-22 19:19:16 -04:00
2021-06-23 22:13:32 -04:00
if ( bOutputComponentSupportsCollision )
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
{
2021-06-23 22:13:32 -04:00
UE : : Geometry : : SetSimpleCollision ( UpdateComponent , & SimpleCollision , CollisionSettings ) ;
ModelingTools: add support for creating Volumes directly from DrawPolygon, DrawRevolve, DrawPolyPath, and AddPrimitive, CombineMeshes, CutMeshWithMesh, PlaneCut, BaseCreateFromSelected Tools. Improve support for Editing volumes, eg handling mesh/volume interactions, and add configurable auto-simplification for volumes to avoid painful Editor hangs.
- Move ToolTarget implementations, DynamicMeshToVolume to ModelingComponentsEditorOnly module
- move VolumeToDynamicMesh, DynamicMeshProvider/Commiter interfaces to ModelingComponents module
- Add UCreateMeshObjectTypeProperties property set to expose mesh/volume options
- Add FCreateMeshObjectParams::TypeHintClass to allow AVolume type (or other UClass hints) to be passed to creation APIs
- Add UE::ToolTarget::ConfigureCreateMeshObjectParams() util function in ModelingToolTargetUtil, tries to determine output type in a FCreateMeshObjectParams based on input ToolTarget
- Add UEditorModelingObjectsCreationAPI::CreateVolume() implementation
- Add UEditorModelingObjectsCreationAPI::FilterMaterials() that strips out any internal materials and replaces with WorldGridMaterial. This occurs when (eg) subtracting a Volume from a StaticMesh, because the temporary volume mesh gets assigned internal materials, but the Tools don't know this. Use in EditorModelingObjectsCreationAPI when creating new objects. UStaticMeshComponentToolTarget also does this filtering in ::CommitMaterialSetUpdate().
- Add ::ComponentTypeSupportsCollision() function to ComponentCollisionUtil, use to avoid checks/ensures for Volume targets
- Add support for automatic mesh simplification in DynamicMeshToVolume. Add CVar to VolumeDynamicMeshToolTarget.h to control max triangle count (default 500). Apply auto-simplify when creating or updating an AVolume. This prevents the Editor from blocking for long periods on meshes that are too high-res for volumes (even 500 is quite high).
- DynamicMeshToVolume now emits polygroup-faces that contain holes (ie multiple boundary loops) as a set of triangles, rather than emitting separate overlapping faces for each boundary loop
#rb none
#rnx
#jira none
#preflight 60ba50632c42ea0001cb54c5
[CL 16561742 by Ryan Schmidt in ue5-main branch]
2021-06-04 16:04:03 -04:00
}
2021-03-01 12:11:10 -04:00
2020-10-22 19:19:16 -04:00
// select the new actor
ToolSelectionUtil : : SetNewActorSelection ( GetToolManager ( ) , SkipActor ) ;
}
2021-06-02 15:58:00 -04:00
2020-10-22 19:19:16 -04:00
TArray < AActor * > Actors ;
2021-02-23 18:03:26 -04:00
for ( int Idx = 0 ; Idx < Targets . Num ( ) ; Idx + + )
2020-10-22 19:19:16 -04:00
{
2021-06-23 22:13:32 -04:00
AActor * Actor = UE : : ToolTarget : : GetTargetActor ( Targets [ Idx ] ) ;
2020-10-22 19:19:16 -04:00
if ( Actor ! = SkipActor )
{
Actors . Add ( Actor ) ;
}
}
HandleSourceProperties - > ApplyMethod ( Actors , GetToolManager ( ) ) ;
GetToolManager ( ) - > EndUndoTransaction ( ) ;
}
2021-06-23 22:13:32 -04:00
void UCombineMeshesTool : : BuildCombinedMaterialSet ( TArray < UMaterialInterface * > & NewMaterialsOut , TArray < TArray < int32 > > & MaterialIDRemapsOut )
{
NewMaterialsOut . Reset ( ) ;
TMap < UMaterialInterface * , int > KnownMaterials ;
MaterialIDRemapsOut . SetNum ( Targets . Num ( ) ) ;
for ( int32 ComponentIdx = 0 ; ComponentIdx < Targets . Num ( ) ; ComponentIdx + + )
{
FComponentMaterialSet MaterialSet = UE : : ToolTarget : : GetMaterialSet ( Targets [ ComponentIdx ] ) ;
int32 NumMaterials = MaterialSet . Materials . Num ( ) ;
for ( int MaterialIdx = 0 ; MaterialIdx < NumMaterials ; MaterialIdx + + )
{
UMaterialInterface * Mat = MaterialSet . Materials [ MaterialIdx ] ;
int32 NewMaterialIdx = 0 ;
if ( KnownMaterials . Contains ( Mat ) = = false )
{
NewMaterialIdx = NewMaterialsOut . Num ( ) ;
KnownMaterials . Add ( Mat , NewMaterialIdx ) ;
NewMaterialsOut . Add ( Mat ) ;
}
else
{
NewMaterialIdx = KnownMaterials [ Mat ] ;
}
MaterialIDRemapsOut [ ComponentIdx ] . Add ( NewMaterialIdx ) ;
}
}
}
2020-01-27 20:11:15 -05:00
# undef LOCTEXT_NAMESPACE