Files
matija kecman 77a219bd26 Add a reusable geometry selection visualization system intended to be used in modeling tools with minimal boilerplate
This CL was reviewed here: https://p4-swarm.epicgames.net/reviews/26051575 but needs to be merged into //Fortnite/Release-26.00, not //Fortnite/Main

#jira UE-183457
#rb ryan.schmidt, nathan.mitchell

[CL 26180612 by matija kecman in 5.3 branch]
2023-06-22 09:26:09 -04:00

79 lines
2.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "SingleSelectionTool.h"
#include "InteractiveToolBuilder.h"
#include "Selections/GeometrySelection.h"
#include "SingleTargetWithSelectionTool.generated.h"
class UPreviewGeometry;
class UGeometrySelectionVisualizationProperties;
PREDECLARE_GEOMETRY(class FDynamicMesh3)
PREDECLARE_GEOMETRY(class FGroupTopology)
UCLASS(Transient, Abstract)
class MODELINGCOMPONENTS_API USingleTargetWithSelectionToolBuilder : public UInteractiveToolWithToolTargetsBuilder
{
GENERATED_BODY()
public:
/** @return true if a single mesh source can be found in the active selection */
virtual bool CanBuildTool(const FToolBuilderState& SceneState) const override;
/** @return new Tool instance initialized with selected mesh source */
virtual UInteractiveTool* BuildTool(const FToolBuilderState& SceneState) const override;
/** @return new Tool instance. Override this in subclasses to build a different Tool class type */
virtual USingleTargetWithSelectionTool* CreateNewTool(const FToolBuilderState& SceneState) const PURE_VIRTUAL(USingleTargetWithSelectionToolBuilder::CreateNewTool, return nullptr; );
/** Called by BuildTool to configure the Tool with the input MeshSource based on the SceneState */
virtual void InitializeNewTool(USingleTargetWithSelectionTool* Tool, const FToolBuilderState& SceneState) const;
/** @return true if this Tool requires an input selection */
virtual bool RequiresInputSelection() const { return false; }
protected:
virtual const FToolTargetTypeRequirements& GetTargetRequirements() const override;
};
UCLASS()
class MODELINGCOMPONENTS_API USingleTargetWithSelectionTool : public USingleSelectionTool
{
GENERATED_BODY()
public:
virtual void Shutdown(EToolShutdownType ShutdownType) override;
virtual void OnShutdown(EToolShutdownType ShutdownType);
virtual void OnTick(float DeltaTime) override;
virtual void SetTargetWorld(UWorld* World);
virtual UWorld* GetTargetWorld();
protected:
UPROPERTY()
TWeakObjectPtr<UWorld> TargetWorld = nullptr;
public:
virtual void SetGeometrySelection(const UE::Geometry::FGeometrySelection& SelectionIn);
virtual void SetGeometrySelection(UE::Geometry::FGeometrySelection&& SelectionIn);
/** @return true if a Selection is available */
virtual bool HasGeometrySelection() const;
/** @return the input Selection */
virtual const UE::Geometry::FGeometrySelection& GetGeometrySelection() const;
protected:
UE::Geometry::FGeometrySelection GeometrySelection;
bool bGeometrySelectionInitialized = false;
UPROPERTY()
TObjectPtr<UGeometrySelectionVisualizationProperties> GeometrySelectionVizProperties = nullptr;
UPROPERTY()
TObjectPtr<UPreviewGeometry> GeometrySelectionViz = nullptr;
};