55#include < cstdint>
66#include < optional>
77#include < string>
8+ #include < variant>
89#include < vector>
910
1011#include " Generic.h"
@@ -14,30 +15,31 @@ namespace mdlpp::MDL {
1415struct Bone {
1516 enum Flags : int32_t {
1617 FLAG_NONE = 0 ,
17- FLAG_CALCULATE_MASK = 0x0000001F ,
18- FLAG_PHYSICALLY_SIMULATED = 0x00000001 ,
19- FLAG_PHYSICS_PROCEDURAL = 0x00000002 ,
20- FLAG_ALWAYS_PROCEDURAL = 0x00000004 ,
21- FLAG_SCREEN_ALIGN_SPHERE = 0x00000008 ,
22- FLAG_SCREEN_ALIGN_CYLINDER = 0x00000010 ,
23- FLAG_USED_MASK = 0x0007FF00 ,
24- FLAG_USED_BY_ANYTHING = 0x0007FF00 ,
25- FLAG_USED_BY_HITBOX = 0x00000100 ,
26- FLAG_USED_BY_ATTACHMENT = 0x00000200 ,
27- FLAG_USED_BY_VERTEX_MASK = 0x0003FC00 ,
28- FLAG_USED_BY_VERTEX_LOD0 = 0x00000400 ,
29- FLAG_USED_BY_VERTEX_LOD1 = 0x00000800 ,
30- FLAG_USED_BY_VERTEX_LOD2 = 0x00001000 ,
31- FLAG_USED_BY_VERTEX_LOD3 = 0x00002000 ,
32- FLAG_USED_BY_VERTEX_LOD4 = 0x00004000 ,
33- FLAG_USED_BY_VERTEX_LOD5 = 0x00008000 ,
34- FLAG_USED_BY_VERTEX_LOD6 = 0x00010000 ,
35- FLAG_USED_BY_VERTEX_LOD7 = 0x00020000 ,
36- FLAG_USED_BY_BONE_MERGE = 0x00040000 ,
37- FLAG_TYPE_MASK = 0x00F00000 ,
38- FLAG_FIXED_ALIGNMENT = 0x00100000 ,
39- FLAG_HAS_SAVEFRAME_POS = 0x00200000 ,
40- FLAG_HAS_SAVEFRAME_ROT = 0x00400000 ,
18+ FLAG_PHYSICALLY_SIMULATED = 1 << 0 ,
19+ FLAG_PHYSICS_PROCEDURAL = 1 << 1 ,
20+ FLAG_ALWAYS_PROCEDURAL = 1 << 2 ,
21+ FLAG_SCREEN_ALIGN_SPHERE = 1 << 3 ,
22+ FLAG_SCREEN_ALIGN_CYLINDER = 1 << 4 ,
23+ FLAG_CALCULATE_MASK = FLAG_PHYSICALLY_SIMULATED | FLAG_PHYSICS_PROCEDURAL | FLAG_ALWAYS_PROCEDURAL | FLAG_SCREEN_ALIGN_SPHERE | FLAG_SCREEN_ALIGN_CYLINDER,
24+ FLAG_USED_BY_HITBOX = 1 << 8 ,
25+ FLAG_USED_BY_ATTACHMENT = 1 << 9 ,
26+ FLAG_USED_BY_VERTEX_LOD0 = 1 << 10 ,
27+ FLAG_USED_BY_VERTEX_LOD1 = 1 << 11 ,
28+ FLAG_USED_BY_VERTEX_LOD2 = 1 << 12 ,
29+ FLAG_USED_BY_VERTEX_LOD3 = 1 << 13 ,
30+ FLAG_USED_BY_VERTEX_LOD4 = 1 << 14 ,
31+ FLAG_USED_BY_VERTEX_LOD5 = 1 << 15 ,
32+ FLAG_USED_BY_VERTEX_LOD6 = 1 << 16 ,
33+ FLAG_USED_BY_VERTEX_LOD7 = 1 << 17 ,
34+ FLAG_USED_BY_BONE_MERGE = 1 << 18 ,
35+ FLAG_USED_BY_VERTEX_MASK = FLAG_USED_BY_VERTEX_LOD0 | FLAG_USED_BY_VERTEX_LOD1 | FLAG_USED_BY_VERTEX_LOD2 | FLAG_USED_BY_VERTEX_LOD3 | FLAG_USED_BY_VERTEX_LOD4 | FLAG_USED_BY_VERTEX_LOD5 | FLAG_USED_BY_VERTEX_LOD6 | FLAG_USED_BY_VERTEX_LOD7,
36+ FLAG_USED_MASK = FLAG_USED_BY_HITBOX | FLAG_USED_BY_ATTACHMENT | FLAG_USED_BY_VERTEX_MASK | FLAG_USED_BY_BONE_MERGE,
37+ FLAG_USED_BY_ANYTHING = FLAG_USED_MASK,
38+ FLAG_FIXED_ALIGNMENT = 1 << 20 ,
39+ FLAG_HAS_SAVEFRAME_POS = 1 << 21 ,
40+ FLAG_HAS_SAVEFRAME_ROT = 1 << 22 ,
41+ FLAG_EMPTY_SLOT = 1 << 23 ,
42+ FLAG_TYPE_MASK = FLAG_FIXED_ALIGNMENT | FLAG_HAS_SAVEFRAME_POS | FLAG_HAS_SAVEFRAME_ROT | FLAG_EMPTY_SLOT,
4143 };
4244
4345 // int32_t nameIndex;
@@ -101,8 +103,7 @@ struct AnimBoneData {
101103 Flags flags;
102104
103105 // static data when RAW flags are set
104- std::optional<sourcepp::math::QuatCompressed48> staticRotation48;
105- std::optional<sourcepp::math::QuatCompressed64> staticRotation64;
106+ std::variant<std::monostate, sourcepp::math::QuatCompressed48, sourcepp::math::QuatCompressed64> staticRotation;
106107 std::optional<sourcepp::math::Vec3Compressed48> staticPosition;
107108
108109 // keyframe data when ANIM flags are set
@@ -119,8 +120,8 @@ struct IKError {
119120};
120121
121122struct CompressedIKError {
122- float scale[ 6 ] ;
123- int16_t offset[ 6 ] ;
123+ sourcepp::math::Vec< 6 , float > scale;
124+ sourcepp::math::Vec< 6 , int16_t > offset;
124125 std::vector<AnimValue> animValues;
125126};
126127
@@ -220,7 +221,9 @@ struct Event {
220221 float cycle;
221222 int32_t event;
222223 int32_t type;
223- std::array<char , 64 > options;
224+
225+ // char options[64];
226+ std::string options;
224227
225228 // int32_t eventNameIndex;
226229 std::string eventName;
@@ -316,10 +319,10 @@ SOURCEPP_BITFLAGS_ENUM(SequenceDesc::Flags)
316319
317320struct Material {
318321 enum Flags : int32_t {
319- FLAG_NONE = 0 ,
320- // Note: mstudiotexture_t.flags field exists in MDL binary format but is never set by studiomdl compiler.
321- // The field remains 0 in all compiled MDL files. RELATIVE_TEXTURE_PATH_SPECIFIED (0x1) exists in the
322- // compiler source but is not written to the file format .
322+ FLAG_NONE = 0 ,
323+ FLAG_RELATIVE_TEXTURE_PATH_SPECIFIED = 1 << 0 ,
324+ // Note: mstudiotexture_t.flags field exists in the format but is never set by the studiomdl compiler.
325+ // The engine might still check this flag, so it is exposed here anyway .
323326 };
324327
325328 // int32_t nameIndex;
@@ -338,25 +341,25 @@ struct Eyeball {
338341
339342 int32_t bone;
340343 sourcepp::math::Vec3f org;
341- float zoffset ;
344+ float zOffset ;
342345 float radius;
343346 sourcepp::math::Vec3f up;
344347 sourcepp::math::Vec3f forward;
345348 int32_t texture;
346349
347350 // int32_t unused1;
348- float iris_scale ;
351+ float irisScale ;
349352 // int32_t unused2;
350353
351- std::array<int32_t , 3 > upperflexdesc ;
352- std::array<int32_t , 3 > lowerflexdesc ;
353- std::array<float , 3 > uppertarget ;
354- std::array<float , 3 > lowertarget ;
354+ std::array<int32_t , 3 > upperFlexDesc ;
355+ std::array<int32_t , 3 > lowerFlexDesc ;
356+ std::array<float , 3 > upperTarget ;
357+ std::array<float , 3 > lowerTarget ;
355358
356- int32_t upperlidflexdesc ;
357- int32_t lowerlidflexdesc ;
359+ int32_t upperLidFlexDesc ;
360+ int32_t lowerLidFlexDesc ;
358361 // int32_t unused[4];
359- bool m_bNonFACS ;
362+ bool nonFACS ;
360363 // char unused3[3];
361364 // int32_t unused4[7];
362365};
@@ -379,11 +382,11 @@ struct VertexAnimWrinkle {
379382 uint8_t side;
380383 std::array<int16_t , 3 > delta;
381384 std::array<int16_t , 3 > ndelta;
382- int16_t wrinkledelta ;
385+ int16_t wrinkleDelta ;
383386};
384387
385388struct MeshFlex {
386- int32_t flexdesc ;
389+ int32_t flexDescIndex ;
387390
388391 // control curve
389392 float target0;
@@ -396,8 +399,8 @@ struct MeshFlex {
396399 std::vector<VertexAnim> vertAnims;
397400 std::vector<VertexAnimWrinkle> vertAnimsWrinkle;
398401
399- int32_t flexpair ;
400- uint8_t vertanimtype ; // 0=normal, 1=wrinkle
402+ int32_t flexPair ;
403+ uint8_t vertAnimType ; // 0=normal, 1=wrinkle
401404 // uint8_t unusedchar[3];
402405 // int32_t unused[6];
403406};
@@ -508,7 +511,7 @@ struct FlexControllerUI {
508511 std::string controllerName1; // right controller (stereo)
509512 std::string controllerName2; // value controller (NWAY only)
510513
511- uint8_t remaptype ;
514+ uint8_t remapType ;
512515 bool stereo;
513516 // uint8_t unused[2];
514517};
@@ -533,7 +536,7 @@ struct IKChain {
533536struct Mouth {
534537 int32_t bone;
535538 sourcepp::math::Vec3f forward;
536- int32_t flexdesc ;
539+ int32_t flexDescIndex ;
537540};
538541
539542enum FlexOpType : int32_t {
@@ -725,21 +728,21 @@ struct MDL {
725728 // int32_t includeModelIndex;
726729 std::vector<IncludeModel> includeModels;
727730
728- int32_t virtualModel;
731+ // int32_t virtualModel;
729732
730733 // int32_t animationBlocksNameIndex;
731734 // int32_t animationBlocksCount;
732735 // int32_t animationBlocksIndex;
733736 std::string animationBlocksName;
734737 std::vector<AnimBlock> animationBlocks;
735738
736- int32_t animationBlockModel;
739+ // int32_t animationBlockModel;
737740
738741 // int32_t boneTableByNameIndex;
739742 std::vector<uint8_t > boneTableByName;
740743
741- int32_t vertexBase;
742- int32_t offsetBase;
744+ // int32_t vertexBase;
745+ // int32_t offsetBase;
743746
744747 uint8_t directionalDotProduct;
745748 uint8_t rootLOD;
@@ -755,7 +758,7 @@ struct MDL {
755758 float vertAnimFixedPointScale;
756759 // int32_t _unused2;
757760
758- int32_t studiohdr2index ;
761+ int32_t studioHdr2Index ;
759762
760763 // int32_t _unused3;
761764
0 commit comments