From c118271565aec1cd06bb05133114d3eecbf6cbbd Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 19 Nov 2024 14:30:54 -0500 Subject: [PATCH] Add VBSP lump 29 --- SabreTools.Models/BSP/PhysCollideLump.cs | 11 +++++++ SabreTools.Models/BSP/PhysModel.cs | 42 ++++++++++++++++++++++++ SabreTools.Models/BSP/PhysSolid.cs | 25 ++++++++++++++ SabreTools.Models/BSP/VbspFile.cs | 6 ++-- 4 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 SabreTools.Models/BSP/PhysCollideLump.cs create mode 100644 SabreTools.Models/BSP/PhysModel.cs create mode 100644 SabreTools.Models/BSP/PhysSolid.cs diff --git a/SabreTools.Models/BSP/PhysCollideLump.cs b/SabreTools.Models/BSP/PhysCollideLump.cs new file mode 100644 index 0000000..af1495a --- /dev/null +++ b/SabreTools.Models/BSP/PhysCollideLump.cs @@ -0,0 +1,11 @@ +namespace SabreTools.Models.BSP +{ + /// + public sealed class PhysCollideLump : Lump + { + /// + /// Models + /// + public PhysModel[]? Models { get; set; } + } +} \ No newline at end of file diff --git a/SabreTools.Models/BSP/PhysModel.cs b/SabreTools.Models/BSP/PhysModel.cs new file mode 100644 index 0000000..46bafed --- /dev/null +++ b/SabreTools.Models/BSP/PhysModel.cs @@ -0,0 +1,42 @@ +using System.Runtime.InteropServices; + +namespace SabreTools.Models.BSP +{ + /// + /// The physcollide lump (Lump 29) contains physics data for the world. + /// + /// + [StructLayout(LayoutKind.Sequential)] + public sealed class PhysModel + { + /// + /// Perhaps the index of the model to which this physics model applies? + /// + public int ModelIndex; + + /// + /// Total size of the collision data sections + /// + public int DataSize; + + /// + /// Size of the text section + /// + public int KeydataSize; + + /// + /// Number of collision data sections + /// + public int SolidCount; + + /// + /// Collision data of length + /// + public PhysSolid[]? Solids; + + /// + /// Key data of size + /// + public byte[]? TextData; + } +} \ No newline at end of file diff --git a/SabreTools.Models/BSP/PhysSolid.cs b/SabreTools.Models/BSP/PhysSolid.cs new file mode 100644 index 0000000..13f4dc5 --- /dev/null +++ b/SabreTools.Models/BSP/PhysSolid.cs @@ -0,0 +1,25 @@ +using System.Runtime.InteropServices; + +namespace SabreTools.Models.BSP +{ + /// + /// The last two parts appear to be identical to the PHY file format, + /// which means their exact contents are unknown. Note that the + /// compactsurfaceheader_t structure contains the data size of each + /// collision data section (including the rest of the header) + /// + /// + [StructLayout(LayoutKind.Sequential)] + public sealed class PhysSolid + { + /// + /// Size of the collision data + /// + public int Size; + + /// + /// Collision data of length + /// + public byte[]? CollisionData; + } +} \ No newline at end of file diff --git a/SabreTools.Models/BSP/VbspFile.cs b/SabreTools.Models/BSP/VbspFile.cs index e73d53f..035dd01 100644 --- a/SabreTools.Models/BSP/VbspFile.cs +++ b/SabreTools.Models/BSP/VbspFile.cs @@ -166,8 +166,10 @@ namespace SabreTools.Models.BSP /// TODO: Find definition and implement // public PhysDispLump? PhysDispLump { get; set; } - // TODO: Implement Lump 29 - // https://developer.valvesoftware.com/wiki/BSP_(Source)#Physics + /// + /// LUMP_PHYSCOLLIDE [29] + /// + public PhysCollideLump? PhysCollideLump { get; set; } /// /// LUMP_VERTNORMALS [30]