From 1415309079199b41191d8e09a39c54990319e568 Mon Sep 17 00:00:00 2001 From: spherallic Date: Wed, 17 Jul 2024 15:08:33 +0200 Subject: [PATCH] Restore classic pasting mode quirks & undo some optimizations for it to fix bugs --- Source/Core/Geometry/Tools.cs | 15 ++++++++++----- Source/Core/Map/MapSet.cs | 12 +++++++----- .../ClassicModes/EditSelectionMode.cs | 13 +++++++++---- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Source/Core/Geometry/Tools.cs b/Source/Core/Geometry/Tools.cs index 24585b91..7ddb2b7b 100755 --- a/Source/Core/Geometry/Tools.cs +++ b/Source/Core/Geometry/Tools.cs @@ -1095,11 +1095,16 @@ namespace CodeImp.DoomBuilder.Geometry map.EndAddRemove(); // Filter old lines and vertices by edited area - RectangleF editarea = MapSet.CreateArea(newlines); - editarea = MapSet.IncreaseArea(editarea, mergeverts); - editarea.Inflate(1.0f, 1.0f); - List oldlines = new List(MapSet.FilterByArea(alllines, ref editarea)); - nonmergeverts = new List(MapSet.FilterByArea(nonmergeverts, ref editarea)); + List oldlines = alllines; + + if (General.Settings.MergeGeometryMode != MergeGeometryMode.CLASSIC) + { + RectangleF editarea = MapSet.CreateArea(newlines); + editarea = MapSet.IncreaseArea(editarea, mergeverts); + editarea.Inflate(1.0f, 1.0f); + oldlines = new List(MapSet.FilterByArea(alllines, ref editarea)); + nonmergeverts = new List(MapSet.FilterByArea(nonmergeverts, ref editarea)); + } /***************************************************\ Find a way to close the drawing diff --git a/Source/Core/Map/MapSet.cs b/Source/Core/Map/MapSet.cs index 1a6fb3a1..a8b3fab5 100755 --- a/Source/Core/Map/MapSet.cs +++ b/Source/Core/Map/MapSet.cs @@ -2182,9 +2182,8 @@ namespace CodeImp.DoomBuilder.Map /// /// Stitches marked geometry with non-marked geometry. Returns false when the operation failed. /// - public bool StitchGeometry() { return StitchGeometry(MergeGeometryMode.CLASSIC, false); } //mxd. Compatibility TODO: figure out why this is needed and kill it - public bool StitchGeometry(MergeGeometryMode mergemode) { return StitchGeometry(mergemode, true); } //sphere: Compatibility - public bool StitchGeometry(MergeGeometryMode mergemode, bool fixsectors) + public bool StitchGeometry() { return StitchGeometry(MergeGeometryMode.CLASSIC); } //mxd. Compatibility + public bool StitchGeometry(MergeGeometryMode mergemode) { // Find vertices HashSet movingverts = new HashSet(General.Map.Map.GetMarkedVertices(true)); @@ -2200,7 +2199,9 @@ namespace CodeImp.DoomBuilder.Map RectangleF editarea = CreateArea(movinglines); editarea = IncreaseArea(editarea, movingverts); editarea.Inflate(1.0f, 1.0f); - fixedverts = FilterByArea(fixedverts, ref editarea); + + if (mergemode != MergeGeometryMode.CLASSIC) + fixedverts = FilterByArea(fixedverts, ref editarea); // Join nearby vertices BeginAddRemove(); @@ -2293,7 +2294,7 @@ namespace CodeImp.DoomBuilder.Map } //mxd. Correct sector references - if (fixsectors) + if (mergemode != MergeGeometryMode.CLASSIC) { // Linedefs cache needs to be up to date... Update(true, false); @@ -2310,6 +2311,7 @@ namespace CodeImp.DoomBuilder.Map else { FlipBackwardLinedefs(changedlines); + CorrectOuterSides(new HashSet(changedlines)); } return true; diff --git a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs index 86a70d81..97c07d70 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs @@ -1815,11 +1815,16 @@ namespace CodeImp.DoomBuilder.BuilderModes HashSet newsides = new HashSet(General.Map.Map.GetMarkedSidedefs(true)); HashSet oldlines = new HashSet(General.Map.Map.GetMarkedLinedefs(false)); + RectangleF editarea = MapSet.CreateArea(oldlines); + // Determine area in which we are editing - RectangleF editarea = MapSet.CreateArea(General.Map.Map.GetMarkedLinedefs(true)); - editarea = MapSet.IncreaseArea(editarea, General.Map.Map.GetMarkedVertices(true)); - editarea.Inflate(1.0f, 1.0f); - //oldlines = MapSet.FilterByArea(oldlines, ref editarea); + if (General.Settings.MergeGeometryMode != MergeGeometryMode.CLASSIC) + { + editarea = MapSet.CreateArea(General.Map.Map.GetMarkedLinedefs(true)); + editarea = MapSet.IncreaseArea(editarea, General.Map.Map.GetMarkedVertices(true)); + editarea.Inflate(1.0f, 1.0f); + //oldlines = MapSet.FilterByArea(oldlines, ref editarea); + } //mxd. Let's use a blockmap... BlockMap blockmap = new BlockMap(editarea);