Files
UnrealEngineUWP/Engine/Plugins/Experimental/MeshModelingToolsetExp/Source/MeshModelingToolsExp/Private/DynamicMeshBrushTool.cpp
bryan sefcik 50d4fac9e0 Updated ../Engine/Plugins/... to inline gen.cpp files
Before:
3548 unity files
Total CPU Time: 47343.578125 s
Total time in Parallel executor: 494.60 seconds

After:
3445 unity files
Total CPU Time: 46044.671875 s
Total time in Parallel executor: 468.51 seconds

#jira
#preflight 63336159b20e73a098b7f24f

[CL 22218213 by bryan sefcik in ue5-main branch]
2022-09-28 01:06:15 -04:00

93 lines
2.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "DynamicMeshBrushTool.h"
#include "InteractiveToolManager.h"
#include "ToolBuilderUtil.h"
#include "ToolSetupUtil.h"
#include "ModelingToolTargetUtil.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(DynamicMeshBrushTool)
using namespace UE::Geometry;
// localization namespace
#define LOCTEXT_NAMESPACE "UDynamicMeshBrushTool"
/*
* Tool
*/
UDynamicMeshBrushTool::UDynamicMeshBrushTool()
{
}
void UDynamicMeshBrushTool::Setup()
{
PreviewMesh = NewObject<UPreviewMesh>(this);
PreviewMesh->bBuildSpatialDataStructure = true;
PreviewMesh->CreateInWorld(GetTargetWorld(), FTransform::Identity);
FTransformSRT3d LocalToWorldTransform = UE::ToolTarget::GetLocalToWorldTransform(Target);
PreviewMesh->SetTransform((FTransform)LocalToWorldTransform);
ToolSetupUtil::ApplyRenderingConfigurationToPreview(PreviewMesh, Target);
FComponentMaterialSet MaterialSet = UE::ToolTarget::GetMaterialSet(Target);
PreviewMesh->SetMaterials(MaterialSet.Materials);
PreviewMesh->ReplaceMesh(UE::ToolTarget::GetDynamicMeshCopy(Target));
OnBaseMeshComponentChangedHandle = PreviewMesh->GetOnMeshChanged().Add(
FSimpleMulticastDelegate::FDelegate::CreateUObject(this, &UDynamicMeshBrushTool::OnBaseMeshComponentChanged));
// call this here so that base tool can estimate target dimension
InputMeshBoundsLocal = PreviewMesh->GetPreviewDynamicMesh()->GetBounds();
double ScaledDim = LocalToWorldTransform.TransformVector(FVector::OneVector).Size();
this->WorldToLocalScale = FMathd::Sqrt3 / FMathd::Max(FMathf::ZeroTolerance, ScaledDim);
UBaseBrushTool::Setup();
UE::ToolTarget::HideSourceObject(Target);
}
double UDynamicMeshBrushTool::EstimateMaximumTargetDimension()
{
return InputMeshBoundsLocal.MaxDim();
}
void UDynamicMeshBrushTool::Shutdown(EToolShutdownType ShutdownType)
{
UBaseBrushTool::Shutdown(ShutdownType);
UE::ToolTarget::ShowSourceObject(Target);
if (PreviewMesh != nullptr)
{
PreviewMesh->GetOnMeshChanged().Remove(OnBaseMeshComponentChangedHandle);
OnShutdown(ShutdownType);
PreviewMesh->SetVisible(false);
PreviewMesh->Disconnect();
PreviewMesh = nullptr;
}
}
bool UDynamicMeshBrushTool::HitTest(const FRay& Ray, FHitResult& OutHit)
{
return PreviewMesh->FindRayIntersection(FRay3d(Ray), OutHit);
}
#undef LOCTEXT_NAMESPACE