Merge branch 'reduce-blockmap-use' into 'master'

Reduce blockmap use when drawing/stitching geometry

See merge request STJr/UltimateZoneBuilder!4
This commit is contained in:
sphere 2023-05-26 12:51:28 +00:00
commit af9c803ed6
5 changed files with 13 additions and 17 deletions

View file

@ -972,11 +972,6 @@ namespace CodeImp.DoomBuilder.Geometry
List<Vertex> nonmergeverts = new List<Vertex>(General.Map.Map.Vertices);
MapSet map = General.Map.Map;
//mxd. Let's use a blockmap...
RectangleF area = MapSet.CreateArea(oldlines);
BlockMap<BlockEntry> oldlinesmap = new BlockMap<BlockEntry>(area);
oldlinesmap.AddLinedefsSet(oldlines);
General.Map.Map.ClearAllMarks(false);
// Any points to do?
@ -1121,7 +1116,7 @@ namespace CodeImp.DoomBuilder.Geometry
foreach(Linedef ld in newlines)
{
Vector2D ldcp = ld.GetCenterPoint();
Linedef nld = MapSet.NearestLinedef(oldlinesmap, ldcp); //mxd. Lines collection -> Blockmap
Linedef nld = MapSet.NearestLinedef(oldlines, ldcp);
if(nld != null)
{
double ldside = nld.SideOfLine(ldcp);
@ -1158,7 +1153,7 @@ namespace CodeImp.DoomBuilder.Geometry
List<LinedefSide> endpoints = new List<LinedefSide>();
// Find out where the start will stitch and create test points
Linedef l1 = MapSet.NearestLinedefRange(oldlinesmap, firstline.Start.Position, MapSet.STITCH_DISTANCE); //mxd. Lines collection -> Blockmap
Linedef l1 = MapSet.NearestLinedefRange(oldlines, firstline.Start.Position, MapSet.STITCH_DISTANCE);
Vertex vv1 = null;
if(l1 != null)
{
@ -1183,7 +1178,7 @@ namespace CodeImp.DoomBuilder.Geometry
}
// Find out where the end will stitch and create test points
Linedef l2 = MapSet.NearestLinedefRange(oldlinesmap, lastline.End.Position, MapSet.STITCH_DISTANCE); //mxd. Lines collection -> Blockmap
Linedef l2 = MapSet.NearestLinedefRange(oldlines, lastline.End.Position, MapSet.STITCH_DISTANCE);
Vertex vv2 = null;
if(l2 != null)
{

View file

@ -2184,6 +2184,7 @@ namespace CodeImp.DoomBuilder.Map
// Split non-moving lines with selected vertices
fixedlines = new HashSet<Linedef>(fixedlines.Where(fixedline => !fixedline.IsDisposed));
fixedlines = FilterByArea(fixedlines, ref editarea);
if (!SplitLinesByVertices(fixedlines, movingverts, STITCH_DISTANCE, movinglines, mergemode))
{
EndAddRemove(); // Unfreeze arrays before returning

View file

@ -944,7 +944,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)
{
@ -976,10 +976,10 @@ 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);
Linedef sl = General.Map.Map.NearestLinedefRange(mousemappos, BuilderPlug.Me.StitchRange / renderer.Scale);
if (sl != null)
{
bool snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;

View file

@ -1171,7 +1171,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// 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

@ -320,7 +320,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
@ -487,7 +487,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)
{
@ -908,7 +908,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?