Files
UnrealEngineUWP/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Public/Selection/SelectionEditInteractiveCommand.h
Ryan Schmidt 6032c02f0e ModelingMode: add Delete command for current Mesh Selection
ToolsFramework:
add UInteractiveCommand and UInteractiveCommandArguments types, base classes for 'interactive commands' which are intended to be used for atomic actions, ie stateless, no user interaction, etc
ModelingComponents:
add UGeometrySelectionEditCommand/Arguments, this is a UInteractiveCommand that uses a FGeometrySelection as an argument
add UGeometrySelectionManager::CanExecuteSelectionCommand() and ExecuteSelectionCommand()

MeshModelingTools:
add UDeleteGeometrySelectionCommand, deletes selected mesh geometry by converting input selection to list of triangles

ModelingToolsEditorMode:
add Delete command to ModelingMode and UI. ModelingToolsEditorMode currently is keeping active command set alive via new UModelingToolsEditorMode::ModelingModeCommands member.

#rb none
#preflight 62d195b9a66919b6701d89a8

[CL 21113757 by Ryan Schmidt in ue5-main branch]
2022-07-15 13:49:13 -04:00

79 lines
2.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "InteractiveCommand.h"
#include "Selection/GeometrySelector.h" // for FGeometrySelectionHandle
#include "SelectionEditInteractiveCommand.generated.h"
/**
* Arguments for a UGeometrySelectionEditCommand
*/
UCLASS()
class MODELINGCOMPONENTS_API UGeometrySelectionEditCommandArguments : public UInteractiveCommandArguments
{
GENERATED_BODY()
public:
FGeometrySelectionHandle SelectionHandle;
bool IsSelectionEmpty() const
{
return SelectionHandle.Selection == nullptr || SelectionHandle.Selection->IsEmpty();
}
bool IsMatchingType(FGeometryIdentifier::ETargetType TargetType, FGeometryIdentifier::EObjectType EngineType) const
{
return SelectionHandle.Identifier.TargetType == TargetType
|| SelectionHandle.Identifier.ObjectType == EngineType;
}
};
/**
* UGeometrySelectionEditCommand is a command that edits geometry based on a selection.
* Requires a UGeometrySelectionEditCommandArguments
*/
UCLASS(Abstract)
class MODELINGCOMPONENTS_API UGeometrySelectionEditCommand : public UInteractiveCommand
{
GENERATED_BODY()
public:
virtual bool AllowEmptySelection() const { return false; }
virtual bool CanExecuteCommandForSelection(UGeometrySelectionEditCommandArguments* SelectionArgs)
{
return false;
}
virtual void ExecuteCommandForSelection(UGeometrySelectionEditCommandArguments* Arguments)
{
}
public:
// UInteractiveCommand API
virtual bool CanExecuteCommand(UInteractiveCommandArguments* Arguments) override
{
UGeometrySelectionEditCommandArguments* SelectionArgs = Cast<UGeometrySelectionEditCommandArguments>(Arguments);
if (SelectionArgs && (SelectionArgs->IsSelectionEmpty() == false || AllowEmptySelection()) )
{
return CanExecuteCommandForSelection(SelectionArgs);
}
return false;
}
virtual void ExecuteCommand(UInteractiveCommandArguments* Arguments) override
{
UGeometrySelectionEditCommandArguments* SelectionArgs = Cast<UGeometrySelectionEditCommandArguments>(Arguments);
if ( SelectionArgs && (SelectionArgs->IsSelectionEmpty() == false || AllowEmptySelection()) )
{
ExecuteCommandForSelection(SelectionArgs);
}
}
};