mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
drawing optimization added
This commit is contained in:
parent
21819e8010
commit
83c4524ce7
2 changed files with 38 additions and 15 deletions
|
@ -76,6 +76,23 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
foreach(EarClipVertex v in p) base.AddLast(v);
|
||||
}
|
||||
|
||||
// This creates a bounding box from the outer polygon
|
||||
public RectangleF CreateBBox()
|
||||
{
|
||||
float left = float.MaxValue;
|
||||
float right = float.MinValue;
|
||||
float top = float.MaxValue;
|
||||
float bottom = float.MinValue;
|
||||
foreach(EarClipVertex v in this)
|
||||
{
|
||||
if(v.Position.x < left) left = v.Position.x;
|
||||
if(v.Position.x > right) right = v.Position.x;
|
||||
if(v.Position.y < top) top = v.Position.y;
|
||||
if(v.Position.y > bottom) bottom = v.Position.y;
|
||||
}
|
||||
return new RectangleF(left, top, right - left, bottom - top);
|
||||
}
|
||||
|
||||
// Point inside the polygon?
|
||||
// See: http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/
|
||||
public bool Intersect(Vector2D p)
|
||||
|
|
|
@ -133,6 +133,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
Linedef foundline;
|
||||
float foundangle = 0f;
|
||||
bool foundlinefront;
|
||||
RectangleF bbox = p.CreateBBox();
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -142,28 +143,33 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
foundv = null;
|
||||
foreach(Vertex v in General.Map.Map.Vertices)
|
||||
{
|
||||
// More to the right?
|
||||
if((foundv == null) || (v.Position.x >= foundv.Position.x))
|
||||
// Inside the polygon bounding box?
|
||||
if((v.Position.x >= bbox.Left) && (v.Position.x <= bbox.Right) &&
|
||||
(v.Position.x >= bbox.Top) && (v.Position.x <= bbox.Bottom))
|
||||
{
|
||||
// Vertex is inside the polygon?
|
||||
if(p.Intersect(v.Position))
|
||||
// More to the right?
|
||||
if((foundv == null) || (v.Position.x >= foundv.Position.x))
|
||||
{
|
||||
// Vertex has lines attached?
|
||||
if(v.Linedefs.Count > 0)
|
||||
// Vertex is inside the polygon?
|
||||
if(p.Intersect(v.Position))
|
||||
{
|
||||
// Go for all lines to see if the vertex is not of the polygon itsself
|
||||
vvalid = true;
|
||||
foreach(LinedefSide ls in alllines)
|
||||
// Vertex has lines attached?
|
||||
if(v.Linedefs.Count > 0)
|
||||
{
|
||||
if((ls.Line.Start == v) || (ls.Line.End == v))
|
||||
// Go for all lines to see if the vertex is not of the polygon itsself
|
||||
vvalid = true;
|
||||
foreach(LinedefSide ls in alllines)
|
||||
{
|
||||
vvalid = false;
|
||||
break;
|
||||
if((ls.Line.Start == v) || (ls.Line.End == v))
|
||||
{
|
||||
vvalid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Valid vertex?
|
||||
if(vvalid) foundv = v;
|
||||
// Valid vertex?
|
||||
if(vvalid) foundv = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue