2019-12-27 07:44:07 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2017-03-31 14:31:36 -04:00
# include "RemoveEdge.h"
# include "IMeshEditorModeEditingContract.h"
# include "IMeshEditorModeUIContract.h"
2018-02-14 14:13:42 -05:00
# include "Framework/Commands/UICommandInfo.h"
2017-03-31 14:31:36 -04:00
# include "EditableMesh.h"
# include "MeshElement.h"
2018-02-22 08:31:06 -05:00
# include "Framework/MultiBox/MultiBoxBuilder.h"
Copying //Tasks/UE4/Dev-Geometry-Refactor to Dev-Geometry (//UE4/Dev-Geometry)
CL 3365379:
Beginnings of 'uber mesh'. Moved mesh description across to UEditableMesh. Renamed Rendering Vertices to Vertex Instances, they will form a fundamental part of the mesh description, in representing shared vertices.
CL 3365385:
Renamed Sections to PolygonGroups. This prevents confusion between editable mesh sections and rendering sections (from the static mesh). It also means we can potentially open up the concept of 'polygon groups' to represent more than static mesh sections if we wish to.
CL 3365387:
Removed FPolygonRef and flattened Polygons container. Added new methods to act on the entire Polygons container. Added RenderingPolygons, RenderingTriangles, RenderingPolygonGroups containers which will eventually live on the adapter, and which are solely involved in maintaining the render buffers. Fixed Quadrangulate so that it doesn't merge across polygon groups.
CL 3365390:
Started to remove virtuals from EditableMesh. First separation of ubermesh intrinsic properties from implementation details in EditableStaticMesh.
CL 3396167:
Picking out generic functionality from the _Internal methods, moving them into UEditableMesh code, ready to remove the inheritance entirely. Implemented adapter interface (currently living within UEditableStaticMesh) and calling into it from UEditableMesh.
Big revamp to handling of rendering vertices; now exist as vertex instances, which are dynamically shared / split, depending on whether colors / textures are identical. Normal/tangent is handled separately as it is autogenerated. Whether neighboring edges are hard or not determines whether a vertex will be automatically instanced, regardless of other attributes. We infer whether a vertex is 'hard' from whether the mesh is split by hard edges at that point (done by tracing adjacent polygons through only soft edges); hard vertices are always instanced for that poly. This simplifies the autogeneration of normals, as it now simply iterates through stale vertex instances, applying the weighted contribution from each connected polygon. Polygon normals are now cached as a read-only attribute, to make this process even quicker.
Rewrite of the basic primitive operations (Create/Delete polygon / edges / vertices / vertex instances). Added a new primitive operation to substitute vertex instances on a polygon contour. Setting edge hardness attribute now potentially instances or deletes vertex instances, as does setting vertex instance attributes.
CL 3396229:
Intermediate check-in (phase 2).
Removed a whole load of dead code. Broke functionality, until InitEditableStaticMesh is rewritten to use the public UEditableMesh API.
CL 3401798:
Intermediate check-in (phase 3).
Implemented a simple alternative to tangent basis generation as MikkTSpace doesn't quite fit our model currently (but with a view to revisiting it in the future; nothing has been removed for now).
Fixed edge hardness setting.
Added missing hash function for FVertexInstanceID.
CL 3403360:
Fixed some bugs in tangent/normal handling. Now correctly includes contributions from adjacent polygons in the same smoothing group but different vertex instance when calculating a vertex instance normal.
CL 3411429:
Fixed a bunch of bugs:
- Fixed issue where adjacent polygons the other side of a UV seam were not contributing to vertex instance normal calculation.
- Fixed various issues where out arrays weren't being reset, and mesh change actions were not being called after setting up the input array.
- Various changes to converting static meshes to editable meshes.
- Removed old ContourVertices arrays from polygon contours; now polygons exclusively use an array of vertex instances.
- Updated natvis to parse new element ID types.
CL 3418022:
More bug fixes:
- Sorted an issue with undo where vertex instance merging / splitting was happening twice, once due to the parent operation, and another time due to the revert transactions which are created.
- Added options to delete orphaned vertex instances in DeletePolygons and other operations which remove vertex instances.
- Fixed issue with SplitEdge due to subtle bug where connected edges were duplicated in a vertex, instead of being added uniquely.
- Changed order that undo items are added to the stack so that the revert operation works smoothly.
CL 3427887:
Fixed issue which occurs in certain circumstances with Split Edge.
Fixed regression which was causing various operations to fail when setting edge hardness.
CL 3430665:
Specify polygon edge hardness policy when creating a polygon. Simplified some existing uses of CreatePolygons. Changed behavior to match original behavior so that only *new* edge IDs are returned by CreatePolygons.
CL 3430927:
Corrected normal/tangent generation for polygons and adjacent polygons.
CL 3431134:
Fixed small issue with remove vertex in certain circumstances.
CL 3446929:
- Added a triangle list to the FMeshPolygon struct, making triangulation a first-class operation instead of an implementation detail.
- Repurposed UEditableStaticMesh as an editable mesh adapter, in a separate class hierarchy.
- Tidied up interfaces
- Moved serialization, compact/uncompact into UEditableMesh
- Currently broken: instance changes. This is pending a rethink on how we scope objects in the assets.
CL 3446954:
Renamed EditableStaticMesh.* to EditableStaticMeshAdapter.* to reflect its new role and place in the class hierarchy.
CL 3449133:
Fixed issue with splitting vertices due to the wrong polygon ID being used by GetPolygonsInSameSmoothingGroup. Also fixed an error where the list being iterated was potentially being mutated by the split operation.
CL 3449362:
Fixed ChangePolygonsVertexInstances to fix up the triangle list after replacing vertex instances. Not sure where this code went!
CL 3458823:
- Deferred normals calculation until the end of the transaction for efficiency
- Fixed a bug in inserting edge loops
- Fixed a bug in splitting vertex instances when hardening an edge
- Moved verbose logging into a LogEditableMesh category.
CL 3461128:
Included a bunch of required header files (IWYU).
CL 3464397:
Change to handling of triangulation and normal/tangent generation. Now this is done as a deferred process during EndTransaction. This achieves three goals:
1) Polygons are not repeatedly triangulated unnecessarily as a consequence of suboperations.
2) We are able to calculate and cache the polygon tangent basis upfront, which is then used for every connected vertex instance tangent basis - this is quickerthan repeatedly calculating it each time it's needed.
3) We no longer need to treat triangulation or vertex generation as a special FChange. Instead it is rolled into the FStartOrEndTransaction change. Hence we can remove the awkward code which was triangulating polygons before or after other actions, depending on whether undo was being processed.
Note: seem to have introduced a bug which is getting the tangents subtly wrong in certain cases; need to investigate.
CL 3465738:
Fixed regression introduced in tangent calculations. Results now match previous version. Stripped out redundant code, and removed superfluous logging. When building the editable mesh, the tangent basis for all polygons is now precached.
CL 3465744:
Removed old debugging code.
CL 3472569:
Reinstated Compact (currently after every topology-changing transaction; will make it much more infrequent when I'm sure it works perfectly). Made some changes to fixing up element IDs. Added a new method in the Adapter interface to reindex elements on compact/uncompact.
CL 3476078:
Fixed issue when loading edited meshes. They now must always have their render mesh rebuilt on PostLoad. (This seems to arise from the way the circular dependency between Engine and MeshEditingRuntime has been resolved).
CL 3476104:
Reinstated instanced editable meshes.
CL 3484401:
Added missing file (EditableMeshAdapter.h)
CL 3484699:
Added new adapter method OnCreateEmptyVertexRange, now needed again by extrude (I removed this action, but Mike's new extrude requires it)
#codereview Mike.Fricker
#rb none
[CL 3490308 by Richard TalbotWatkin in Dev-Geometry branch]
2017-06-14 16:31:26 -04:00
# include "ScopedTransaction.h"
2017-03-31 14:31:36 -04:00
# define LOCTEXT_NAMESPACE "MeshEditorMode"
void URemoveEdgeCommand : : RegisterUICommand ( FBindingContext * BindingContext )
{
2017-06-26 14:00:48 -04:00
UI_COMMAND_EXT ( BindingContext , /* Out */ UICommandInfo , " RemoveEdge " , " Remove " , " Attempts to remove the selected edge and merge adjacent polygons. " , EUserInterfaceActionType : : Button , FInputChord ( EKeys : : BackSpace ) ) ;
2017-03-31 14:31:36 -04:00
}
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 ;
Copying //Tasks/UE4/Dev-Geometry-Refactor to Dev-Geometry (//UE4/Dev-Geometry)
CL 3365379:
Beginnings of 'uber mesh'. Moved mesh description across to UEditableMesh. Renamed Rendering Vertices to Vertex Instances, they will form a fundamental part of the mesh description, in representing shared vertices.
CL 3365385:
Renamed Sections to PolygonGroups. This prevents confusion between editable mesh sections and rendering sections (from the static mesh). It also means we can potentially open up the concept of 'polygon groups' to represent more than static mesh sections if we wish to.
CL 3365387:
Removed FPolygonRef and flattened Polygons container. Added new methods to act on the entire Polygons container. Added RenderingPolygons, RenderingTriangles, RenderingPolygonGroups containers which will eventually live on the adapter, and which are solely involved in maintaining the render buffers. Fixed Quadrangulate so that it doesn't merge across polygon groups.
CL 3365390:
Started to remove virtuals from EditableMesh. First separation of ubermesh intrinsic properties from implementation details in EditableStaticMesh.
CL 3396167:
Picking out generic functionality from the _Internal methods, moving them into UEditableMesh code, ready to remove the inheritance entirely. Implemented adapter interface (currently living within UEditableStaticMesh) and calling into it from UEditableMesh.
Big revamp to handling of rendering vertices; now exist as vertex instances, which are dynamically shared / split, depending on whether colors / textures are identical. Normal/tangent is handled separately as it is autogenerated. Whether neighboring edges are hard or not determines whether a vertex will be automatically instanced, regardless of other attributes. We infer whether a vertex is 'hard' from whether the mesh is split by hard edges at that point (done by tracing adjacent polygons through only soft edges); hard vertices are always instanced for that poly. This simplifies the autogeneration of normals, as it now simply iterates through stale vertex instances, applying the weighted contribution from each connected polygon. Polygon normals are now cached as a read-only attribute, to make this process even quicker.
Rewrite of the basic primitive operations (Create/Delete polygon / edges / vertices / vertex instances). Added a new primitive operation to substitute vertex instances on a polygon contour. Setting edge hardness attribute now potentially instances or deletes vertex instances, as does setting vertex instance attributes.
CL 3396229:
Intermediate check-in (phase 2).
Removed a whole load of dead code. Broke functionality, until InitEditableStaticMesh is rewritten to use the public UEditableMesh API.
CL 3401798:
Intermediate check-in (phase 3).
Implemented a simple alternative to tangent basis generation as MikkTSpace doesn't quite fit our model currently (but with a view to revisiting it in the future; nothing has been removed for now).
Fixed edge hardness setting.
Added missing hash function for FVertexInstanceID.
CL 3403360:
Fixed some bugs in tangent/normal handling. Now correctly includes contributions from adjacent polygons in the same smoothing group but different vertex instance when calculating a vertex instance normal.
CL 3411429:
Fixed a bunch of bugs:
- Fixed issue where adjacent polygons the other side of a UV seam were not contributing to vertex instance normal calculation.
- Fixed various issues where out arrays weren't being reset, and mesh change actions were not being called after setting up the input array.
- Various changes to converting static meshes to editable meshes.
- Removed old ContourVertices arrays from polygon contours; now polygons exclusively use an array of vertex instances.
- Updated natvis to parse new element ID types.
CL 3418022:
More bug fixes:
- Sorted an issue with undo where vertex instance merging / splitting was happening twice, once due to the parent operation, and another time due to the revert transactions which are created.
- Added options to delete orphaned vertex instances in DeletePolygons and other operations which remove vertex instances.
- Fixed issue with SplitEdge due to subtle bug where connected edges were duplicated in a vertex, instead of being added uniquely.
- Changed order that undo items are added to the stack so that the revert operation works smoothly.
CL 3427887:
Fixed issue which occurs in certain circumstances with Split Edge.
Fixed regression which was causing various operations to fail when setting edge hardness.
CL 3430665:
Specify polygon edge hardness policy when creating a polygon. Simplified some existing uses of CreatePolygons. Changed behavior to match original behavior so that only *new* edge IDs are returned by CreatePolygons.
CL 3430927:
Corrected normal/tangent generation for polygons and adjacent polygons.
CL 3431134:
Fixed small issue with remove vertex in certain circumstances.
CL 3446929:
- Added a triangle list to the FMeshPolygon struct, making triangulation a first-class operation instead of an implementation detail.
- Repurposed UEditableStaticMesh as an editable mesh adapter, in a separate class hierarchy.
- Tidied up interfaces
- Moved serialization, compact/uncompact into UEditableMesh
- Currently broken: instance changes. This is pending a rethink on how we scope objects in the assets.
CL 3446954:
Renamed EditableStaticMesh.* to EditableStaticMeshAdapter.* to reflect its new role and place in the class hierarchy.
CL 3449133:
Fixed issue with splitting vertices due to the wrong polygon ID being used by GetPolygonsInSameSmoothingGroup. Also fixed an error where the list being iterated was potentially being mutated by the split operation.
CL 3449362:
Fixed ChangePolygonsVertexInstances to fix up the triangle list after replacing vertex instances. Not sure where this code went!
CL 3458823:
- Deferred normals calculation until the end of the transaction for efficiency
- Fixed a bug in inserting edge loops
- Fixed a bug in splitting vertex instances when hardening an edge
- Moved verbose logging into a LogEditableMesh category.
CL 3461128:
Included a bunch of required header files (IWYU).
CL 3464397:
Change to handling of triangulation and normal/tangent generation. Now this is done as a deferred process during EndTransaction. This achieves three goals:
1) Polygons are not repeatedly triangulated unnecessarily as a consequence of suboperations.
2) We are able to calculate and cache the polygon tangent basis upfront, which is then used for every connected vertex instance tangent basis - this is quickerthan repeatedly calculating it each time it's needed.
3) We no longer need to treat triangulation or vertex generation as a special FChange. Instead it is rolled into the FStartOrEndTransaction change. Hence we can remove the awkward code which was triangulating polygons before or after other actions, depending on whether undo was being processed.
Note: seem to have introduced a bug which is getting the tangents subtly wrong in certain cases; need to investigate.
CL 3465738:
Fixed regression introduced in tangent calculations. Results now match previous version. Stripped out redundant code, and removed superfluous logging. When building the editable mesh, the tangent basis for all polygons is now precached.
CL 3465744:
Removed old debugging code.
CL 3472569:
Reinstated Compact (currently after every topology-changing transaction; will make it much more infrequent when I'm sure it works perfectly). Made some changes to fixing up element IDs. Added a new method in the Adapter interface to reindex elements on compact/uncompact.
CL 3476078:
Fixed issue when loading edited meshes. They now must always have their render mesh rebuilt on PostLoad. (This seems to arise from the way the circular dependency between Engine and MeshEditingRuntime has been resolved).
CL 3476104:
Reinstated instanced editable meshes.
CL 3484401:
Added missing file (EditableMeshAdapter.h)
CL 3484699:
Added new adapter method OnCreateEmptyVertexRange, now needed again by extrude (I removed this action, but Mike's new extrude requires it)
#codereview Mike.Fricker
#rb none
[CL 3490308 by Richard TalbotWatkin in Dev-Geometry branch]
2017-06-14 16:31:26 -04:00
FPolygonID NewPolygonID ;
2017-03-31 14:31:36 -04:00
Copying //Tasks/UE4/Dev-Geometry-Refactor to Dev-Geometry (//UE4/Dev-Geometry)
CL 3365379:
Beginnings of 'uber mesh'. Moved mesh description across to UEditableMesh. Renamed Rendering Vertices to Vertex Instances, they will form a fundamental part of the mesh description, in representing shared vertices.
CL 3365385:
Renamed Sections to PolygonGroups. This prevents confusion between editable mesh sections and rendering sections (from the static mesh). It also means we can potentially open up the concept of 'polygon groups' to represent more than static mesh sections if we wish to.
CL 3365387:
Removed FPolygonRef and flattened Polygons container. Added new methods to act on the entire Polygons container. Added RenderingPolygons, RenderingTriangles, RenderingPolygonGroups containers which will eventually live on the adapter, and which are solely involved in maintaining the render buffers. Fixed Quadrangulate so that it doesn't merge across polygon groups.
CL 3365390:
Started to remove virtuals from EditableMesh. First separation of ubermesh intrinsic properties from implementation details in EditableStaticMesh.
CL 3396167:
Picking out generic functionality from the _Internal methods, moving them into UEditableMesh code, ready to remove the inheritance entirely. Implemented adapter interface (currently living within UEditableStaticMesh) and calling into it from UEditableMesh.
Big revamp to handling of rendering vertices; now exist as vertex instances, which are dynamically shared / split, depending on whether colors / textures are identical. Normal/tangent is handled separately as it is autogenerated. Whether neighboring edges are hard or not determines whether a vertex will be automatically instanced, regardless of other attributes. We infer whether a vertex is 'hard' from whether the mesh is split by hard edges at that point (done by tracing adjacent polygons through only soft edges); hard vertices are always instanced for that poly. This simplifies the autogeneration of normals, as it now simply iterates through stale vertex instances, applying the weighted contribution from each connected polygon. Polygon normals are now cached as a read-only attribute, to make this process even quicker.
Rewrite of the basic primitive operations (Create/Delete polygon / edges / vertices / vertex instances). Added a new primitive operation to substitute vertex instances on a polygon contour. Setting edge hardness attribute now potentially instances or deletes vertex instances, as does setting vertex instance attributes.
CL 3396229:
Intermediate check-in (phase 2).
Removed a whole load of dead code. Broke functionality, until InitEditableStaticMesh is rewritten to use the public UEditableMesh API.
CL 3401798:
Intermediate check-in (phase 3).
Implemented a simple alternative to tangent basis generation as MikkTSpace doesn't quite fit our model currently (but with a view to revisiting it in the future; nothing has been removed for now).
Fixed edge hardness setting.
Added missing hash function for FVertexInstanceID.
CL 3403360:
Fixed some bugs in tangent/normal handling. Now correctly includes contributions from adjacent polygons in the same smoothing group but different vertex instance when calculating a vertex instance normal.
CL 3411429:
Fixed a bunch of bugs:
- Fixed issue where adjacent polygons the other side of a UV seam were not contributing to vertex instance normal calculation.
- Fixed various issues where out arrays weren't being reset, and mesh change actions were not being called after setting up the input array.
- Various changes to converting static meshes to editable meshes.
- Removed old ContourVertices arrays from polygon contours; now polygons exclusively use an array of vertex instances.
- Updated natvis to parse new element ID types.
CL 3418022:
More bug fixes:
- Sorted an issue with undo where vertex instance merging / splitting was happening twice, once due to the parent operation, and another time due to the revert transactions which are created.
- Added options to delete orphaned vertex instances in DeletePolygons and other operations which remove vertex instances.
- Fixed issue with SplitEdge due to subtle bug where connected edges were duplicated in a vertex, instead of being added uniquely.
- Changed order that undo items are added to the stack so that the revert operation works smoothly.
CL 3427887:
Fixed issue which occurs in certain circumstances with Split Edge.
Fixed regression which was causing various operations to fail when setting edge hardness.
CL 3430665:
Specify polygon edge hardness policy when creating a polygon. Simplified some existing uses of CreatePolygons. Changed behavior to match original behavior so that only *new* edge IDs are returned by CreatePolygons.
CL 3430927:
Corrected normal/tangent generation for polygons and adjacent polygons.
CL 3431134:
Fixed small issue with remove vertex in certain circumstances.
CL 3446929:
- Added a triangle list to the FMeshPolygon struct, making triangulation a first-class operation instead of an implementation detail.
- Repurposed UEditableStaticMesh as an editable mesh adapter, in a separate class hierarchy.
- Tidied up interfaces
- Moved serialization, compact/uncompact into UEditableMesh
- Currently broken: instance changes. This is pending a rethink on how we scope objects in the assets.
CL 3446954:
Renamed EditableStaticMesh.* to EditableStaticMeshAdapter.* to reflect its new role and place in the class hierarchy.
CL 3449133:
Fixed issue with splitting vertices due to the wrong polygon ID being used by GetPolygonsInSameSmoothingGroup. Also fixed an error where the list being iterated was potentially being mutated by the split operation.
CL 3449362:
Fixed ChangePolygonsVertexInstances to fix up the triangle list after replacing vertex instances. Not sure where this code went!
CL 3458823:
- Deferred normals calculation until the end of the transaction for efficiency
- Fixed a bug in inserting edge loops
- Fixed a bug in splitting vertex instances when hardening an edge
- Moved verbose logging into a LogEditableMesh category.
CL 3461128:
Included a bunch of required header files (IWYU).
CL 3464397:
Change to handling of triangulation and normal/tangent generation. Now this is done as a deferred process during EndTransaction. This achieves three goals:
1) Polygons are not repeatedly triangulated unnecessarily as a consequence of suboperations.
2) We are able to calculate and cache the polygon tangent basis upfront, which is then used for every connected vertex instance tangent basis - this is quickerthan repeatedly calculating it each time it's needed.
3) We no longer need to treat triangulation or vertex generation as a special FChange. Instead it is rolled into the FStartOrEndTransaction change. Hence we can remove the awkward code which was triangulating polygons before or after other actions, depending on whether undo was being processed.
Note: seem to have introduced a bug which is getting the tangents subtly wrong in certain cases; need to investigate.
CL 3465738:
Fixed regression introduced in tangent calculations. Results now match previous version. Stripped out redundant code, and removed superfluous logging. When building the editable mesh, the tangent basis for all polygons is now precached.
CL 3465744:
Removed old debugging code.
CL 3472569:
Reinstated Compact (currently after every topology-changing transaction; will make it much more infrequent when I'm sure it works perfectly). Made some changes to fixing up element IDs. Added a new method in the Adapter interface to reindex elements on compact/uncompact.
CL 3476078:
Fixed issue when loading edited meshes. They now must always have their render mesh rebuilt on PostLoad. (This seems to arise from the way the circular dependency between Engine and MeshEditingRuntime has been resolved).
CL 3476104:
Reinstated instanced editable meshes.
CL 3484401:
Added missing file (EditableMeshAdapter.h)
CL 3484699:
Added new adapter method OnCreateEmptyVertexRange, now needed again by extrude (I removed this action, but Mike's new extrude requires it)
#codereview Mike.Fricker
#rb none
[CL 3490308 by Richard TalbotWatkin in Dev-Geometry branch]
2017-06-14 16:31:26 -04:00
EditableMesh - > TryToRemovePolygonEdge ( EdgeID , /* Out */ bWasEdgeRemoved , /* Out */ NewPolygonID ) ;
2017-03-31 14:31:36 -04:00
if ( bWasEdgeRemoved )
{
// Select the new polygon
FMeshElement NewPolygonMeshElement ;
{
NewPolygonMeshElement . Component = EdgeElementToRemove . Component ;
NewPolygonMeshElement . ElementAddress = EdgeElementToRemove . ElementAddress ;
NewPolygonMeshElement . ElementAddress . ElementType = EEditableMeshElementType : : Polygon ;
Copying //Tasks/UE4/Dev-Geometry-Refactor to Dev-Geometry (//UE4/Dev-Geometry)
CL 3365379:
Beginnings of 'uber mesh'. Moved mesh description across to UEditableMesh. Renamed Rendering Vertices to Vertex Instances, they will form a fundamental part of the mesh description, in representing shared vertices.
CL 3365385:
Renamed Sections to PolygonGroups. This prevents confusion between editable mesh sections and rendering sections (from the static mesh). It also means we can potentially open up the concept of 'polygon groups' to represent more than static mesh sections if we wish to.
CL 3365387:
Removed FPolygonRef and flattened Polygons container. Added new methods to act on the entire Polygons container. Added RenderingPolygons, RenderingTriangles, RenderingPolygonGroups containers which will eventually live on the adapter, and which are solely involved in maintaining the render buffers. Fixed Quadrangulate so that it doesn't merge across polygon groups.
CL 3365390:
Started to remove virtuals from EditableMesh. First separation of ubermesh intrinsic properties from implementation details in EditableStaticMesh.
CL 3396167:
Picking out generic functionality from the _Internal methods, moving them into UEditableMesh code, ready to remove the inheritance entirely. Implemented adapter interface (currently living within UEditableStaticMesh) and calling into it from UEditableMesh.
Big revamp to handling of rendering vertices; now exist as vertex instances, which are dynamically shared / split, depending on whether colors / textures are identical. Normal/tangent is handled separately as it is autogenerated. Whether neighboring edges are hard or not determines whether a vertex will be automatically instanced, regardless of other attributes. We infer whether a vertex is 'hard' from whether the mesh is split by hard edges at that point (done by tracing adjacent polygons through only soft edges); hard vertices are always instanced for that poly. This simplifies the autogeneration of normals, as it now simply iterates through stale vertex instances, applying the weighted contribution from each connected polygon. Polygon normals are now cached as a read-only attribute, to make this process even quicker.
Rewrite of the basic primitive operations (Create/Delete polygon / edges / vertices / vertex instances). Added a new primitive operation to substitute vertex instances on a polygon contour. Setting edge hardness attribute now potentially instances or deletes vertex instances, as does setting vertex instance attributes.
CL 3396229:
Intermediate check-in (phase 2).
Removed a whole load of dead code. Broke functionality, until InitEditableStaticMesh is rewritten to use the public UEditableMesh API.
CL 3401798:
Intermediate check-in (phase 3).
Implemented a simple alternative to tangent basis generation as MikkTSpace doesn't quite fit our model currently (but with a view to revisiting it in the future; nothing has been removed for now).
Fixed edge hardness setting.
Added missing hash function for FVertexInstanceID.
CL 3403360:
Fixed some bugs in tangent/normal handling. Now correctly includes contributions from adjacent polygons in the same smoothing group but different vertex instance when calculating a vertex instance normal.
CL 3411429:
Fixed a bunch of bugs:
- Fixed issue where adjacent polygons the other side of a UV seam were not contributing to vertex instance normal calculation.
- Fixed various issues where out arrays weren't being reset, and mesh change actions were not being called after setting up the input array.
- Various changes to converting static meshes to editable meshes.
- Removed old ContourVertices arrays from polygon contours; now polygons exclusively use an array of vertex instances.
- Updated natvis to parse new element ID types.
CL 3418022:
More bug fixes:
- Sorted an issue with undo where vertex instance merging / splitting was happening twice, once due to the parent operation, and another time due to the revert transactions which are created.
- Added options to delete orphaned vertex instances in DeletePolygons and other operations which remove vertex instances.
- Fixed issue with SplitEdge due to subtle bug where connected edges were duplicated in a vertex, instead of being added uniquely.
- Changed order that undo items are added to the stack so that the revert operation works smoothly.
CL 3427887:
Fixed issue which occurs in certain circumstances with Split Edge.
Fixed regression which was causing various operations to fail when setting edge hardness.
CL 3430665:
Specify polygon edge hardness policy when creating a polygon. Simplified some existing uses of CreatePolygons. Changed behavior to match original behavior so that only *new* edge IDs are returned by CreatePolygons.
CL 3430927:
Corrected normal/tangent generation for polygons and adjacent polygons.
CL 3431134:
Fixed small issue with remove vertex in certain circumstances.
CL 3446929:
- Added a triangle list to the FMeshPolygon struct, making triangulation a first-class operation instead of an implementation detail.
- Repurposed UEditableStaticMesh as an editable mesh adapter, in a separate class hierarchy.
- Tidied up interfaces
- Moved serialization, compact/uncompact into UEditableMesh
- Currently broken: instance changes. This is pending a rethink on how we scope objects in the assets.
CL 3446954:
Renamed EditableStaticMesh.* to EditableStaticMeshAdapter.* to reflect its new role and place in the class hierarchy.
CL 3449133:
Fixed issue with splitting vertices due to the wrong polygon ID being used by GetPolygonsInSameSmoothingGroup. Also fixed an error where the list being iterated was potentially being mutated by the split operation.
CL 3449362:
Fixed ChangePolygonsVertexInstances to fix up the triangle list after replacing vertex instances. Not sure where this code went!
CL 3458823:
- Deferred normals calculation until the end of the transaction for efficiency
- Fixed a bug in inserting edge loops
- Fixed a bug in splitting vertex instances when hardening an edge
- Moved verbose logging into a LogEditableMesh category.
CL 3461128:
Included a bunch of required header files (IWYU).
CL 3464397:
Change to handling of triangulation and normal/tangent generation. Now this is done as a deferred process during EndTransaction. This achieves three goals:
1) Polygons are not repeatedly triangulated unnecessarily as a consequence of suboperations.
2) We are able to calculate and cache the polygon tangent basis upfront, which is then used for every connected vertex instance tangent basis - this is quickerthan repeatedly calculating it each time it's needed.
3) We no longer need to treat triangulation or vertex generation as a special FChange. Instead it is rolled into the FStartOrEndTransaction change. Hence we can remove the awkward code which was triangulating polygons before or after other actions, depending on whether undo was being processed.
Note: seem to have introduced a bug which is getting the tangents subtly wrong in certain cases; need to investigate.
CL 3465738:
Fixed regression introduced in tangent calculations. Results now match previous version. Stripped out redundant code, and removed superfluous logging. When building the editable mesh, the tangent basis for all polygons is now precached.
CL 3465744:
Removed old debugging code.
CL 3472569:
Reinstated Compact (currently after every topology-changing transaction; will make it much more infrequent when I'm sure it works perfectly). Made some changes to fixing up element IDs. Added a new method in the Adapter interface to reindex elements on compact/uncompact.
CL 3476078:
Fixed issue when loading edited meshes. They now must always have their render mesh rebuilt on PostLoad. (This seems to arise from the way the circular dependency between Engine and MeshEditingRuntime has been resolved).
CL 3476104:
Reinstated instanced editable meshes.
CL 3484401:
Added missing file (EditableMeshAdapter.h)
CL 3484699:
Added new adapter method OnCreateEmptyVertexRange, now needed again by extrude (I removed this action, but Mike's new extrude requires it)
#codereview Mike.Fricker
#rb none
[CL 3490308 by Richard TalbotWatkin in Dev-Geometry branch]
2017-06-14 16:31:26 -04:00
NewPolygonMeshElement . ElementAddress . ElementID = NewPolygonID ;
2017-03-31 14:31:36 -04:00
}
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 ( ) ) ;
}
2017-04-10 16:45:27 -04:00
// Select the polygon leftover after removing the edge
MeshEditorMode . SelectMeshElements ( MeshElementsToSelect ) ;
2017-03-31 14:31:36 -04:00
}
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