mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +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,31 +153,31 @@ 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
|
||||
{
|
||||
// More to the right?
|
||||
if((foundv == null) || (v.Position.x >= foundv.Position.x))
|
||||
{
|
||||
// Vertex is inside the polygon?
|
||||
if(p.Intersect(v.Position))
|
||||
{
|
||||
// Vertex has lines attached?
|
||||
if(v.Linedefs.Count > 0)
|
||||
{
|
||||
// Go for all lines to see if the vertex is not of the polygon itsself
|
||||
vvalid = true;
|
||||
foreach(LinedefSide ls in alllines)
|
||||
{
|
||||
if((ls.Line.Start == v) || (ls.Line.End == v))
|
||||
{
|
||||
vvalid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(v.Position.x < bbox.Left || v.Position.x > bbox.Right || v.Position.y < bbox.Top || v.Position.y > bbox.Bottom)
|
||||
continue;
|
||||
|
||||
// Valid vertex?
|
||||
if(vvalid) foundv = v;
|
||||
// More to the right?
|
||||
if((foundv == null) || (v.Position.x >= foundv.Position.x))
|
||||
{
|
||||
// Vertex is inside the polygon?
|
||||
if(p.Intersect(v.Position))
|
||||
{
|
||||
// Vertex has lines attached?
|
||||
if(v.Linedefs.Count > 0)
|
||||
{
|
||||
// Go for all lines to see if the vertex is not of the polygon itsself
|
||||
vvalid = true;
|
||||
foreach(LinedefSide ls in alllines)
|
||||
{
|
||||
if((ls.Line.Start == v) || (ls.Line.End == v))
|
||||
{
|
||||
vvalid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Valid vertex?
|
||||
if(vvalid) foundv = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
// The line could be in the area
|
||||
newlines.Add(l);
|
||||
// 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,11 +1938,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
foreach(Vertex v in verts)
|
||||
{
|
||||
// Within rect?
|
||||
if(area.Contains(v.Position.x, v.Position.y)) //mxd
|
||||
{
|
||||
// The vertex is in the area
|
||||
newverts.Add(v);
|
||||
}
|
||||
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
|
||||
|
@ -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