Files
UnrealEngineUWP/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Public/Selection/PersistentMeshSelection.h
ryan schmidt 70ac55822d ModelingMode: improve interop with new Selection System and existing Tools
Add support for Tools to provide an "output" selection. Add UGeometrySelectionManager::SetSelectionForComponent() which can set an explicit externally-provided selection. FBaseDynamicMeshSelector::UpdateSelectionFromSelection() now supports selection conversion when available and requested (is used to implement SetSelectionForComponent). New GeometrySelectionUtil functions InitializeSelectionFromTriangles() and ConvertSelection() are used to implement this (note: only Triangles->other conversion is currently supported). Add HaveAvailableGeometrySelection() and SetToolOutputGeometrySelectionForTarget() in StoredMeshSelectionUtil.h, this is the top-level function that Tools can use to set an Output selection.

ExtrudeMeshSelectionTool now emits output selection.

Update EditMeshPolygonsTool to use new Selection system and allow individual operations to be utilized as standalone Tools. Convert EditMeshPolygonsTool to be a USingleTargetWithSelectionTool, use FGeometrySelection to initialize selection. Add bTerminateOnPendingActionComplete flag, which is set when Tool is directly initialized to a specific operation, and forces tool to shut down when operation completes. This allows it to be used to more cleanly implement multiple action buttons in Modeling UI. When in this mode, selection panels are not shown. On Shutdown, now emits an "output" selection which GeometrySelectionManager can use to provide new selection to user. Update UPolygonSelectionMechanic Set/Get selection APIs to use FGeometrySelection instead of UPersistentMeshSelection.

port UVProjectionTool to derive from USingleTargetWithSelectionTool, use FGeometrySelection to initialize target ROI

deprecate UPersistentMeshSelection and related functions in StoredMeshSelectionUtil.h. Deprecate Tool Input Selection APIs in USingleSelectionMeshEditingTool and Builder.

Repurpose old ModelingMode-level PolyModel tab operations for new Selection Tools UI, now support Inset, Outset, Cut Faces, Insert Edge Loop, PushPull, and Bevel.

#rb none
#preflight 63c84fa2b065224750b9831f

[CL 23766643 by ryan schmidt in ue5-main branch]
2023-01-18 17:59:31 -05:00

146 lines
4.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "IndexTypes.h"
#include "SegmentTypes.h"
#include "PersistentMeshSelection.generated.h"
class UPrimitiveComponent;
class UInteractiveTool;
PREDECLARE_USE_GEOMETRY_STRUCT(FGroupTopologySelection);
PREDECLARE_USE_GEOMETRY_CLASS(FGroupTopology);
PREDECLARE_USE_GEOMETRY_CLASS(FCompactMaps);
/**
* FGenericMeshSelection represents various types of selection on a Mesh.
* This includes various types of indices that could be interpreted in different ways.
*
* In addition, "Render" geometry is stored, which can be used by higher-level
* code to draw the selection in some way (eg a selection highlight)
*
* @warning this class is likely to change in the future
*/
struct MODELINGCOMPONENTS_API FGenericMeshSelection
{
// selection type
enum class ETopologyType
{
FGroupTopology,
FTriangleGroupTopology,
FUVGroupTopology,
};
//
// Selection representation (may be interpreted differently depending on TopologyType)
//
// selection type
ETopologyType TopologyType = ETopologyType::FGroupTopology;
// selected vertices or "corners" (eg of polygroup topology)
TArray<int32> VertexIDs;
// selected edges, represented as index pairs because for many selections,
// using a pair of vertices defining/on the edge is more reliable (due to unstable edge IDs)
TArray<UE::Geometry::FIndex2i> EdgeIDs;
// selected triangles/faces/regions
TArray<int32> FaceIDs;
//
// Selection Target Information
//
// Component this selection applies to (eg that owns mesh, etc)
UPrimitiveComponent* SourceComponent = nullptr;
//
// Renderable Selection Representation
//
// set of 3D points representing selection (in world space)
TArray<FVector3d> RenderVertices;
// set of 3D lines representing selection (in world space)
TArray<UE::Geometry::FSegment3d> RenderEdges;
/** @return selected GroupIDs */
const TArray<int32>& GetGroupIDs() const { return FaceIDs; }
/** @return true if selection is empty */
bool IsEmpty() const
{
return VertexIDs.IsEmpty() && EdgeIDs.IsEmpty() && FaceIDs.IsEmpty();
}
/** @return true if selection has 3D lines that can be rendered */
bool HasRenderableLines() const { return RenderEdges.Num() > 0; }
bool operator==(const FGenericMeshSelection& Other) const
{
return SourceComponent == Other.SourceComponent
&& TopologyType == Other.TopologyType
&& VertexIDs == Other.VertexIDs
&& EdgeIDs == Other.EdgeIDs
&& FaceIDs == Other.FaceIDs;
}
};
/**
* UPersistentMeshSelection is a UObject wrapper for a FGenericMeshSelection
*/
//UE_DEPRECATED(5.2, "UPersistentMeshSelection and related functions are deprecated")
UCLASS(Deprecated)
class MODELINGCOMPONENTS_API UDEPRECATED_PersistentMeshSelection : public UObject
{
GENERATED_BODY()
public:
/**
* Resets the contents of the object using the given selection.
*
* @param CompactMaps If the mesh was compacted without updating the passed in topology object, these
* maps will be used to give an object that will work with the new mesh vids.
*/
void SetSelection(const FGroupTopology& TopologyIn, const FGroupTopologySelection& SelectionIn, const FCompactMaps* CompactMaps = nullptr);
/**
* Initializes a FGroupTopologySelection using the current contents of the object. The topology
* must already be initialized.
*/
void ExtractIntoSelectionObject(const FGroupTopology& TopologyIn, FGroupTopologySelection& SelectionOut) const;
/** @return true if the selection is empty */
bool IsEmpty() const
{
return Selection.IsEmpty();
}
UPrimitiveComponent* GetTargetComponent() const { return Selection.SourceComponent; }
FGenericMeshSelection::ETopologyType GetSelectionType() const { return Selection.TopologyType; }
/** replace the internal Selection data */
void SetSelection(const FGenericMeshSelection& SelectionIn) { Selection = SelectionIn; }
/** @return the internal Selection data */
const FGenericMeshSelection& GetSelection() const { return Selection; }
protected:
FGenericMeshSelection Selection;
};