Refactor TextureInfo into a struct

This commit is contained in:
wfowler
2019-05-29 21:57:51 -06:00
parent 2686563805
commit 43ebf69f01
2 changed files with 9 additions and 27 deletions

View File

@@ -266,7 +266,7 @@ namespace LibBSP {
-1, -1, 0);
}
default: {
return null;
return new TextureInfo();
}
}
}

View File

@@ -21,15 +21,15 @@ namespace LibBSP {
/// Some BSP formats lack this lump (or the information is contained in a
/// different lump) so their cases will be left out.
/// </summary>
[Serializable] public class TextureInfo {
[Serializable] public struct TextureInfo {
public byte[] data;
public MapType type;
public int version;
// No BSP format uses these so they are fields.
public Vector2d scale = new Vector2d(1, 1);
public double rotation = 0;
public Vector2d scale;
public double rotation;
public Vector3d uAxis {
get {
@@ -171,24 +171,6 @@ namespace LibBSP {
}
}
/// <summary>
/// Creates a new <see cref="TextureInfo"/> object with sensible defaults.
/// </summary>
public TextureInfo() {
data = new byte[40];
type = MapType.Quake;
version = 0;
uAxis = new Vector3d(0, 0, 0);
vAxis = new Vector3d(0, 0, 0);
translation = new Vector2d(0, 0);
flags = 0;
texture = -1;
scale = new Vector2d(1, 1);
rotation = 0;
}
/// <summary>
/// Creates a new <see cref="TextureInfo"/> object from a <c>byte</c> array.
/// </summary>
@@ -219,17 +201,17 @@ namespace LibBSP {
/// <param name="texture">Index into the texture list for the texture this <see cref="TextureInfo"/> uses.</param>
/// <param name="rotation">Rotation of the texutre axes.</param>
public TextureInfo(Vector3d u, Vector3d v, Vector2d translation, Vector2d scale, int flags, int texture, double rotation) {
data = new byte[40];
type = MapType.Quake;
version = 0;
this.data = new byte[40];
this.type = MapType.Quake;
this.version = 0;
this.scale = scale;
this.rotation = rotation;
uAxis = u;
vAxis = v;
this.translation = translation;
this.scale = scale;
this.flags = flags;
this.texture = texture;
this.rotation = rotation;
}
/// <summary>