2008-01-06 20:56:48 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Text;
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
using SlimDX.Direct3D;
|
|
|
|
using System.Drawing;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Geometry
|
|
|
|
{
|
2008-05-01 19:31:49 +00:00
|
|
|
public class SidedefsTracePath : List<Sidedef>
|
2008-01-06 20:56:48 +00:00
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
2008-04-19 17:31:53 +00:00
|
|
|
public SidedefsTracePath()
|
2008-01-06 20:56:48 +00:00
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
}
|
|
|
|
|
|
|
|
// Constructor
|
2008-04-19 17:31:53 +00:00
|
|
|
public SidedefsTracePath(SidedefsTracePath p, Sidedef add) : base(p)
|
2008-01-06 20:56:48 +00:00
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
base.Add(add);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// This checks if the polygon is closed
|
|
|
|
public bool CheckIsClosed()
|
|
|
|
{
|
|
|
|
// There must be at least 2 sidedefs
|
|
|
|
if(base.Count > 1)
|
|
|
|
{
|
|
|
|
// The end sidedef must share a vertex with the first
|
|
|
|
return (base[0].Line.Start == base[base.Count - 1].Line.Start) ||
|
|
|
|
(base[0].Line.Start == base[base.Count - 1].Line.End) ||
|
|
|
|
(base[0].Line.End == base[base.Count - 1].Line.Start) ||
|
|
|
|
(base[0].Line.End == base[base.Count - 1].Line.End);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Not closed
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This makes a polygon from the path
|
|
|
|
public Polygon MakePolygon()
|
|
|
|
{
|
|
|
|
Polygon p = new Polygon();
|
|
|
|
|
|
|
|
// Any sides at all?
|
|
|
|
if(base.Count > 0)
|
|
|
|
{
|
|
|
|
// Add all sides
|
|
|
|
for(int i = 0; i < base.Count; i++)
|
|
|
|
{
|
|
|
|
// On front or back?
|
|
|
|
if(base[i].IsFront)
|
2008-01-07 23:03:36 +00:00
|
|
|
p.AddLast(new EarClipVertex(base[i].Line.End.Position));
|
2008-01-06 20:56:48 +00:00
|
|
|
else
|
2008-01-07 23:03:36 +00:00
|
|
|
p.AddLast(new EarClipVertex(base[i].Line.Start.Position));
|
2008-01-06 20:56:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|