using System.Runtime.InteropServices;
namespace SabreTools.Data.Models.BSP
{
///
/// The structure is 176 bytes long. The startPosition element is the
/// coordinates of the first corner of the displacement. DispVertStart
/// and DispTriStart are indices into the DispVerts and DispTris lumps.
/// The power entry gives the number of subdivisions in the displacement
/// surface - allowed values are 2, 3 and 4, and these correspond to 4,
/// 8 and 16 subdivisions on each side of the displacement surface.
/// The structure also references any neighbouring displacements on the
/// sides or the corners of this displacement through the EdgeNeighbors
/// and CornerNeighbors members. There are complex rules governing the
/// order that these neighbour displacements are given; see the comments
/// in bspfile.h for more. The MapFace value is an index into the face
/// array and is face that was turned into a displacement surface.
/// This face is used to set the texture and overall physical location
/// and boundaries of the displacement.
///
///
[StructLayout(LayoutKind.Sequential)]
public sealed class DispInfo
{
///
/// Start position used for orientation
///
public Vector3D StartPosition = new();
///
/// Index into LUMP_DISP_VERTS.
///
public int DispVertStart;
///
/// Index into LUMP_DISP_TRIS.
///
public int DispTriStart;
///
/// Power - indicates size of surface (2^power 1)
///
public int Power;
///
/// Minimum tesselation allowed
///
public int MinTess;
///
/// Lighting smoothing angle
///
public float SmoothingAngle;
///
/// Surface contents
///
public int Contents;
///
/// Which map face this displacement comes from.
///
public ushort MapFace;
///
/// Index into ddisplightmapalpha.
///
public int LightmapAlphaStart;
///
/// Index into LUMP_DISP_LIGHTMAP_SAMPLE_POSITIONS.
///
public int LightmapSamplePositionStart;
///
/// Indexed by NEIGHBOREDGE_ defines.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public CDispNeighbor[] EdgeNeighbors = new CDispNeighbor[4];
///
/// Indexed by CORNER_ defines.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public CDispCornerNeighbors[] CornerNeighbors = new CDispCornerNeighbors[4];
///
/// Active verticies
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
public uint[] AllowedVerts = new uint[10];
}
}