mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-02-14 08:00:54 +00:00
MapSet.NearestLinedefRange using a blockmap now takes into account that the maxrange could be bigger than the blockmap block size
This commit is contained in:
parent
b0b1693a62
commit
0eee76393b
2 changed files with 45 additions and 8 deletions
|
@ -196,6 +196,32 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This returns a range of blocks in a rectangle. Pretty much the same like GetSquareRange(RectangleF rect),
|
||||||
|
// just without the overhead to create a RectangleF first
|
||||||
|
public virtual HashSet<BE> GetSquareRange(double left, double top, double width, double height)
|
||||||
|
{
|
||||||
|
// Calculate block coordinates
|
||||||
|
Point lt = GetBlockCoordinates(new Vector2D(left, top));
|
||||||
|
Point rb = GetBlockCoordinates(new Vector2D(left+width, top+height));
|
||||||
|
|
||||||
|
// Crop coordinates to range
|
||||||
|
lt = CropToRange(lt);
|
||||||
|
rb = CropToRange(rb);
|
||||||
|
|
||||||
|
// Go through the range to make a list
|
||||||
|
int entriescount = ((rb.X - lt.X) + 1) * ((rb.Y - lt.Y) + 1);
|
||||||
|
HashSet<BE> entries = new HashSet<BE>(entriescount);
|
||||||
|
for (int x = lt.X; x <= rb.X; x++)
|
||||||
|
{
|
||||||
|
for (int y = lt.Y; y <= rb.Y; y++)
|
||||||
|
{
|
||||||
|
entries.Add(blockmap[x, y]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
// This returns all blocks along the given line
|
// This returns all blocks along the given line
|
||||||
public virtual List<BE> GetLineBlocks(Vector2D v1, Vector2D v2)
|
public virtual List<BE> GetLineBlocks(Vector2D v1, Vector2D v2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3392,7 +3392,13 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
float maxrangesq = maxrange * maxrange;
|
float maxrangesq = maxrange * maxrange;
|
||||||
HashSet<Linedef> processed = new HashSet<Linedef>();
|
HashSet<Linedef> processed = new HashSet<Linedef>();
|
||||||
|
|
||||||
HashSet<BlockEntry> blocks = new HashSet<BlockEntry>
|
HashSet<BlockEntry> blocks;
|
||||||
|
|
||||||
|
// If the max range is lower or equal to the blockmap's block size we can take a shortcut got the the possible blocks.
|
||||||
|
// Otherwise get an rectangular range of blocks. This happens when maxrange is computed from low zoom levels
|
||||||
|
if (maxrange <= selectionmap.BlockSize)
|
||||||
|
{
|
||||||
|
blocks = new HashSet<BlockEntry>
|
||||||
{
|
{
|
||||||
selectionmap.GetBlockAt(pos),
|
selectionmap.GetBlockAt(pos),
|
||||||
selectionmap.GetBlockAt(new Vector2D(pos.x + maxrange, pos.y + maxrange)),
|
selectionmap.GetBlockAt(new Vector2D(pos.x + maxrange, pos.y + maxrange)),
|
||||||
|
@ -3400,6 +3406,11 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
selectionmap.GetBlockAt(new Vector2D(pos.x - maxrange, pos.y + maxrange)),
|
selectionmap.GetBlockAt(new Vector2D(pos.x - maxrange, pos.y + maxrange)),
|
||||||
selectionmap.GetBlockAt(new Vector2D(pos.x - maxrange, pos.y - maxrange))
|
selectionmap.GetBlockAt(new Vector2D(pos.x - maxrange, pos.y - maxrange))
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
blocks = selectionmap.GetSquareRange(pos.x - maxrange, pos.y - maxrange, maxrange * 2, maxrange * 2);
|
||||||
|
}
|
||||||
|
|
||||||
foreach(BlockEntry be in blocks)
|
foreach(BlockEntry be in blocks)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue