diff --git a/LibBSP/Source/Extensions/PlaneExtensions.cs b/LibBSP/Source/Extensions/PlaneExtensions.cs
index e2448e4..90627da 100644
--- a/LibBSP/Source/Extensions/PlaneExtensions.cs
+++ b/LibBSP/Source/Extensions/PlaneExtensions.cs
@@ -318,9 +318,8 @@ namespace LibBSP {
case MapType.Vindictus:
case MapType.Quake2:
case MapType.Daikatana:
- case MapType.TacticalInterventionEncrypted:
- case MapType.Titanfall: {
- BitConverter.GetBytes(BestAxis(p)).CopyTo(bytes, 16);
+ case MapType.TacticalInterventionEncrypted: {
+ BitConverter.GetBytes(p.Type()).CopyTo(bytes, 16);
break;
}
}
@@ -355,6 +354,46 @@ namespace LibBSP {
return bestaxis;
}
+ ///
+ /// Gets the axial type of this plane.
+ /// 0 = X
+ /// 1 = Y
+ /// 2 = Z
+ /// 3 = Closest to X
+ /// 4 = Closest to Y
+ /// 5 = Closest to Z
+ ///
+ ///
+ /// This more closely resembles the type calculation of zhlt, q2tools seems to use a greater-than-or-equal
+ /// comparison for the "closest to" types whereas we use a greater-than here. The difference should be minimal.
+ ///
+ /// This .
+ /// The axial type of this plane.
+ public static int Type(this Plane p) {
+ double ax = Math.Abs(p.normal.x);
+ if (ax >= 1.0) {
+ return 0;
+ }
+
+ double ay = Math.Abs(p.normal.y);
+ if (ay >= 1.0) {
+ return 1;
+ }
+
+ double az = Math.Abs(p.normal.z);
+ if (az >= 1.0) {
+ return 2;
+ }
+
+ if (ax > ay && ax > az) {
+ return 3;
+ }
+ if (ay > ax && ay > az) {
+ return 4;
+ }
+ return 5;
+ }
+
///
/// Gets the index for this lump in the BSP file for a specific map format.
///
@@ -402,6 +441,12 @@ namespace LibBSP {
}
}
+ ///
+ /// Gets the structure length for the specified .
+ ///
+ /// The version of BSP this plane came from.
+ /// The version of the planes lump this plane came from.
+ /// The length of this structure, in bytes.
public static int GetStructLength(MapType type, int version) {
int structLength = 0;
switch (type) {