working on visual mode

This commit is contained in:
codeimp 2008-11-26 22:56:53 +00:00
parent ca5a2d3813
commit b31fe3d9a7
2 changed files with 18 additions and 3 deletions

View file

@ -71,6 +71,7 @@ namespace CodeImp.DoomBuilder.Map
// Triangulation
private bool updateneeded;
private bool triangulationneeded;
private RectangleF bbox;
private Triangulation triangles;
private FlatVertex[] flatvertices;
private ReadOnlyCollection<LabelPositionInfo> labels;
@ -95,6 +96,7 @@ namespace CodeImp.DoomBuilder.Map
public int Tag { get { return tag; } set { tag = value; if((tag < 0) || (tag > MapSet.HIGHEST_TAG)) throw new ArgumentOutOfRangeException("Tag", "Invalid tag number"); } }
public int Brightness { get { return brightness; } set { brightness = value; updateneeded = true; } }
public bool UpdateNeeded { get { return updateneeded; } set { updateneeded |= value; triangulationneeded |= value; } }
public RectangleF BBox { get { return bbox; } }
public Sector Clone { get { return clone; } set { clone = value; } }
public Triangulation Triangles { get { return triangles; } }
public FlatVertex[] FlatVertices { get { return flatvertices; } }
@ -253,6 +255,9 @@ namespace CodeImp.DoomBuilder.Map
flatvertices[i].u = triangles.Vertices[i].x;
flatvertices[i].v = triangles.Vertices[i].y;
}
// Create bounding box
bbox = CreateBBox();
// Updated
updateneeded = false;
@ -405,7 +410,7 @@ namespace CodeImp.DoomBuilder.Map
// This creates a bounding box rectangle
// This requires the sector triangulation to be up-to-date!
public RectangleF CreateBBox()
private RectangleF CreateBBox()
{
// Setup
float left = float.MaxValue;

View file

@ -286,7 +286,7 @@ namespace CodeImp.DoomBuilder.VisualModes
if(start != null) ProcessVisibleSectors(start, (Vector2D)campos);
}
// This recursively finds and adds visible sectors
// This finds and adds visible sectors
private void ProcessVisibleSectors(Sector start, Vector2D campos)
{
Stack<Sector> todo = new Stack<Sector>(50);
@ -357,8 +357,18 @@ namespace CodeImp.DoomBuilder.VisualModes
// Within view range?
if(sd.Line.DistanceToSq(campos, true) < viewdist2)
{
Vector2D p = sd.Line.Start.Position;
if((p.x > s.BBox.Left + Linedef.SIDE_POINT_DISTANCE) &&
(p.x < s.BBox.Right - Linedef.SIDE_POINT_DISTANCE) &&
(p.y > s.BBox.Top + Linedef.SIDE_POINT_DISTANCE) &&
(p.y < s.BBox.Bottom - Linedef.SIDE_POINT_DISTANCE))
{
// Sidedef is inside source sector, other sector always visible!
todo.Push(os);
stackedsectors.Add(os, os);
}
// Can we see this sector?
if(clipper.TestRange(sd.Line.Start.Position, sd.Line.End.Position))
else if(clipper.TestRange(sd.Line.Start.Position, sd.Line.End.Position))
{
// Process this sector as well
todo.Push(os);