mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
Fixed/reverted some of optimizations from r1845...
This commit is contained in:
parent
47cebd9b20
commit
894a2069e8
2 changed files with 50 additions and 35 deletions
|
@ -153,8 +153,9 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
foreach(Vertex v in General.Map.Map.Vertices)
|
||||
{
|
||||
// Inside the polygon bounding box?
|
||||
if(bbox.Contains(v.Position.x, v.Position.y)) //mxd
|
||||
{
|
||||
if(v.Position.x < bbox.Left || v.Position.x > bbox.Right || v.Position.y < bbox.Top || v.Position.y > bbox.Bottom)
|
||||
continue;
|
||||
|
||||
// More to the right?
|
||||
if((foundv == null) || (v.Position.x >= foundv.Position.x))
|
||||
{
|
||||
|
@ -181,7 +182,6 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Found a vertex inside the polygon?
|
||||
if(foundv != null)
|
||||
|
@ -296,7 +296,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
// Line to the right of start point?
|
||||
if((ld.Start.Position.x > px) || (ld.End.Position.x > px)) {
|
||||
// Line intersecting the y axis?
|
||||
if((ld.Start.Position.y > py && ld.End.Position.y < py) || (ld.Start.Position.y < py && ld.End.Position.y > py)) { //mxd
|
||||
if((ld.Start.Position.y >= py && ld.End.Position.y <= py) || (ld.Start.Position.y <= py && ld.End.Position.y >= py)) { //mxd
|
||||
// Check if this linedef intersects our test line at a closer range
|
||||
float thisu;
|
||||
ld.Line.GetIntersection(testline, out thisu);
|
||||
|
|
|
@ -1906,16 +1906,29 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// Go for all lines
|
||||
foreach(Linedef l in lines)
|
||||
{
|
||||
//mxd. Not within rect?
|
||||
if(!area.Contains(l.Start.Position.x, l.Start.Position.y) || !area.Contains(l.End.Position.x, l.End.Position.y)) continue;
|
||||
// Check the cs field bits
|
||||
if ((GetCSFieldBits(l.Start, ref area) & GetCSFieldBits(l.End, ref area)) == 0)
|
||||
{
|
||||
// The line could be in the area
|
||||
newlines.Add(l);
|
||||
}
|
||||
}
|
||||
|
||||
// Return result
|
||||
return newlines;
|
||||
}
|
||||
|
||||
// This returns the cohen-sutherland field bits for a vertex in a rectangle area
|
||||
private static int GetCSFieldBits(Vertex v, ref RectangleF area)
|
||||
{
|
||||
int bits = 0;
|
||||
if(v.Position.y < area.Top) bits |= 0x01;
|
||||
if(v.Position.y > area.Bottom) bits |= 0x02;
|
||||
if(v.Position.x < area.Left) bits |= 0x04;
|
||||
if(v.Position.x > area.Right) bits |= 0x08;
|
||||
return bits;
|
||||
}
|
||||
|
||||
/// <summary>This filters vertices by a rectangular area.</summary>
|
||||
public static ICollection<Vertex> FilterByArea(ICollection<Vertex> verts, ref RectangleF area)
|
||||
{
|
||||
|
@ -1925,12 +1938,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
foreach(Vertex v in verts)
|
||||
{
|
||||
// Within rect?
|
||||
if(area.Contains(v.Position.x, v.Position.y)) //mxd
|
||||
{
|
||||
if((v.Position.x < area.Left) || (v.Position.x > area.Right) ||
|
||||
(v.Position.y < area.Top) || (v.Position.y > area.Bottom)) continue;
|
||||
|
||||
// The vertex is in the area
|
||||
newverts.Add(v);
|
||||
}
|
||||
}
|
||||
|
||||
// Return result
|
||||
return newverts;
|
||||
|
@ -2532,8 +2545,10 @@ namespace CodeImp.DoomBuilder.Map
|
|||
px = v.Position.x;
|
||||
py = v.Position.y;
|
||||
|
||||
// Within range?
|
||||
if(!range.Contains(px, py)) continue; //mxd
|
||||
//mxd. Within range?
|
||||
if((v.Position.x < range.Left) || (v.Position.x > range.Right)
|
||||
|| (v.Position.y < range.Top) || (v.Position.y > range.Bottom))
|
||||
continue;
|
||||
|
||||
// Close than previous find?
|
||||
d = Math.Abs(px - pos.x) + Math.Abs(py - pos.y);
|
||||
|
|
Loading…
Reference in a new issue