Avoid blockmap use when moving mouse in some classic modes

This commit is contained in:
spherallic 2023-05-11 17:34:39 +02:00
parent 56b2423887
commit 6576ed7408
4 changed files with 25 additions and 8 deletions

View file

@ -2122,6 +2122,7 @@ namespace CodeImp.DoomBuilder.Map
BeginAddRemove(); BeginAddRemove();
// Split moving lines with unselected vertices // Split moving lines with unselected vertices
General.WriteLogLine("Splitting moving lines with unselected vertices...");
ICollection<Vertex> nearbyfixedverts = FilterByArea(fixedverts, ref editarea); ICollection<Vertex> nearbyfixedverts = FilterByArea(fixedverts, ref editarea);
if (!SplitLinesByVertices(movinglines, nearbyfixedverts, STITCH_DISTANCE, movinglines, mergemode)) if (!SplitLinesByVertices(movinglines, nearbyfixedverts, STITCH_DISTANCE, movinglines, mergemode))
{ {
@ -2130,6 +2131,7 @@ namespace CodeImp.DoomBuilder.Map
} }
// Split non-moving lines with selected vertices // Split non-moving lines with selected vertices
General.WriteLogLine("Splitting non-moving lines with selected vertices...");
fixedlines = FilterByArea(fixedlines, ref editarea); fixedlines = FilterByArea(fixedlines, ref editarea);
fixedlines = new HashSet<Linedef>(fixedlines.Where(fixedline => !fixedline.IsDisposed)); fixedlines = new HashSet<Linedef>(fixedlines.Where(fixedline => !fixedline.IsDisposed));
if (!SplitLinesByVertices(fixedlines, movingverts, STITCH_DISTANCE, movinglines, mergemode)) if (!SplitLinesByVertices(fixedlines, movingverts, STITCH_DISTANCE, movinglines, mergemode))
@ -2139,6 +2141,7 @@ namespace CodeImp.DoomBuilder.Map
} }
//mxd. Split moving lines with fixed lines //mxd. Split moving lines with fixed lines
General.WriteLogLine("Splitting moving lines with fixed lines...");
if (!SplitLinesByLines(fixedlines, movinglines, mergemode)) if (!SplitLinesByLines(fixedlines, movinglines, mergemode))
{ {
EndAddRemove(); // Unfreeze arrays before returning EndAddRemove(); // Unfreeze arrays before returning
@ -2146,6 +2149,7 @@ namespace CodeImp.DoomBuilder.Map
} }
// Remove looped linedefs // Remove looped linedefs
General.WriteLogLine("Removing looped lines...");
RemoveLoopedLinedefs(movinglines); RemoveLoopedLinedefs(movinglines);
// Join overlapping lines // Join overlapping lines

View file

@ -545,9 +545,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
/// </summary> /// </summary>
private void CreateBlockmap() private void CreateBlockmap()
{ {
General.WriteLogLine("Creating blockmap...");
RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices); RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);
blockmap = new BlockMap<BlockEntry>(area); blockmap = new BlockMap<BlockEntry>(area);
blockmap.AddLinedefsSet(General.Map.Map.Linedefs); blockmap.AddLinedefsSet(General.Map.Map.Linedefs);
General.WriteLogLine("Blockmap done.");
} }
#endregion #endregion
@ -1000,9 +1002,10 @@ 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 = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale); //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) if (l != null)
{ {
if(l != highlighted) if(l != highlighted)
{ {
@ -1032,10 +1035,12 @@ 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 = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale); //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 //mxd. Render insert vertex preview
Linedef sl = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.StitchRange / renderer.Scale); //Linedef sl = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.StitchRange / renderer.Scale);
Linedef sl = General.Map.Map.NearestLinedefRange(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;

View file

@ -749,6 +749,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
/// </summary> /// </summary>
private void CreateBlockmap() private void CreateBlockmap()
{ {
General.WriteLogLine("Creating blockmap...");
RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices); RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);
area = MapSet.IncreaseArea(area, General.Map.Map.Things); area = MapSet.IncreaseArea(area, General.Map.Map.Things);
blockmap = new BlockMap<BlockEntry>(area); blockmap = new BlockMap<BlockEntry>(area);
@ -758,6 +759,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Don't add linedefs here. They are only needed for paint select, so let's save some // 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) // time (and add them when paint select is used t he first time)
addedlinedefstoblockmap = false; addedlinedefstoblockmap = false;
General.WriteLogLine("Blockmap done.");
} }
#endregion #endregion
@ -1155,7 +1157,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
// Find the nearest linedef within highlight range // Find the nearest linedef within highlight range
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale); //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; Sector s = null;
if(l != null) if(l != null)

View file

@ -81,9 +81,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
/// </summary> /// </summary>
private void CreateBlockmap() private void CreateBlockmap()
{ {
General.WriteLogLine("Creating blockmap...");
RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices); RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);
blockmap = new BlockMap<BlockEntry>(area); blockmap = new BlockMap<BlockEntry>(area);
blockmap.AddLinedefsSet(General.Map.Map.Linedefs); blockmap.AddLinedefsSet(General.Map.Map.Linedefs);
General.WriteLogLine("Blockmap done.");
} }
public override void OnHelp() public override void OnHelp()
@ -331,7 +333,8 @@ 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 = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale); //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) if(l != null)
{ {
// Create undo // Create undo
@ -498,7 +501,8 @@ 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 = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale); //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) if(l != null)
{ {
@ -901,7 +905,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Map.UndoRedo.CreateUndo("Insert vertex"); General.Map.UndoRedo.CreateUndo("Insert vertex");
// Snap to geometry? // Snap to geometry?
Linedef l = MapSet.NearestLinedefRange(blockmap, mousemappos, BuilderPlug.Me.SplitLinedefsRange / renderer.Scale); //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)) if(snaptonearest && (l != null))
{ {
// Snip to grid also? // Snip to grid also?