mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-02-14 16:10:50 +00:00
Linedefs Mode, Sectors Mode, Vertices Mode, Sound Environment Mode, Sound Propagation Mode: slightly improved performance when moving the mouse
This commit is contained in:
parent
60a010efd1
commit
710cb59719
3 changed files with 87 additions and 12 deletions
|
@ -69,6 +69,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
new private bool editpressed;
|
new private bool editpressed;
|
||||||
private bool selectionfromhighlight; //mxd
|
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
|
// Stores sizes of the text for text labels so that they only have to be computed once
|
||||||
private Dictionary<string, float> textlabelsizecache;
|
private Dictionary<string, float> textlabelsizecache;
|
||||||
|
|
||||||
|
@ -541,6 +545,17 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Events
|
#region ================== Events
|
||||||
|
@ -594,6 +609,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
BuilderPlug.Me.MenusForm.SyncronizeThingEditButton.ToolTipText = "Synchronized Things Editing" + Environment.NewLine + BuilderPlug.Me.MenusForm.SyncronizeThingEditLinedefsItem.ToolTipText;
|
BuilderPlug.Me.MenusForm.SyncronizeThingEditButton.ToolTipText = "Synchronized Things Editing" + Environment.NewLine + BuilderPlug.Me.MenusForm.SyncronizeThingEditLinedefsItem.ToolTipText;
|
||||||
General.Interface.EndToolbarUpdate(); //mxd
|
General.Interface.EndToolbarUpdate(); //mxd
|
||||||
|
|
||||||
|
// Create the blockmap
|
||||||
|
CreateBlockmap();
|
||||||
|
|
||||||
// Convert geometry selection to linedefs selection
|
// Convert geometry selection to linedefs selection
|
||||||
General.Map.Map.ConvertSelection(SelectionType.Linedefs);
|
General.Map.Map.ConvertSelection(SelectionType.Linedefs);
|
||||||
UpdateSelectionInfo(); //mxd
|
UpdateSelectionInfo(); //mxd
|
||||||
|
@ -931,6 +949,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
{
|
{
|
||||||
base.OnUndoEnd();
|
base.OnUndoEnd();
|
||||||
|
|
||||||
|
// Recreate the blockmap to not include the potentially un-done lines anymore
|
||||||
|
CreateBlockmap();
|
||||||
|
|
||||||
// Select changed map elements
|
// Select changed map elements
|
||||||
if (BuilderPlug.Me.SelectChangedafterUndoRedo)
|
if (BuilderPlug.Me.SelectChangedafterUndoRedo)
|
||||||
{
|
{
|
||||||
|
@ -952,6 +973,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
{
|
{
|
||||||
base.OnRedoEnd();
|
base.OnRedoEnd();
|
||||||
|
|
||||||
|
// Recreate the blockmap to include the potentially re-done linedefs again
|
||||||
|
CreateBlockmap();
|
||||||
|
|
||||||
// Select changed map elements
|
// Select changed map elements
|
||||||
if (BuilderPlug.Me.SelectChangedafterUndoRedo)
|
if (BuilderPlug.Me.SelectChangedafterUndoRedo)
|
||||||
{
|
{
|
||||||
|
@ -989,7 +1013,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
else if(paintselectpressed && !editpressed && !selecting) //mxd. Drag-select
|
else if(paintselectpressed && !editpressed && !selecting) //mxd. Drag-select
|
||||||
{
|
{
|
||||||
// Find the nearest thing within highlight range
|
// Find the nearest thing within highlight range
|
||||||
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
|
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
|
||||||
|
|
||||||
if(l != null)
|
if(l != null)
|
||||||
{
|
{
|
||||||
|
@ -1021,11 +1045,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
else if(e.Button == MouseButtons.None) // Not holding any buttons?
|
else if(e.Button == MouseButtons.None) // Not holding any buttons?
|
||||||
{
|
{
|
||||||
// Find the nearest linedef within highlight range
|
// Find the nearest linedef within highlight range
|
||||||
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
|
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
|
||||||
|
|
||||||
//mxd. Render insert vertex preview
|
//mxd. Render insert vertex preview
|
||||||
Linedef sl = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.StitchRange / renderer.Scale);
|
Linedef sl = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.StitchRange / renderer.Scale);
|
||||||
if(sl != null)
|
if (sl != null)
|
||||||
{
|
{
|
||||||
bool snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
|
bool snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
|
||||||
bool snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge;
|
bool snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge;
|
||||||
|
@ -1520,6 +1544,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
General.Map.IsChanged = true;
|
General.Map.IsChanged = true;
|
||||||
General.Map.Map.Update();
|
General.Map.Map.Update();
|
||||||
|
|
||||||
|
// Recreate the blockmap since it shouldn't include the deleted linedefs anymore
|
||||||
|
CreateBlockmap();
|
||||||
|
|
||||||
// Redraw screen
|
// Redraw screen
|
||||||
SetupSectorLabels(); //mxd
|
SetupSectorLabels(); //mxd
|
||||||
UpdateSelectionInfo(); //mxd
|
UpdateSelectionInfo(); //mxd
|
||||||
|
@ -1607,6 +1634,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
General.Map.IsChanged = true;
|
General.Map.IsChanged = true;
|
||||||
General.Map.Map.Update();
|
General.Map.Map.Update();
|
||||||
|
|
||||||
|
// Recreate the blockmap since it shouldn't include the dissolved linedefs anymore
|
||||||
|
CreateBlockmap();
|
||||||
|
|
||||||
// Redraw screen
|
// Redraw screen
|
||||||
SetupSectorLabels(); //mxd
|
SetupSectorLabels(); //mxd
|
||||||
UpdateSelectionInfo(); //mxd
|
UpdateSelectionInfo(); //mxd
|
||||||
|
|
|
@ -76,6 +76,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
|
|
||||||
// The blockmap makes synchronized editing faster
|
// The blockmap makes synchronized editing faster
|
||||||
BlockMap<BlockEntry> blockmap;
|
BlockMap<BlockEntry> blockmap;
|
||||||
|
bool addedlinedefstoblockmap;
|
||||||
|
|
||||||
// Stores sizes of the text for text labels so that they only have to be computed once
|
// Stores sizes of the text for text labels so that they only have to be computed once
|
||||||
private Dictionary<string, float> textlabelsizecache;
|
private Dictionary<string, float> textlabelsizecache;
|
||||||
|
@ -755,6 +756,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
blockmap = new BlockMap<BlockEntry>(area);
|
blockmap = new BlockMap<BlockEntry>(area);
|
||||||
blockmap.AddSectorsSet(General.Map.Map.Sectors);
|
blockmap.AddSectorsSet(General.Map.Map.Sectors);
|
||||||
blockmap.AddThingsSet(General.Map.Map.Things);
|
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
|
#endregion
|
||||||
|
@ -1162,8 +1167,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
}
|
}
|
||||||
else if(paintselectpressed && !editpressed && !selecting) //mxd. Drag-select
|
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
|
// Find the nearest linedef within highlight range
|
||||||
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
|
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
|
||||||
Sector s = null;
|
Sector s = null;
|
||||||
|
|
||||||
if(l != null)
|
if(l != null)
|
||||||
|
|
|
@ -56,6 +56,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
new private bool editpressed;
|
new private bool editpressed;
|
||||||
private bool selectionfromhighlight; //mxd
|
private bool selectionfromhighlight; //mxd
|
||||||
|
|
||||||
|
// The blockmap makes is used to make finding lines faster
|
||||||
|
BlockMap<BlockEntry> blockmap;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Properties
|
#region ================== Properties
|
||||||
|
@ -70,6 +73,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
|
|
||||||
#region ================== Methods
|
#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()
|
public override void OnHelp()
|
||||||
{
|
{
|
||||||
General.ShowHelp("e_vertices.html");
|
General.ShowHelp("e_vertices.html");
|
||||||
|
@ -107,6 +121,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.PerpendicularLinedef); //JBR
|
General.Interface.AddButton(BuilderPlug.Me.MenusForm.PerpendicularLinedef); //JBR
|
||||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.ParallelLinedef); //JBR
|
General.Interface.AddButton(BuilderPlug.Me.MenusForm.ParallelLinedef); //JBR
|
||||||
|
|
||||||
|
// Create the blockmap
|
||||||
|
CreateBlockmap();
|
||||||
|
|
||||||
// Convert geometry selection to vertices only
|
// Convert geometry selection to vertices only
|
||||||
General.Map.Map.ConvertSelection(SelectionType.Vertices);
|
General.Map.Map.ConvertSelection(SelectionType.Vertices);
|
||||||
UpdateSelectionInfo(); //mxd
|
UpdateSelectionInfo(); //mxd
|
||||||
|
@ -304,7 +321,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
else if(!selecting) //mxd. We don't want to do this stuff while multiselecting
|
else if(!selecting) //mxd. We don't want to do this stuff while multiselecting
|
||||||
{
|
{
|
||||||
// Find the nearest linedef within highlight range
|
// Find the nearest linedef within highlight range
|
||||||
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
|
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
|
||||||
if(l != null)
|
if(l != null)
|
||||||
{
|
{
|
||||||
// Create undo
|
// Create undo
|
||||||
|
@ -481,7 +498,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
else if(e.Button == MouseButtons.None) // Not holding any buttons?
|
else if(e.Button == MouseButtons.None) // Not holding any buttons?
|
||||||
{
|
{
|
||||||
//mxd. Render insert vertex preview
|
//mxd. Render insert vertex preview
|
||||||
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
|
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
|
||||||
|
|
||||||
if(l != null)
|
if(l != null)
|
||||||
{
|
{
|
||||||
|
@ -555,6 +572,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
Highlight(null);
|
Highlight(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnUndoEnd()
|
||||||
|
{
|
||||||
|
base.OnUndoEnd();
|
||||||
|
|
||||||
|
// Recreate the blockmap
|
||||||
|
CreateBlockmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnRedoEnd()
|
||||||
|
{
|
||||||
|
base.OnRedoEnd();
|
||||||
|
|
||||||
|
// Recreate the blockmap
|
||||||
|
CreateBlockmap();
|
||||||
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
protected override void BeginViewPan()
|
protected override void BeginViewPan()
|
||||||
{
|
{
|
||||||
|
@ -851,7 +884,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
General.Map.UndoRedo.CreateUndo("Insert vertex");
|
General.Map.UndoRedo.CreateUndo("Insert vertex");
|
||||||
|
|
||||||
// Snap to geometry?
|
// Snap to geometry?
|
||||||
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
|
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
|
||||||
if(snaptonearest && (l != null))
|
if(snaptonearest && (l != null))
|
||||||
{
|
{
|
||||||
// Snip to grid also?
|
// Snip to grid also?
|
||||||
|
@ -912,7 +945,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
if(snaptonearest)
|
if(snaptonearest)
|
||||||
{
|
{
|
||||||
//mxd. Check if snapped vertex is still on top of a linedef
|
//mxd. Check if snapped vertex is still on top of a linedef
|
||||||
l = General.Map.Map.NearestLinedefRange(v.Position, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
|
l = MapSet.NearestLinedefRange(blockmap, v.Position, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
|
||||||
|
|
||||||
if(l != null)
|
if(l != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue