Files
UnrealEngineUWP/Engine/Plugins/Experimental/MeshModelingToolset/Source/ModelingComponents/Private/BaseTools/SingleSelectionMeshEditingTool.cpp
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

51 lines
1.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "BaseTools/SingleSelectionMeshEditingTool.h"
#include "TargetInterfaces/MaterialProvider.h"
#include "TargetInterfaces/MeshDescriptionCommitter.h"
#include "TargetInterfaces/MeshDescriptionProvider.h"
#include "TargetInterfaces/PrimitiveComponentBackedTarget.h"
#include "ToolTargetManager.h"
/*
* ToolBuilder
*/
const FToolTargetTypeRequirements& USingleSelectionMeshEditingToolBuilder::GetTargetRequirements() const
{
static FToolTargetTypeRequirements TypeRequirements({
UMaterialProvider::StaticClass(),
UMeshDescriptionCommitter::StaticClass(),
UMeshDescriptionProvider::StaticClass(),
UPrimitiveComponentBackedTarget::StaticClass()
});
return TypeRequirements;
}
bool USingleSelectionMeshEditingToolBuilder::CanBuildTool(const FToolBuilderState& SceneState) const
{
return SceneState.TargetManager->CountSelectedAndTargetable(SceneState, GetTargetRequirements()) == 1;
}
UInteractiveTool* USingleSelectionMeshEditingToolBuilder::BuildTool(const FToolBuilderState& SceneState) const
{
USingleSelectionMeshEditingTool* NewTool = CreateNewTool(SceneState);
InitializeNewTool(NewTool, SceneState);
return NewTool;
}
void USingleSelectionMeshEditingToolBuilder::InitializeNewTool(USingleSelectionMeshEditingTool* NewTool, const FToolBuilderState& SceneState) const
{
UToolTarget* Target = SceneState.TargetManager->BuildFirstSelectedTargetable(SceneState, GetTargetRequirements());
check(Target);
NewTool->SetTarget(Target);
NewTool->SetWorld(SceneState.World);
if (WantsInputSelectionIfAvailable() && SceneState.StoredToolSelection != nullptr)
{
NewTool->SetInputSelection(SceneState.StoredToolSelection);
}
}