Merge branch 'killblockmapuse'

This commit is contained in:
spherallic 2024-06-07 12:14:20 +02:00
commit 99af0c2b81
4 changed files with 4 additions and 96 deletions

View file

@ -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<BlockEntry> blockmap = new BlockMap<BlockEntry>(editarea);

View file

@ -65,9 +65,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Interface
new private bool editpressed;
// The blockmap makes is used to make finding lines faster
BlockMap<BlockEntry> blockmap;
// Stores sizes of the text for text labels so that they only have to be computed once
private Dictionary<string, float> textlabelsizecache;
@ -469,17 +466,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
/// <summary>
/// Create a blockmap containing linedefs. This is used to speed up determining the closest line
/// to the mouse cursor
/// </summary>
private void CreateBlockmap()
{
RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);
blockmap = new BlockMap<BlockEntry>(area);
blockmap.AddLinedefsSet(General.Map.Map.Linedefs);
}
/// <summary>
/// Renders the overlay with the (selection) labels and insert vertex preview.
/// </summary>
@ -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<DrawnVertex>(), blockmap).pos;
Vector2D v = DrawGeometryMode.GetCurrentPosition(mousemappos, snaptonearest, snaptogrid, false, false, renderer, new List<DrawnVertex>()).pos;
if (v != insertpreview)
{
@ -1255,16 +1229,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
return base.OnCopyBegin();
}
/// <summary>
/// If map elements have changed the blockmap needs to be recreated.
/// </summary>
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();

View file

@ -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<BlockEntry>(area);
blockmap = new BlockMap<BlockEntry>(area, 512);
blockmap.AddSectorsSet(General.Map.Map.Sectors);
blockmap.AddThingsSet(General.Map.Map.Things);

View file

@ -56,9 +56,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Interface
new private bool editpressed;
// The blockmap makes is used to make finding lines faster
BlockMap<BlockEntry> blockmap;
// Vertices that will be edited
ICollection<Vertex> editvertices;
@ -81,17 +78,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
/// <summary>
/// Create a blockmap containing linedefs. This is used to speed up determining the closest line
/// to the mouse cursor
/// </summary>
private void CreateBlockmap()
{
RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);
blockmap = new BlockMap<BlockEntry>(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();
}
/// <summary>
/// If map elements have changed the blockmap needs to be recreated.
/// </summary>
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);