Revert "Linedefs Mode, Sectors Mode, Vertices Mode, Sound Environment Mode, Sound Propagation Mode: slightly improved performance when moving the mouse"

This commit is contained in:
spherallic 2023-04-26 00:36:11 +02:00
parent 1f6dc46b07
commit 8c4ac371fd
3 changed files with 12 additions and 109 deletions

View File

@ -70,9 +70,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
private bool editpressed;
private bool selectionfromhighlight; //mxd
// 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;
@ -584,20 +581,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
labels.Add(linedef, l);
}
}
/// <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);
}
#endregion
#region ================== Events
public override void OnHelp()
@ -649,9 +635,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
@ -992,9 +975,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)
{
@ -1012,9 +992,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)
{
@ -1048,7 +1025,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
else if(paintselectpressed && !editpressed && !selecting) //mxd. Drag-select
{
// Find the nearest thing within highlight range
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
if(l != null)
{
@ -1080,11 +1057,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
else if(e.Button == MouseButtons.None) // Not holding any buttons?
{
// Find the nearest linedef within highlight range
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
//mxd. Render insert vertex preview
Linedef sl = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.StitchRange / renderer.Scale);
if (sl != null)
Linedef sl = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.StitchRange / renderer.Scale);
if(sl != null)
{
bool snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
bool snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge;
@ -1579,9 +1556,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
@ -1668,10 +1642,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Update cache values
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
@ -1892,9 +1863,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

@ -75,7 +75,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
// The blockmap makes synchronized editing faster
BlockMap<BlockEntry> blockmap;
bool addedlinedefstoblockmap;
// Stores sizes of the text for text labels so that they only have to be computed once
private Dictionary<string, float> textlabelsizecache;
@ -754,10 +753,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
blockmap = new BlockMap<BlockEntry>(area);
blockmap.AddSectorsSet(General.Map.Map.Sectors);
blockmap.AddThingsSet(General.Map.Map.Things);
// Don't add linedefs here. They are only needed for paint select, so let's save some
// time (and add them when paint select is used t he first time)
addedlinedefstoblockmap = false;
}
#endregion
@ -1165,15 +1160,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
else if(paintselectpressed && !editpressed && !selecting) //mxd. Drag-select
{
// If linedefs were not added to the blockmap yet add them here
if (!addedlinedefstoblockmap)
{
blockmap.AddLinedefsSet(General.Map.Map.Linedefs);
addedlinedefstoblockmap = true;
}
// Find the nearest linedef within highlight range
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
Sector s = null;
if(l != null)

View File

@ -56,9 +56,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
private bool editpressed;
private bool selectionfromhighlight; //mxd
// The blockmap makes is used to make finding lines faster
BlockMap<BlockEntry> blockmap;
#endregion
#region ================== Properties
@ -73,17 +70,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");
@ -121,9 +107,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.AddButton(BuilderPlug.Me.MenusForm.PerpendicularLinedef); //JBR
General.Interface.AddButton(BuilderPlug.Me.MenusForm.ParallelLinedef); //JBR
// Create the blockmap
CreateBlockmap();
// Convert geometry selection to vertices only
General.Map.Map.ConvertSelection(SelectionType.Vertices);
UpdateSelectionInfo(); //mxd
@ -321,7 +304,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
else if(!selecting) //mxd. We don't want to do this stuff while multiselecting
{
// Find the nearest linedef within highlight range
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
if(l != null)
{
// Create undo
@ -372,9 +355,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
//BuilderPlug.Me.AdjustSplitCoordinates(l, sld);
// Create the blockmap
CreateBlockmap();
// Update
General.Map.Map.Update();
@ -501,7 +481,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
else if(e.Button == MouseButtons.None) // Not holding any buttons?
{
//mxd. Render insert vertex preview
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
if(l != null)
{
@ -575,36 +555,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
Highlight(null);
}
public override void OnUndoEnd()
{
base.OnUndoEnd();
// Recreate the blockmap
CreateBlockmap();
// Select changed map elements
if (BuilderPlug.Me.SelectChangedafterUndoRedo)
{
General.Map.Map.SelectMarkedGeometry(true, true);
General.Map.Map.ConvertSelection(SelectionType.Vertices);
}
}
public override void OnRedoEnd()
{
base.OnRedoEnd();
// Recreate the blockmap
CreateBlockmap();
// Select changed map elements
if (BuilderPlug.Me.SelectChangedafterUndoRedo)
{
General.Map.Map.SelectMarkedGeometry(true, true);
General.Map.Map.ConvertSelection(SelectionType.Vertices);
}
}
//mxd
protected override void BeginViewPan()
{
@ -901,7 +851,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Map.UndoRedo.CreateUndo("Insert vertex");
// Snap to geometry?
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
if(snaptonearest && (l != null))
{
// Snip to grid also?
@ -962,7 +912,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)
{
@ -989,9 +939,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.DisplayStatus(StatusType.Action, "Inserted a vertex.");
}
// Create the blockmap
CreateBlockmap();
// Update
General.Map.Map.Update();