You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Renamed lots of UI text and tooltips to improve UX - Hid the 'Propagate' and 'Per Instance' buttons until this feature is properly supported - Flipped radio buttons so they're on top of 'instant' buttons - Renamed 'Any' to 'Mesh' in the top level UI (meaning, 'any part of the mesh') - Added group name title text for 'Mesh', 'Polygon', 'Edge', 'Vertex' - Reversed order of top level buttons, removed 'Select' label - 'Remove Subdivision Level' now greys out if there is nothing already subdivided - Fixed lots of non-unity build issues #codereview richard.talbotwatkin #rb none [CL 3509887 by Mike Fricker in Dev-Geometry branch]
119 lines
3.8 KiB
C++
119 lines
3.8 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "RemoveEdge.h"
|
|
#include "IMeshEditorModeEditingContract.h"
|
|
#include "IMeshEditorModeUIContract.h"
|
|
#include "UICommandInfo.h"
|
|
#include "EditableMesh.h"
|
|
#include "MeshElement.h"
|
|
#include "Framework/Multibox/MultiBoxBuilder.h"
|
|
#include "ScopedTransaction.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "MeshEditorMode"
|
|
|
|
|
|
void URemoveEdgeCommand::RegisterUICommand( FBindingContext* BindingContext )
|
|
{
|
|
UI_COMMAND_EXT( BindingContext, /* Out */ UICommandInfo, "RemoveEdge", "Remove", "Attempts to remove the selected edge and merge adjacent polygons.", EUserInterfaceActionType::Button, FInputChord( EKeys::BackSpace ) );
|
|
}
|
|
|
|
|
|
void URemoveEdgeCommand::Execute( IMeshEditorModeEditingContract& MeshEditorMode )
|
|
{
|
|
if( MeshEditorMode.GetActiveAction() != NAME_None )
|
|
{
|
|
return;
|
|
}
|
|
|
|
static TMap< UEditableMesh*, TArray< FMeshElement > > MeshesWithEdgesToRemove;
|
|
MeshEditorMode.GetSelectedMeshesAndEdges( MeshesWithEdgesToRemove );
|
|
|
|
// @todo mesheditor: Only if one edge is selected, for now. It gets a bit confusing when performing this operation
|
|
// with more than one edge selected. However, it can be very useful when collapsing away edges that don't share any
|
|
// common polygons, so we should try to support it.
|
|
if( MeshesWithEdgesToRemove.Num() != 1 )
|
|
{
|
|
const auto& FirstMeshWithEdges = MeshesWithEdgesToRemove.CreateConstIterator();
|
|
if( FirstMeshWithEdges->Get<1>().Num() != 1 )
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
FScopedTransaction Transaction( LOCTEXT( "UndoRemoveEdge", "Remove Edge" ) );
|
|
|
|
MeshEditorMode.CommitSelectedMeshes();
|
|
|
|
// Refresh selection (committing may have created a new mesh instance)
|
|
MeshEditorMode.GetSelectedMeshesAndEdges( MeshesWithEdgesToRemove );
|
|
|
|
MeshEditorMode.DeselectMeshElements( MeshesWithEdgesToRemove );
|
|
|
|
TArray<FMeshElement> MeshElementsToSelect;
|
|
for( const auto& MeshAndElements : MeshesWithEdgesToRemove )
|
|
{
|
|
UEditableMesh* EditableMesh = MeshAndElements.Key;
|
|
|
|
EditableMesh->StartModification( EMeshModificationType::Final, EMeshTopologyChange::TopologyChange );
|
|
|
|
const TArray<FMeshElement>& EdgeElementsToRemove = MeshAndElements.Value;
|
|
|
|
for( const FMeshElement& EdgeElementToRemove : EdgeElementsToRemove )
|
|
{
|
|
const FEdgeID EdgeID( EdgeElementToRemove.ElementAddress.ElementID );
|
|
{
|
|
bool bWasEdgeRemoved = false;
|
|
FPolygonID NewPolygonID;
|
|
|
|
EditableMesh->TryToRemovePolygonEdge( EdgeID, /* Out */ bWasEdgeRemoved, /* Out */ NewPolygonID );
|
|
|
|
if( bWasEdgeRemoved )
|
|
{
|
|
// Select the new polygon
|
|
FMeshElement NewPolygonMeshElement;
|
|
{
|
|
NewPolygonMeshElement.Component = EdgeElementToRemove.Component;
|
|
NewPolygonMeshElement.ElementAddress = EdgeElementToRemove.ElementAddress;
|
|
NewPolygonMeshElement.ElementAddress.ElementType = EEditableMeshElementType::Polygon;
|
|
NewPolygonMeshElement.ElementAddress.ElementID = NewPolygonID;
|
|
}
|
|
|
|
MeshElementsToSelect.Add( NewPolygonMeshElement );
|
|
}
|
|
else
|
|
{
|
|
// Couldn't remove the edge
|
|
// @todo mesheditor: Needs good user feedback when this happens
|
|
}
|
|
}
|
|
}
|
|
|
|
EditableMesh->EndModification();
|
|
|
|
MeshEditorMode.TrackUndo( EditableMesh, EditableMesh->MakeUndo() );
|
|
}
|
|
|
|
// Select the polygon leftover after removing the edge
|
|
MeshEditorMode.SelectMeshElements( MeshElementsToSelect );
|
|
}
|
|
|
|
|
|
void URemoveEdgeCommand::AddToVRRadialMenuActionsMenu( IMeshEditorModeUIContract& MeshEditorMode, FMenuBuilder& MenuBuilder, TSharedPtr<FUICommandList> CommandList, const FName TEMPHACK_StyleSetName, class UVREditorMode* VRMode )
|
|
{
|
|
if( MeshEditorMode.GetMeshElementSelectionMode() == EEditableMeshElementType::Edge )
|
|
{
|
|
MenuBuilder.AddMenuEntry(
|
|
LOCTEXT( "VRRemoveEdge", "Remove" ),
|
|
FText(),
|
|
FSlateIcon( TEMPHACK_StyleSetName, "MeshEditorMode.EdgeRemove" ),
|
|
MakeUIAction( MeshEditorMode ),
|
|
NAME_None,
|
|
EUserInterfaceActionType::CollapsedButton
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|
|
|