2020-01-27 20:11:15 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "CombineMeshesTool.h"
|
|
|
|
|
#include "InteractiveToolManager.h"
|
|
|
|
|
#include "ToolBuilderUtil.h"
|
|
|
|
|
|
2021-06-13 00:36:02 -04:00
|
|
|
#include "DynamicMesh/DynamicMesh3.h"
|
2020-01-27 20:11:15 -05:00
|
|
|
#include "DynamicMeshEditor.h"
|
2021-06-13 00:36:02 -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
|
|
|
|
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
|
|
|
|
2022-09-28 01:06:15 -04:00
|
|
|
#include UE_INLINE_GENERATED_CPP_BY_NAME(CombineMeshesTool)
|
|
|
|
|
|
2020-01-27 20:11:15 -05:00
|
|
|
#if WITH_EDITOR
|
|
|
|
|
#include "Misc/ScopedSlowTask.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-03-09 19:33:56 -04:00
|
|
|
using namespace UE::Geometry;
|
2020-01-27 20:11:15 -05:00
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "UCombineMeshesTool"
|
|
|
|
|
|
2023-02-01 19:27:27 -05:00
|
|
|
namespace CombineMeshesToolLocals
|
|
|
|
|
{
|
|
|
|
|
void SetNewMaterialID(int32 ComponentIdx, FDynamicMeshMaterialAttribute* MatAttrib, int32 TID,
|
|
|
|
|
TArray<TArray<int32>>& MaterialIDRemaps, TArray<UMaterialInterface*>& AllMaterials)
|
|
|
|
|
{
|
|
|
|
|
int MatID = MatAttrib->GetValue(TID);
|
|
|
|
|
if (!ensure(MatID >= 0))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (MatID >= MaterialIDRemaps[ComponentIdx].Num())
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogGeometry, Warning, TEXT("UCombineMeshesTool: Component %d had at least one material ID (%d) "
|
|
|
|
|
"that was not in its material list."), ComponentIdx, MatID);
|
|
|
|
|
|
|
|
|
|
// There are different things we could do here. It's worth noting that out of bounds material indices
|
|
|
|
|
// are handled differently in static meshes and dynamic mesh components, and depend in part on how we
|
|
|
|
|
// got to that state. So trying to preserve a specific behavior is not practical, and probably not
|
|
|
|
|
// expected if the user is not giving us valid data to begin with.
|
|
|
|
|
// The route we go is to give a separate nullptr material slot to each out of bounds ID. This will give
|
|
|
|
|
// the user a chance to preserve their material assignments while fixing the issue by assigning materials to
|
|
|
|
|
// the slots created in the output (at least, unless they pass through this tool again, at which point any
|
|
|
|
|
// nullptr-pointing IDs will be collapsed to point to the same nullptr slot, due to the way we create the
|
|
|
|
|
// combined material list for in-bounds IDs).
|
|
|
|
|
int32 NumElementsToAdd = MatID - MaterialIDRemaps[ComponentIdx].Num() + 1;
|
|
|
|
|
for (int32 i = 0; i < NumElementsToAdd; ++i)
|
|
|
|
|
{
|
|
|
|
|
MaterialIDRemaps[ComponentIdx].Add(AllMaterials.Num());
|
|
|
|
|
AllMaterials.Add(nullptr);
|
|
|
|
|
}
|
|
|
|
|
checkSlow(MaterialIDRemaps[ComponentIdx].Num() == MatID + 1);
|
|
|
|
|
}
|
|
|
|
|
MatAttrib->SetValue(TID, MaterialIDRemaps[ComponentIdx][MatID]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-27 20:11:15 -05:00
|
|
|
/*
|
|
|
|
|
* ToolBuilder
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2021-11-23 09:42:40 -05:00
|
|
|
UMultiSelectionMeshEditingTool* UCombineMeshesToolBuilder::CreateNewTool(const FToolBuilderState& SceneState) const
|
2020-01-27 20:11:15 -05:00
|
|
|
{
|
|
|
|
|
UCombineMeshesTool* NewTool = NewObject<UCombineMeshesTool>(SceneState.ToolManager);
|
2020-03-09 16:10:47 -04:00
|
|
|
NewTool->SetDuplicateMode(bIsDuplicateTool);
|
2020-01-27 20:11:15 -05:00
|
|
|
return NewTool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Tool
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
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:14:55 -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);
|
|
|
|
|
|
2021-10-28 11:24:32 -04:00
|
|
|
BasicProperties->WatchProperty(BasicProperties->OutputWriteTo, [&](EBaseCreateFromSelectedTargetType NewType)
|
2020-10-22 19:19:16 -04:00
|
|
|
{
|
2021-10-28 11:24:32 -04:00
|
|
|
if (NewType == EBaseCreateFromSelectedTargetType::NewObject)
|
2020-10-22 19:19:16 -04:00
|
|
|
{
|
2021-10-28 11:24:32 -04:00
|
|
|
BasicProperties->OutputExistingName = TEXT("");
|
2021-06-23 22:14:55 -04:00
|
|
|
SetToolPropertySourceEnabled(OutputTypeProperties, true);
|
2020-10-22 19:19:16 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-10-28 11:24:32 -04:00
|
|
|
int32 Index = (BasicProperties->OutputWriteTo == EBaseCreateFromSelectedTargetType::FirstInputObject) ? 0 : Targets.Num() - 1;
|
|
|
|
|
BasicProperties->OutputExistingName = UE::Modeling::GetComponentAssetBaseName(UE::ToolTarget::GetTargetComponent(Targets[Index]), false);
|
2021-06-23 22:14:55 -04:00
|
|
|
SetToolPropertySourceEnabled(OutputTypeProperties, false);
|
2020-10-22 19:19:16 -04:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2021-10-28 11:24:32 -04:00
|
|
|
SetToolPropertySourceEnabled(OutputTypeProperties, BasicProperties->OutputWriteTo == EBaseCreateFromSelectedTargetType::NewObject);
|
2021-06-23 22:14:55 -04:00
|
|
|
|
2020-10-22 19:19:16 -04:00
|
|
|
if (bDuplicateMode)
|
|
|
|
|
{
|
2021-02-08 17:02:09 -04:00
|
|
|
SetToolDisplayName(LOCTEXT("DuplicateMeshesToolName", "Duplicate"));
|
2021-10-28 11:24:32 -04:00
|
|
|
BasicProperties->OutputNewName = 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"));
|
2021-10-28 11:24:32 -04:00
|
|
|
BasicProperties->OutputNewName = FString("Combined");
|
2020-10-22 19:19:16 -04:00
|
|
|
}
|
|
|
|
|
|
2021-10-28 11:24:32 -04:00
|
|
|
HandleSourceProperties = bDuplicateMode
|
|
|
|
|
? static_cast<UOnAcceptHandleSourcesPropertiesBase*>(NewObject<UOnAcceptHandleSourcesPropertiesSingle>(this))
|
|
|
|
|
: static_cast<UOnAcceptHandleSourcesPropertiesBase*>(NewObject<UOnAcceptHandleSourcesProperties>(this));
|
2020-10-22 19:19:16 -04:00
|
|
|
AddToolPropertySource(HandleSourceProperties);
|
|
|
|
|
HandleSourceProperties->RestoreProperties(this);
|
2020-03-10 13:59:45 -04:00
|
|
|
|
|
|
|
|
if (bDuplicateMode)
|
|
|
|
|
{
|
|
|
|
|
GetToolManager()->DisplayMessage(
|
2021-10-28 11:24:32 -04:00
|
|
|
LOCTEXT("OnStartToolDuplicate", "This tool duplicates a single input object to create new objects, and optionally replaces the input object."),
|
2020-03-10 13:59:45 -04:00
|
|
|
EToolMessageLevel::UserNotification);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GetToolManager()->DisplayMessage(
|
2021-10-28 11:24:32 -04:00
|
|
|
LOCTEXT("OnStartToolCombine", "This tool appends multiple input object to create new objects, and optionally replaces the one of the input objects."),
|
2020-03-10 13:59:45 -04:00
|
|
|
EToolMessageLevel::UserNotification);
|
|
|
|
|
}
|
2020-01-27 20:11:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-01-28 18:40:54 -05:00
|
|
|
void UCombineMeshesTool::OnShutdown(EToolShutdownType ShutdownType)
|
2020-01-27 20:11:15 -05:00
|
|
|
{
|
2020-10-22 19:19:16 -04:00
|
|
|
BasicProperties->SaveProperties(this);
|
2021-06-23 22:14:55 -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)
|
|
|
|
|
{
|
2021-10-28 11:24:32 -04:00
|
|
|
if (bDuplicateMode || BasicProperties->OutputWriteTo == EBaseCreateFromSelectedTargetType::NewObject)
|
2020-10-22 19:19:16 -04:00
|
|
|
{
|
|
|
|
|
CreateNewAsset();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
UpdateExistingAsset();
|
|
|
|
|
}
|
2020-01-27 20:11:15 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-28 11:24:32 -04:00
|
|
|
|
2020-10-22 19:19:16 -04:00
|
|
|
void UCombineMeshesTool::CreateNewAsset()
|
2020-01-27 20:11:15 -05:00
|
|
|
{
|
2023-02-01 19:27:27 -05:00
|
|
|
using namespace CombineMeshesToolLocals;
|
|
|
|
|
|
2021-06-23 22:14:55 -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.
|
2024-05-16 04:43:12 -04:00
|
|
|
static FGetMeshParameters GetMeshParams;
|
|
|
|
|
GetMeshParams.bWantMeshTangents = true;
|
2021-06-23 22:14:55 -04:00
|
|
|
TArray<FDynamicMesh3> InputMeshes;
|
|
|
|
|
InputMeshes.Reserve(Targets.Num());
|
2021-03-01 12:11:10 -04:00
|
|
|
for (int32 ComponentIdx = 0; ComponentIdx < Targets.Num(); ComponentIdx++)
|
|
|
|
|
{
|
2024-05-16 04:43:12 -04:00
|
|
|
InputMeshes.Add(UE::ToolTarget::GetDynamicMeshCopy(Targets[ComponentIdx], GetMeshParams));
|
2021-03-01 12:11:10 -04:00
|
|
|
}
|
|
|
|
|
|
2021-06-23 22:14:55 -04:00
|
|
|
GetToolManager()->BeginUndoTransaction( bDuplicateMode ?
|
2020-06-23 18:40:00 -04:00
|
|
|
LOCTEXT("DuplicateMeshToolTransactionName", "Duplicate Mesh") :
|
2021-10-28 11:24:32 -04:00
|
|
|
LOCTEXT("CombineMeshesToolTransactionName", "Merge 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:14:55 -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:14:55 -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:14:55 -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();
|
2022-04-22 19:55:01 -04:00
|
|
|
constexpr bool bCenterPivot = false;
|
|
|
|
|
FVector3d Origin = FVector3d::ZeroVector;
|
|
|
|
|
if (bCenterPivot)
|
|
|
|
|
{
|
|
|
|
|
// Place the pivot at the bounding box center
|
|
|
|
|
Origin = Box.GetCenter();
|
|
|
|
|
}
|
|
|
|
|
else if (!Targets.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
// Use the average pivot
|
|
|
|
|
for (int32 ComponentIdx = 0; ComponentIdx < Targets.Num(); ComponentIdx++)
|
|
|
|
|
{
|
|
|
|
|
Origin += UE::ToolTarget::GetLocalToWorldTransform(Targets[ComponentIdx]).TransformPosition(FVector3d::ZeroVector);
|
|
|
|
|
}
|
|
|
|
|
Origin /= Targets.Num();
|
|
|
|
|
}
|
|
|
|
|
FTransform3d AccumToWorld(Origin);
|
|
|
|
|
FTransform3d ToAccum(-Origin);
|
2020-01-27 20:11:15 -05:00
|
|
|
|
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 ...") :
|
2021-10-28 11:24:32 -04:00
|
|
|
LOCTEXT("CombineMeshesBuild", "Building merged mesh ..."));
|
2020-01-27 20:11:15 -05:00
|
|
|
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:14:55 -04:00
|
|
|
UPrimitiveComponent* PrimitiveComponent = UE::ToolTarget::GetTargetComponent(Targets[ComponentIdx]);
|
2020-01-27 20:11:15 -05:00
|
|
|
|
2021-06-23 22:14:55 -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
|
|
|
|
2022-06-08 23:37:03 -04:00
|
|
|
if (ComponentDMesh.HasAttributes())
|
2021-05-27 18:34:25 -04:00
|
|
|
{
|
2022-06-08 23:37:03 -04:00
|
|
|
AccumulateDMesh.Attributes()->EnableMatchingAttributes(*ComponentDMesh.Attributes(), false);
|
2021-05-27 18:34:25 -04:00
|
|
|
}
|
|
|
|
|
|
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())
|
|
|
|
|
{
|
2023-02-01 19:27:27 -05:00
|
|
|
SetNewMaterialID(ComponentIdx, MatAttrib, TID, MaterialIDRemaps, AllMaterials);
|
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:14:55 -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:14:55 -04:00
|
|
|
CollisionSettings = UE::Geometry::GetCollisionSettings(PrimitiveComponent);
|
2022-01-29 14:37:53 -05:00
|
|
|
UE::Geometry::AppendSimpleCollision(PrimitiveComponent, &SimpleCollision, 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
|
|
|
|
|
{
|
2022-10-17 12:30:43 -04:00
|
|
|
FTransformSRT3d XF = (UE::ToolTarget::GetLocalToWorldTransform(Targets[ComponentIdx]) * ToAccum);
|
|
|
|
|
if (XF.GetDeterminant() < 0)
|
|
|
|
|
{
|
|
|
|
|
ComponentDMesh.ReverseOrientation(false);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-25 19:50:01 -04:00
|
|
|
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:14:55 -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:14:55 -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:14:55 -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);
|
2022-02-24 15:01:41 -05:00
|
|
|
AccumToWorld = (FTransform3d)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
|
2021-10-28 11:24:32 -04:00
|
|
|
FString UseBaseName = BasicProperties->OutputNewName.Left(250);
|
2020-10-22 19:19:16 -04:00
|
|
|
if (UseBaseName.IsEmpty())
|
|
|
|
|
{
|
2021-10-28 11:24:32 -04:00
|
|
|
UseBaseName = (bDuplicateMode) ? TEXT("Duplicate") : TEXT("Merge");
|
2020-10-22 19:19:16 -04:00
|
|
|
}
|
2021-06-02 15:58:00 -04:00
|
|
|
|
|
|
|
|
FCreateMeshObjectParams NewMeshObjectParams;
|
2022-01-28 10:18:10 -05:00
|
|
|
NewMeshObjectParams.TargetWorld = GetTargetWorld();
|
2022-02-24 15:01:41 -05:00
|
|
|
NewMeshObjectParams.Transform = (FTransform)AccumToWorld;
|
2021-06-02 15:58:00 -04:00
|
|
|
NewMeshObjectParams.BaseName = UseBaseName;
|
|
|
|
|
NewMeshObjectParams.Materials = AllMaterials;
|
|
|
|
|
NewMeshObjectParams.SetMesh(&AccumulateDMesh);
|
2021-06-23 22:14:55 -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:14:55 -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()
|
|
|
|
|
{
|
2023-02-01 19:27:27 -05:00
|
|
|
using namespace CombineMeshesToolLocals;
|
|
|
|
|
|
2021-06-23 22:14:55 -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.
|
2024-05-16 04:43:12 -04:00
|
|
|
static FGetMeshParameters GetMeshParams;
|
|
|
|
|
GetMeshParams.bWantMeshTangents = true;
|
2021-06-23 22:14:55 -04:00
|
|
|
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
|
|
|
{
|
2024-05-16 04:43:12 -04:00
|
|
|
InputMeshes.Add(UE::ToolTarget::GetDynamicMeshCopy(Targets[ComponentIdx], GetMeshParams));
|
2021-03-01 12:11:10 -04:00
|
|
|
}
|
|
|
|
|
|
2020-10-22 19:19:16 -04:00
|
|
|
check(!bDuplicateMode);
|
2021-10-28 11:24:32 -04:00
|
|
|
GetToolManager()->BeginUndoTransaction(LOCTEXT("CombineMeshesToolTransactionName", "Merge Meshes"));
|
2020-10-22 19:19:16 -04:00
|
|
|
|
|
|
|
|
AActor* SkipActor = nullptr;
|
|
|
|
|
|
|
|
|
|
TArray<UMaterialInterface*> AllMaterials;
|
2021-06-23 22:14:55 -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:14:55 -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-10-28 11:24:32 -04:00
|
|
|
int32 SkipIndex = (BasicProperties->OutputWriteTo == EBaseCreateFromSelectedTargetType::FirstInputObject) ? 0 : (Targets.Num() - 1);
|
2021-06-23 22:14:55 -04:00
|
|
|
UPrimitiveComponent* UpdateComponent = UE::ToolTarget::GetTargetComponent(Targets[SkipIndex]);
|
|
|
|
|
SkipActor = UE::ToolTarget::GetTargetActor(Targets[SkipIndex]);
|
2020-10-22 19:19:16 -04:00
|
|
|
|
2022-01-29 14:37:53 -05:00
|
|
|
FTransform3d TargetToWorld = UE::ToolTarget::GetLocalToWorldTransform(Targets[SkipIndex]);
|
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:14:55 -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:14:55 -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
|
|
|
}
|
2022-01-29 14:37:53 -05:00
|
|
|
TArray<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 ...") :
|
2021-10-28 11:24:32 -04:00
|
|
|
LOCTEXT("CombineMeshesBuild", "Building merged mesh ..."));
|
2020-10-22 19:19:16 -04:00
|
|
|
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:14:55 -04:00
|
|
|
UPrimitiveComponent* PrimitiveComponent = UE::ToolTarget::GetTargetComponent(Targets[ComponentIdx]);
|
2020-10-22 19:19:16 -04:00
|
|
|
|
2021-06-23 22:14:55 -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())
|
|
|
|
|
{
|
2023-02-01 19:27:27 -05:00
|
|
|
SetNewMaterialID(ComponentIdx, MatAttrib, TID, MaterialIDRemaps, AllMaterials);
|
2020-10-22 19:19:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ComponentIdx != SkipIndex)
|
|
|
|
|
{
|
2022-01-29 14:37:53 -05:00
|
|
|
FTransform3d ComponentToWorld = (FTransform3d)UE::ToolTarget::GetLocalToWorldTransform(Targets[ComponentIdx]);
|
2022-08-30 14:40:56 -04:00
|
|
|
MeshTransforms::ApplyTransform(ComponentDMesh, ComponentToWorld, true);
|
|
|
|
|
MeshTransforms::ApplyTransformInverse(ComponentDMesh, TargetToWorld, true);
|
2021-03-01 12:11:10 -04:00
|
|
|
Transforms[0] = ComponentToWorld;
|
2022-05-12 12:08:26 -04:00
|
|
|
if (TargetToWorld.GetRotation().IsIdentity() || TargetToWorld.GetScale3D().IsUniform())
|
|
|
|
|
{
|
|
|
|
|
// Inverse can be represented by a single FTransform3d
|
|
|
|
|
Transforms[1] = TargetToWorld.Inverse();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Separate inverse into a rotation+translation part and a scale part
|
|
|
|
|
FQuat4d WorldToTargetR = TargetToWorld.GetRotation().Inverse();
|
|
|
|
|
FTransform3d WorldToTargetRT(WorldToTargetR, WorldToTargetR * (-TargetToWorld.GetTranslation()), FVector3d::One());
|
|
|
|
|
FTransform3d WorldToTargetS = FTransform3d::Identity;
|
|
|
|
|
WorldToTargetS.SetScale3D(FTransform3d::GetSafeScaleReciprocal(TargetToWorld.GetScale3D()));
|
|
|
|
|
|
|
|
|
|
Transforms[1] = WorldToTargetRT;
|
|
|
|
|
Transforms.Add(WorldToTargetS);
|
|
|
|
|
}
|
2021-06-23 22:14:55 -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:14:55 -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:14:55 -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
|
|
|
{
|
2022-01-29 14:37:53 -05:00
|
|
|
UE::Geometry::AppendSimpleCollision(PrimitiveComponent, &SimpleCollision, 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:14:55 -04:00
|
|
|
FComponentMaterialSet NewMaterialSet;
|
|
|
|
|
NewMaterialSet.Materials = AllMaterials;
|
|
|
|
|
UE::ToolTarget::CommitDynamicMeshUpdate(Targets[SkipIndex], AccumulateDMesh, true, FConversionToMeshDescriptionOptions(), &NewMaterialSet);
|
2020-10-22 19:19:16 -04:00
|
|
|
|
2022-01-14 18:46:20 -05:00
|
|
|
// CommitDynamicMeshUpdate updates the materials for the underlying asset. However,
|
|
|
|
|
// it does not update the component itself, so address that now.
|
|
|
|
|
UE::ToolTarget::CommitMaterialSetUpdate(Targets[SkipIndex], NewMaterialSet, false);
|
|
|
|
|
|
2021-06-23 22:14:55 -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:14:55 -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:14:55 -04:00
|
|
|
AActor* Actor = UE::ToolTarget::GetTargetActor(Targets[Idx]);
|
2021-10-25 20:05:28 -04:00
|
|
|
Actors.Add(Actor);
|
2020-10-22 19:19:16 -04:00
|
|
|
}
|
2021-10-25 20:05:28 -04:00
|
|
|
HandleSourceProperties->ApplyMethod(Actors, GetToolManager(), SkipActor);
|
2020-10-22 19:19:16 -04:00
|
|
|
|
|
|
|
|
GetToolManager()->EndUndoTransaction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-06-23 22:14:55 -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
|
2022-09-28 01:06:15 -04:00
|
|
|
|