From c30f266c5b534005d21401d6da905767412e6682 Mon Sep 17 00:00:00 2001 From: spherallic Date: Thu, 30 May 2024 19:59:15 +0200 Subject: [PATCH 1/3] Completely remove blockmap use in Vertices and Linedefs modes --- .../BuilderModes/ClassicModes/LinedefsMode.cs | 47 +----------------- .../BuilderModes/ClassicModes/VerticesMode.cs | 49 +------------------ 2 files changed, 2 insertions(+), 94 deletions(-) diff --git a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs index ba570077..45787a29 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs @@ -65,9 +65,6 @@ namespace CodeImp.DoomBuilder.BuilderModes // Interface new private bool editpressed; - // The blockmap makes is used to make finding lines faster - BlockMap blockmap; - // Stores sizes of the text for text labels so that they only have to be computed once private Dictionary textlabelsizecache; @@ -469,17 +466,6 @@ namespace CodeImp.DoomBuilder.BuilderModes } } - /// - /// Create a blockmap containing linedefs. This is used to speed up determining the closest line - /// to the mouse cursor - /// - private void CreateBlockmap() - { - RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices); - blockmap = new BlockMap(area); - blockmap.AddLinedefsSet(General.Map.Map.Linedefs); - } - /// /// Renders the overlay with the (selection) labels and insert vertex preview. /// @@ -629,9 +615,6 @@ namespace CodeImp.DoomBuilder.BuilderModes BuilderPlug.Me.MenusForm.SyncronizeThingEditButton.ToolTipText = "Synchronized Things Editing" + Environment.NewLine + BuilderPlug.Me.MenusForm.SyncronizeThingEditLinedefsItem.ToolTipText; General.Interface.EndToolbarUpdate(); //mxd - // Create the blockmap - CreateBlockmap(); - // Convert geometry selection to linedefs selection General.Map.Map.ConvertSelection(SelectionType.Linedefs); UpdateSelectionInfo(); //mxd @@ -881,9 +864,6 @@ namespace CodeImp.DoomBuilder.BuilderModes { base.OnUndoEnd(); - // Recreate the blockmap to not include the potentially un-done lines anymore - CreateBlockmap(); - // Select changed map elements if (BuilderPlug.Me.SelectChangedafterUndoRedo) { @@ -905,9 +885,6 @@ namespace CodeImp.DoomBuilder.BuilderModes { base.OnRedoEnd(); - // Recreate the blockmap to include the potentially re-done linedefs again - CreateBlockmap(); - // Select changed map elements if (BuilderPlug.Me.SelectChangedafterUndoRedo) { @@ -928,9 +905,6 @@ namespace CodeImp.DoomBuilder.BuilderModes { base.OnScriptRunEnd(); - // The script might have added new geometry - CreateBlockmap(); - UpdateSelectionInfo(); SetupSectorLabels(); @@ -1001,7 +975,7 @@ namespace CodeImp.DoomBuilder.BuilderModes bool snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid; bool snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge; - Vector2D v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, false, false, renderer, new List(), blockmap).pos; + Vector2D v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, false, false, renderer, new List()).pos; if (v != insertpreview) { @@ -1255,16 +1229,6 @@ namespace CodeImp.DoomBuilder.BuilderModes return base.OnCopyBegin(); } - /// - /// If map elements have changed the blockmap needs to be recreated. - /// - public override void OnMapElementsChanged() - { - base.OnMapElementsChanged(); - - CreateBlockmap(); - } - public override bool OnAutoSaveBegin() { return allowautosave; @@ -1498,9 +1462,6 @@ namespace CodeImp.DoomBuilder.BuilderModes General.Map.IsChanged = true; General.Map.Map.Update(); - // Recreate the blockmap since it shouldn't include the deleted linedefs anymore - CreateBlockmap(); - // Redraw screen SetupSectorLabels(); //mxd UpdateSelectionInfo(); //mxd @@ -1571,9 +1532,6 @@ namespace CodeImp.DoomBuilder.BuilderModes General.Map.IsChanged = true; General.Map.Map.Update(); - // Recreate the blockmap since it shouldn't include the dissolved linedefs anymore - CreateBlockmap(); - // Redraw screen SetupSectorLabels(); //mxd UpdateSelectionInfo(); //mxd @@ -1644,9 +1602,6 @@ namespace CodeImp.DoomBuilder.BuilderModes //BuilderPlug.Me.AdjustSplitCoordinates(ld, sld); } - // Create the blockmap - CreateBlockmap(); - // Update cache values General.Map.IsChanged = true; General.Map.Map.Update(); diff --git a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs index 0f1a2317..b72df611 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs @@ -56,9 +56,6 @@ namespace CodeImp.DoomBuilder.BuilderModes // Interface new private bool editpressed; - // The blockmap makes is used to make finding lines faster - BlockMap blockmap; - // Vertices that will be edited ICollection editvertices; @@ -81,17 +78,6 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Methods - /// - /// Create a blockmap containing linedefs. This is used to speed up determining the closest line - /// to the mouse cursor - /// - private void CreateBlockmap() - { - RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices); - blockmap = new BlockMap(area); - blockmap.AddLinedefsSet(General.Map.Map.Linedefs); - } - public override void OnHelp() { General.ShowHelp("e_vertices.html"); @@ -124,9 +110,6 @@ namespace CodeImp.DoomBuilder.BuilderModes General.Interface.EndToolbarUpdate(); //mxd } - // Create the blockmap - CreateBlockmap(); - // Convert geometry selection to vertices only General.Map.Map.ConvertSelection(SelectionType.Vertices); UpdateSelectionInfo(); //mxd @@ -378,9 +361,6 @@ namespace CodeImp.DoomBuilder.BuilderModes } //BuilderPlug.Me.AdjustSplitCoordinates(l, sld); - // Create the blockmap - CreateBlockmap(); - // Update General.Map.Map.Update(); @@ -578,9 +558,6 @@ namespace CodeImp.DoomBuilder.BuilderModes { base.OnUndoEnd(); - // Recreate the blockmap - CreateBlockmap(); - // Select changed map elements if (BuilderPlug.Me.SelectChangedafterUndoRedo) { @@ -593,9 +570,6 @@ namespace CodeImp.DoomBuilder.BuilderModes { base.OnRedoEnd(); - // Recreate the blockmap - CreateBlockmap(); - // Select changed map elements if (BuilderPlug.Me.SelectChangedafterUndoRedo) { @@ -608,8 +582,6 @@ namespace CodeImp.DoomBuilder.BuilderModes { base.OnScriptRunEnd(); - CreateBlockmap(); - General.Interface.RedrawDisplay(); } @@ -783,16 +755,6 @@ namespace CodeImp.DoomBuilder.BuilderModes return base.OnCopyBegin(); } - /// - /// If map elements have changed the blockmap needs to be recreated. - /// - public override void OnMapElementsChanged() - { - base.OnMapElementsChanged(); - - CreateBlockmap(); - } - #endregion #region ================== Actions @@ -986,7 +948,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(snaptonearest) { //mxd. Check if snapped vertex is still on top of a linedef - l = MapSet.NearestLinedefRange(blockmap, v.Position, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale); + l = General.Map.Map.NearestLinedefRange(v.Position, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale); if(l != null) { @@ -1013,9 +975,6 @@ namespace CodeImp.DoomBuilder.BuilderModes General.Interface.DisplayStatus(StatusType.Action, "Inserted a vertex."); } - // Create the blockmap - CreateBlockmap(); - // Update General.Map.Map.Update(); @@ -1069,9 +1028,6 @@ namespace CodeImp.DoomBuilder.BuilderModes General.Map.IsChanged = true; General.Map.Map.Update(); - // Create the blockmap - CreateBlockmap(); - // Invoke a new mousemove so that the highlighted item updates MouseEventArgs e = new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0); OnMouseMove(e); @@ -1151,9 +1107,6 @@ namespace CodeImp.DoomBuilder.BuilderModes General.Map.Map.Update(); General.Map.IsChanged = true; - // Create the blockmap - CreateBlockmap(); - // Invoke a new mousemove so that the highlighted item updates MouseEventArgs e = new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0); OnMouseMove(e); From f167febd585212e02cb0d76732a7c38795d156f0 Mon Sep 17 00:00:00 2001 From: spherallic Date: Thu, 30 May 2024 20:53:41 +0200 Subject: [PATCH 2/3] Increase blockmap entry size for Sectors Mode --- Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs index 449da33b..572cd96c 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs @@ -780,7 +780,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices); area = MapSet.IncreaseArea(area, General.Map.Map.Things); - blockmap = new BlockMap(area); + blockmap = new BlockMap(area, 512); blockmap.AddSectorsSet(General.Map.Map.Sectors); blockmap.AddThingsSet(General.Map.Map.Things); From ef8afd60f632168b9177229a765ec96f2d5203de Mon Sep 17 00:00:00 2001 From: spherallic Date: Mon, 3 Jun 2024 13:28:37 +0200 Subject: [PATCH 3/3] Fix small sector geometry pasted inside a much bigger sector not maintaining textures --- Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs index 32defe7f..29ef22f0 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs @@ -1814,7 +1814,7 @@ namespace CodeImp.DoomBuilder.BuilderModes 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); + //oldlines = MapSet.FilterByArea(oldlines, ref editarea); //mxd. Let's use a blockmap... BlockMap blockmap = new BlockMap(editarea);