UltimateZoneBuilder/Source/Core/VisualModes/VisualVertex.cs

94 lines
2.8 KiB
C#
Raw Normal View History

2013-03-18 13:52:27 +00:00
using System;
using CodeImp.DoomBuilder.Geometry;
2013-03-18 13:52:27 +00:00
using CodeImp.DoomBuilder.Map;
2019-08-08 16:24:33 +00:00
using CodeImp.DoomBuilder.Rendering;
2013-03-18 13:52:27 +00:00
namespace CodeImp.DoomBuilder.VisualModes
{
public class VisualVertexPair
{
private readonly VisualVertex floorvert;
private readonly VisualVertex ceilvert;
2013-03-18 13:52:27 +00:00
public VisualVertex[] Vertices { get { return new[] { floorvert, ceilvert }; } }
public VisualVertex FloorVertex { get { return floorvert; } }
public VisualVertex CeilingVertex { get { return ceilvert; } }
public bool Changed { set { floorvert.Changed = value; ceilvert.Changed = value; } }
2013-03-18 13:52:27 +00:00
public VisualVertexPair(VisualVertex floorvert, VisualVertex ceilvert)
{
if(floorvert.CeilingVertex == ceilvert.CeilingVertex)
2013-03-18 13:52:27 +00:00
throw new Exception("VisualVertexPair: both verts have the same alignment! We cannot tolerate this!");
this.floorvert = floorvert;
this.ceilvert = ceilvert;
2013-03-18 13:52:27 +00:00
}
public void Update()
{
if(floorvert.Changed) floorvert.Update();
if(ceilvert.Changed) ceilvert.Update();
2013-03-18 13:52:27 +00:00
}
public void Deselect()
{
floorvert.Selected = false;
ceilvert.Selected = false;
2013-03-18 13:52:27 +00:00
}
}
public abstract class VisualVertex : IVisualPickable
2013-03-18 13:52:27 +00:00
{
//Constants
public const float DEFAULT_SIZE = 6.0f;
2013-03-18 13:52:27 +00:00
//Variables
protected readonly Vertex vertex;
2013-03-18 13:52:27 +00:00
private Matrix position;
protected bool selected;
protected bool changed;
protected readonly bool ceilingVertex;
protected bool haveOffset;
2013-03-18 13:52:27 +00:00
//Properties
internal Matrix Position { get { return position; } }
public Vertex Vertex { get { return vertex; } }
public bool Selected { get { return selected; } set { selected = value; } }
public bool Changed { get { return changed; } set { changed |= value; } }
public bool CeilingVertex { get { return ceilingVertex; } }
public bool HaveHeightOffset { get { return haveOffset; } }
2013-03-18 13:52:27 +00:00
protected VisualVertex(Vertex v, bool ceilingVertex)
{
2013-03-18 13:52:27 +00:00
vertex = v;
position = Matrix.Identity;
this.ceilingVertex = ceilingVertex;
}
public void SetPosition(Vector3D pos)
{
2013-03-18 13:52:27 +00:00
position = Matrix.Translation(pos.x, pos.y, pos.z);
}
public virtual void Update() { }
/// <summary>
/// This is called when the thing must be tested for line intersection. This should reject
/// as fast as possible to rule out all geometry that certainly does not touch the line.
/// </summary>
public virtual bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{
2013-03-18 13:52:27 +00:00
return false;
}
/// <summary>
/// This is called when the thing must be tested for line intersection. This should perform
/// accurate hit detection and set u_ray to the position on the ray where this hits the geometry.
/// </summary>
public virtual bool PickAccurate(Vector3D from, Vector3D to, Vector3D dir, ref float u_ray)
{
2013-03-18 13:52:27 +00:00
return false;
}
}
}