Files
UnrealEngineUWP/Engine/Plugins/Experimental/MeshModelingToolsetExp/Source/MeshModelingToolsExp/Private/MeshBoundaryToolBase.cpp
ryan schmidt 7c983b8d45 GeometryCore: clean up issues that block non-LWC builds
#rb david.hill
#preflight 620ff48d53204823ae859ccb

#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 19064974 via CL 19076437 via CL 19077315 via CL 19078956
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v921-19075845)

[CL 19122734 by ryan schmidt in ue5-main branch]
2022-02-24 15:01:41 -05:00

73 lines
2.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "MeshBoundaryToolBase.h"
#include "BaseBehaviors/SingleClickBehavior.h"
#include "BaseBehaviors/MouseHoverBehavior.h"
#include "DynamicMesh/DynamicMesh3.h"
#include "InteractiveToolManager.h"
#include "MeshDescriptionToDynamicMesh.h"
#include "Selection/PolygonSelectionMechanic.h"
#include "TargetInterfaces/PrimitiveComponentBackedTarget.h"
#include "ModelingToolTargetUtil.h"
using namespace UE::Geometry;
#define LOCTEXT_NAMESPACE "UMeshBoundaryToolBase"
void UMeshBoundaryToolBase::Setup()
{
USingleSelectionTool::Setup();
if (!Target)
{
return;
}
// create mesh to operate on
OriginalMesh = MakeShared<FDynamicMesh3, ESPMode::ThreadSafe>();
FMeshDescriptionToDynamicMesh Converter;
Converter.Convert( UE::ToolTarget::GetMeshDescription(Target), *OriginalMesh);
// initialize hit query
MeshSpatial.SetMesh(OriginalMesh.Get());
// initialize topology
Topology = MakeUnique<FBasicTopology>(OriginalMesh.Get(), false);
bool bTopologyOK = Topology->RebuildTopology();
// Set up selection mechanic to find and select edges
SelectionMechanic = NewObject<UPolygonSelectionMechanic>(this);
SelectionMechanic->bAddSelectionFilterPropertiesToParentTool = false;
SelectionMechanic->Setup(this);
SelectionMechanic->Properties->bSelectEdges = true;
SelectionMechanic->Properties->bSelectFaces = false;
SelectionMechanic->Properties->bSelectVertices = false;
SelectionMechanic->Initialize(OriginalMesh.Get(),
(FTransform3d)Cast<IPrimitiveComponentBackedTarget>(Target)->GetWorldTransform(),
GetTargetWorld(),
Topology.Get(),
[this]() { return &MeshSpatial; }
);
SelectionMechanic->OnSelectionChanged.AddUObject(this, &UMeshBoundaryToolBase::OnSelectionChanged);
}
void UMeshBoundaryToolBase::OnShutdown(EToolShutdownType ShutdownType)
{
if (SelectionMechanic)
{
SelectionMechanic->Shutdown();
}
}
void UMeshBoundaryToolBase::Render(IToolsContextRenderAPI* RenderAPI)
{
if (SelectionMechanic)
{
SelectionMechanic->Render(RenderAPI);
}
}
#undef LOCTEXT_NAMESPACE