Files
UnrealEngineUWP/Engine/Plugins/Experimental/MeshModelingToolset/Source/ModelingComponents/Public/BaseTools/SingleSelectionMeshEditingTool.h
Ryan Schmidt 7b214c4a33 MeshModeling: add ModelingObjectsCreationAPI, replaces existing usage of IToolsContextAssetAPI in Modeling Tools/Mode
- add new UModelingObjectsCreationAPI and associated data structures, provides abstract API for creating mesh and texture objects from Tools that is not specifically tied to StaticMesh Actors/Assets
- new helper functions in UE::Modeling:: namespace to simplify usage of an implementation of this API registered in a ContextObjectStore
- add new UEditorModelingObjectsCreationAPI implementation of above, supports hooks for higher level to provide custom paths
- add ModelingModeAssetUtils.h, provides several functions in UE::Modeling:: namespace to be used to implement those hooks (various existing path-determination code is moved here)
- ModelingToolsEditorMode now registers an instance of UEditorModelingObjectsCreationAPI in ContextObjectStore and connects up callbacks to these path functions
- AssetGenerationUtil functions and ModelingModeAssetAPI deleted
- All Tools that previously used IToolsContextAssetAPI updated to use this new system

#rb jimmy.andrews
#rnx
#jira none
#preflight 60b7c2ddae46a1000162729b

[CL 16538450 by Ryan Schmidt in ue5-main branch]
2021-06-02 15:58:00 -04:00

93 lines
3.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "SingleSelectionTool.h"
#include "InteractiveToolBuilder.h"
#include "InteractiveToolStorableSelection.h"
#include "SingleSelectionMeshEditingTool.generated.h"
class USingleSelectionMeshEditingTool;
/**
* USingleSelectionMeshEditingToolBuilder is a base tool builder for single
* selection tools that define a common set of ToolTarget interfaces required
* for editing meshes.
*/
UCLASS(Transient, Abstract)
class MODELINGCOMPONENTS_API USingleSelectionMeshEditingToolBuilder : public UInteractiveToolBuilder
{
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 USingleSelectionMeshEditingTool* CreateNewTool(const FToolBuilderState& SceneState) const PURE_VIRTUAL(USingleSelectionMeshEditingToolBuilder::CreateNewTool, return nullptr; );
/** Called by BuildTool to configure the Tool with the input MeshSource based on the SceneState */
virtual void InitializeNewTool(USingleSelectionMeshEditingTool* Tool, const FToolBuilderState& SceneState) const;
/** @return true if this Tool would like access to an available Input Selection object */
virtual bool WantsInputSelectionIfAvailable() const { return false; }
protected:
virtual const FToolTargetTypeRequirements& GetTargetRequirements() const override;
};
/**
* Single Selection Mesh Editing tool base class.
*/
UCLASS()
class MODELINGCOMPONENTS_API USingleSelectionMeshEditingTool : public USingleSelectionTool
{
GENERATED_BODY()
public:
virtual void SetWorld(UWorld* World) { TargetWorld = World; }
protected:
UWorld* TargetWorld = nullptr;
//
// Mesh Selection support
//
public:
/**
* Set a Selection for the Tool to use. This should be called before tool Setup() (ie in the ToolBuilder)
* to allow the Tool to configure it's behavior based on the Selection (which may or may-not exist).
* If the Tool requires a Selection, this needs to be handled at the Builder level.
*/
virtual void SetInputSelection(const UInteractiveToolStorableSelection* StoredToolSelectionIn)
{
InputSelection = StoredToolSelectionIn;
}
/** @return true if an InputSelection is available */
virtual bool HasInputSelection() const
{
return InputSelection != nullptr;
}
/** @return the input Selection, or nullptr if one was not configured */
virtual const UInteractiveToolStorableSelection* GetInputSelection() const
{
return InputSelection;
}
protected:
/**
* (optional) Stored Selection provided on Tool Input. This should never be modified after the Tool's Setup() is called
*/
UPROPERTY()
const UInteractiveToolStorableSelection* InputSelection = nullptr;
};