2020-08-11 01:36:57 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "BaseTools/BaseVoxelTool.h"
|
|
|
|
|
#include "InteractiveToolManager.h"
|
|
|
|
|
#include "ToolSetupUtil.h"
|
2021-11-23 09:42:40 -05:00
|
|
|
#include "ModelingToolTargetUtil.h"
|
2021-06-13 00:36:02 -04:00
|
|
|
#include "DynamicMesh/DynamicMesh3.h"
|
2021-10-28 19:47:45 -04:00
|
|
|
#include "Materials/MaterialInstanceDynamic.h"
|
2020-08-11 01:36:57 -04:00
|
|
|
|
2021-11-23 09:42:40 -05:00
|
|
|
#include "TargetInterfaces/MeshDescriptionProvider.h"
|
|
|
|
|
|
2020-08-11 01:36:57 -04:00
|
|
|
#include "MeshDescriptionToDynamicMesh.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "UBaseVoxelTool"
|
|
|
|
|
|
2021-03-09 19:33:56 -04:00
|
|
|
using namespace UE::Geometry;
|
2020-08-11 01:36:57 -04:00
|
|
|
|
|
|
|
|
void UBaseVoxelTool::SetupProperties()
|
|
|
|
|
{
|
|
|
|
|
Super::SetupProperties();
|
|
|
|
|
VoxProperties = NewObject<UVoxelProperties>(this);
|
|
|
|
|
VoxProperties->RestoreProperties(this);
|
|
|
|
|
AddToolPropertySource(VoxProperties);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBaseVoxelTool::SaveProperties()
|
|
|
|
|
{
|
|
|
|
|
Super::SaveProperties();
|
|
|
|
|
VoxProperties->SaveProperties(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TArray<UMaterialInterface*> UBaseVoxelTool::GetOutputMaterials() const
|
|
|
|
|
{
|
|
|
|
|
TArray<UMaterialInterface*> Materials;
|
|
|
|
|
Materials.Add(LoadObject<UMaterial>(nullptr, TEXT("MATERIAL")));
|
|
|
|
|
return Materials;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBaseVoxelTool::ConvertInputsAndSetPreviewMaterials(bool bSetPreviewMesh)
|
|
|
|
|
{
|
2021-03-11 11:40:03 -04:00
|
|
|
OriginalDynamicMeshes.SetNum(Targets.Num());
|
2020-08-11 01:36:57 -04:00
|
|
|
|
2021-03-11 11:40:03 -04:00
|
|
|
for (int ComponentIdx = 0; ComponentIdx < Targets.Num(); ComponentIdx++)
|
2020-08-11 01:36:57 -04:00
|
|
|
{
|
2021-02-17 11:50:23 -04:00
|
|
|
OriginalDynamicMeshes[ComponentIdx] = MakeShared<FDynamicMesh3, ESPMode::ThreadSafe>();
|
2020-08-11 01:36:57 -04:00
|
|
|
FMeshDescriptionToDynamicMesh Converter;
|
2021-11-23 09:42:40 -05:00
|
|
|
Converter.Convert(UE::ToolTarget::GetMeshDescription(Targets[ComponentIdx]), *OriginalDynamicMeshes[ComponentIdx]);
|
2020-08-11 01:36:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if (bSetPreviewMesh)
|
|
|
|
|
//{
|
|
|
|
|
// // TODO: create a low quality preview result for initial display?
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
Preview->ConfigureMaterials(
|
|
|
|
|
ToolSetupUtil::GetDefaultSculptMaterial(GetToolManager()),
|
|
|
|
|
ToolSetupUtil::GetDefaultWorkingMaterial(GetToolManager())
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|