mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-19 06:51:09 +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
d831d22217
commit
4991c323c3
5 changed files with 138 additions and 16 deletions
|
@ -67,7 +67,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Interface
|
||||
new private bool editpressed;
|
||||
private bool selectionfromhighlight; //mxd
|
||||
|
||||
|
||||
// The blockmap makes is used to make finding lines faster
|
||||
BlockMap<BlockEntry> blockmap;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -446,9 +449,20 @@ 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()
|
||||
|
@ -499,6 +513,9 @@ 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
|
||||
|
@ -824,6 +841,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
base.OnUndoEnd();
|
||||
|
||||
// Recreate the blockmap to not include the potentially un-done lines anymore
|
||||
CreateBlockmap();
|
||||
|
||||
// If something is highlighted make sure to update the association so that it contains valid data
|
||||
if (highlighted != null && !highlighted.IsDisposed)
|
||||
highlightasso.Set(highlighted);
|
||||
|
@ -838,6 +858,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
base.OnRedoEnd();
|
||||
|
||||
// Recreate the blockmap to include the potentially re-done linedefs again
|
||||
CreateBlockmap();
|
||||
|
||||
// If something is highlighted make sure to update the association so that it contains valid data
|
||||
if (highlighted != null && !highlighted.IsDisposed)
|
||||
highlightasso.Set(highlighted);
|
||||
|
@ -868,7 +891,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
else if(paintselectpressed && !editpressed && !selecting) //mxd. Drag-select
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
|
@ -900,11 +923,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
else if(e.Button == MouseButtons.None) // Not holding any buttons?
|
||||
{
|
||||
// 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
|
||||
Linedef sl = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.StitchRange / renderer.Scale);
|
||||
if(sl != null)
|
||||
Linedef sl = MapSet.NearestLinedefRange(blockmap, 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;
|
||||
|
@ -1371,6 +1394,9 @@ 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
|
||||
|
@ -1440,7 +1466,10 @@ 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
|
||||
|
|
|
@ -73,6 +73,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// The blockmap makes synchronized editing faster
|
||||
BlockMap<BlockEntry> blockmap;
|
||||
bool addedlinedefstoblockmap;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -693,6 +694,10 @@ 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
|
||||
|
@ -1087,8 +1092,15 @@ 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 = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
|
||||
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale);
|
||||
Sector s = null;
|
||||
|
||||
if(l != null)
|
||||
|
|
|
@ -57,6 +57,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
new private bool editpressed;
|
||||
private bool selectionfromhighlight; //mxd
|
||||
|
||||
// The blockmap makes is used to make finding lines faster
|
||||
BlockMap<BlockEntry> blockmap;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -71,6 +74,17 @@ 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");
|
||||
|
@ -103,6 +117,9 @@ 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
|
||||
|
@ -291,7 +308,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 = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
|
||||
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale);
|
||||
if(l != null)
|
||||
{
|
||||
// Create undo
|
||||
|
@ -468,7 +485,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
else if(e.Button == MouseButtons.None) // Not holding any buttons?
|
||||
{
|
||||
//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)
|
||||
{
|
||||
|
@ -543,6 +560,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Highlight(null);
|
||||
}
|
||||
|
||||
public override void OnUndoEnd()
|
||||
{
|
||||
base.OnUndoEnd();
|
||||
|
||||
// Recreate the blockmap
|
||||
CreateBlockmap();
|
||||
}
|
||||
|
||||
public override void OnRedoEnd()
|
||||
{
|
||||
base.OnRedoEnd();
|
||||
|
||||
// Recreate the blockmap
|
||||
CreateBlockmap();
|
||||
}
|
||||
|
||||
//mxd
|
||||
protected override void BeginViewPan()
|
||||
{
|
||||
|
@ -833,7 +866,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Map.UndoRedo.CreateUndo("Insert vertex");
|
||||
|
||||
// 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))
|
||||
{
|
||||
// Snip to grid also?
|
||||
|
@ -894,7 +927,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(snaptonearest)
|
||||
{
|
||||
//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)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Actions;
|
||||
using CodeImp.DoomBuilder.Controls;
|
||||
|
@ -58,6 +59,9 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
|
||||
private BackgroundWorker worker;
|
||||
|
||||
// The blockmap makes is used to make finding lines faster
|
||||
BlockMap<BlockEntry> blockmap;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -130,6 +134,17 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
}
|
||||
}
|
||||
|
||||
/// <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
|
||||
|
@ -169,6 +184,9 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
worker.ProgressChanged += worker_ProgressChanged;
|
||||
worker.RunWorkerCompleted += worker_RunWorkerCompleted;
|
||||
|
||||
// Create the blockmap
|
||||
CreateBlockmap();
|
||||
|
||||
UpdateData();
|
||||
|
||||
CustomPresentation presentation = new CustomPresentation();
|
||||
|
@ -231,6 +249,9 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
{
|
||||
base.OnUndoEnd();
|
||||
|
||||
// Recreate the blockmap
|
||||
CreateBlockmap();
|
||||
|
||||
// Update
|
||||
UpdateData();
|
||||
General.Interface.RedrawDisplay();
|
||||
|
@ -241,6 +262,9 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
{
|
||||
base.OnRedoEnd();
|
||||
|
||||
// Recreate the blockmap
|
||||
CreateBlockmap();
|
||||
|
||||
// Update
|
||||
UpdateData();
|
||||
General.Interface.RedrawDisplay();
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
@ -52,6 +53,9 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
private List<SoundPropagationDomain> propagationdomains;
|
||||
private Dictionary<Sector, SoundPropagationDomain> sector2domain;
|
||||
|
||||
// The blockmap makes is used to make finding lines faster
|
||||
BlockMap<BlockEntry> blockmap;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -161,8 +165,19 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
}
|
||||
}
|
||||
|
||||
/// <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()
|
||||
|
@ -202,6 +217,9 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
presentation.AddLayer(new PresentLayer(RendererLayer.Geometry, BlendingMode.Alpha, 1.0f, true));
|
||||
renderer.SetPresentation(presentation);
|
||||
|
||||
// Create the blockmap
|
||||
CreateBlockmap();
|
||||
|
||||
// Convert geometry selection to sectors only
|
||||
General.Map.Map.ConvertSelection(SelectionType.Sectors);
|
||||
|
||||
|
@ -320,6 +338,9 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
{
|
||||
base.OnUndoEnd();
|
||||
|
||||
// Recreate the blockmap
|
||||
CreateBlockmap();
|
||||
|
||||
// Update
|
||||
ResetSoundPropagation();
|
||||
General.Interface.RedrawDisplay();
|
||||
|
@ -330,6 +351,9 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
{
|
||||
base.OnRedoEnd();
|
||||
|
||||
// Recreate the blockmap
|
||||
CreateBlockmap();
|
||||
|
||||
// Update
|
||||
ResetSoundPropagation();
|
||||
General.Interface.RedrawDisplay();
|
||||
|
@ -346,7 +370,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
General.Interface.SetCursor(Cursors.Default);
|
||||
|
||||
//mxd. Find the nearest linedef within default highlight range
|
||||
Linedef nl = General.Map.Map.NearestLinedefRange(mousemappos, 20 / renderer.Scale);
|
||||
Linedef nl = MapSet.NearestLinedefRange(blockmap, mousemappos, 20 / renderer.Scale);
|
||||
//mxd. We are not interested in single-sided lines (unless they have "blocksound" flag set)...
|
||||
if(nl != null && (nl.Front == null || nl.Back == null) && !nl.IsFlagSet(BlockSoundFlag)) nl = null;
|
||||
|
||||
|
@ -355,7 +379,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
highlightedline = nl;
|
||||
|
||||
// Find the nearest linedef within highlight range
|
||||
Linedef l = General.Map.Map.NearestLinedef(mousemappos);
|
||||
Linedef l = MapSet.NearestLinedef(blockmap, mousemappos);
|
||||
if(l != null)
|
||||
{
|
||||
// Check on which side of the linedef the mouse is
|
||||
|
|
Loading…
Reference in a new issue