Files
jimmy andrews 5337719d2e Fix vox offset tool issues:
- Warn about artifacts on meshes with open boundaries
 - Fix some settings not being saved/restored
 - Fix transaction name on undo/redo not matching the tool name

Also: Make the asset warning for base interactive tool only clear the tool's display message if it set a display message when it was last called, so that it is less likely to clear unrelated display messages when called with no warning to display.

#jira UE-180838
#jira UE-180758
#jira UE-180838
#rb rinat.abdrashitov
#preflight 641be32f25389270b7300ae4

[CL 24783364 by jimmy andrews in ue5-main branch]
2023-03-24 14:05:46 -04:00

84 lines
2.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "BaseTools/BaseVoxelTool.h"
#include "InteractiveToolManager.h"
#include "Materials/Material.h"
#include "Materials/MaterialInterface.h"
#include "ToolSetupUtil.h"
#include "ModelingToolTargetUtil.h"
#include "DynamicMesh/DynamicMesh3.h"
#include "Materials/MaterialInstanceDynamic.h"
#include "TargetInterfaces/MeshDescriptionProvider.h"
#include "MeshDescriptionToDynamicMesh.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(BaseVoxelTool)
#define LOCTEXT_NAMESPACE "UBaseVoxelTool"
using namespace UE::Geometry;
void UBaseVoxelTool::SetupProperties()
{
Super::SetupProperties();
VoxProperties = NewObject<UVoxelProperties>(this);
VoxProperties->RestoreProperties(this);
AddToolPropertySource(VoxProperties);
}
void UBaseVoxelTool::SaveProperties()
{
Super::SaveProperties();
VoxProperties->SaveProperties(this);
}
bool UBaseVoxelTool::HasOpenBoundariesInMeshInputs()
{
for (int32 Idx = 0; Idx < OriginalDynamicMeshes.Num(); ++Idx)
{
if (!OriginalDynamicMeshes[Idx]->IsClosed() && OriginalDynamicMeshes[Idx]->TriangleCount() > 0)
{
return true;
}
}
return false;
}
TArray<UMaterialInterface*> UBaseVoxelTool::GetOutputMaterials() const
{
TArray<UMaterialInterface*> Materials;
Materials.Add(LoadObject<UMaterial>(nullptr, TEXT("MATERIAL")));
return Materials;
}
void UBaseVoxelTool::ConvertInputsAndSetPreviewMaterials(bool bSetPreviewMesh)
{
OriginalDynamicMeshes.SetNum(Targets.Num());
for (int ComponentIdx = 0; ComponentIdx < Targets.Num(); ComponentIdx++)
{
OriginalDynamicMeshes[ComponentIdx] = MakeShared<FDynamicMesh3, ESPMode::ThreadSafe>();
FMeshDescriptionToDynamicMesh Converter;
Converter.Convert(UE::ToolTarget::GetMeshDescription(Targets[ComponentIdx]), *OriginalDynamicMeshes[ComponentIdx]);
}
//if (bSetPreviewMesh)
//{
// // TODO: create a low quality preview result for initial display?
//}
Preview->ConfigureMaterials(
ToolSetupUtil::GetDefaultSculptMaterial(GetToolManager()),
ToolSetupUtil::GetDefaultWorkingMaterial(GetToolManager())
);
}
#undef LOCTEXT_NAMESPACE