wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
bone.hpp
Go to the documentation of this file.
1#pragma once
2
7
8#include <cstdint>
9
10#include <welder/vocabulary.hpp>
11
12#include <wowlib/core/lang.hpp>
16
22 struct [[
23 =welder::weld,
24 =welder::weld_as("M2CompBone"),
26 =welder::doc(R"(
27 One skeleton bone. Abstract over the client version; construct a concrete
28 version with M2CompBone.ForVersion / for_version.)")
30 // The concretes default operator== — the base must be comparable too.
31 bool operator==(const M2CompBoneBase&) const = default;
32 };
34 enum class [[
35 =welder::weld,
36 =welder::flags,
37 =welder::doc(
38 "M2CompBone flags: parent-transform exemptions, billboarding "
39 "and physics participation.")
40 ]] BoneFlags : std::uint32_t {
41 IgnoreParentTranslate [[=welder::doc("Do not inherit parent translation.")]] = 0x1,
42 IgnoreParentScale [[=welder::doc("Do not inherit parent scale.")]] = 0x2,
43 IgnoreParentRotation [[=welder::doc("Do not inherit parent rotation.")]] = 0x4,
44 SphericalBillboard [[=welder::doc("Always face the viewer.")]] = 0x8,
45 CylindricalBillboardLockX [[=welder::doc("Billboard around the X axis.")]] = 0x10,
46 CylindricalBillboardLockY [[=welder::doc("Billboard around the Y axis.")]] = 0x20,
47 CylindricalBillboardLockZ [[=welder::doc("Billboard around the Z axis.")]] = 0x40,
48 Transformed [[=welder::doc("Has an animated transform.")]] = 0x200,
49 KinematicBone [[=welder::doc("MoP+: physics may drive this bone.")]] = 0x400,
50 HelmetAnimScaled [[=welder::doc("Scale by the helmet-anim-scaling record.")]
51 ] = 0x1000,
52 SequenceId [[=welder::doc(
53 "BfA+: parent_bone/submesh_id form a sequence id.")]] = 0x2000
54 };
56 namespace detail {
57 // The annotated era layouts; instantiate through the canonicalizing
58 // aliases below, never directly.
59 template <ClientVersion V>
60 struct M2CompBone;
62 template <ClientVersion V>
63 requires (V < M2CompressedBones)
64 struct [[
65 =welder::weld,
66 =welder::doc(
67 "A bone, vanilla layout: raw-quaternion rotations, no name CRC.")
69 [[=welder::doc("Key-bone-lookup back reference, -1 if none.")]]
70 std::int32_t keyBoneId = -1;
71 [[=welder::doc("See BoneFlags.")]]
73 [[=welder::doc("Parent bone index, -1 for roots.")]]
74 std::int16_t parentBone = -1;
75 [[=welder::doc("Mesh part id.")]]
76 std::uint16_t submeshId = 0;
77 [[=welder::doc("Translation keyframes, relative to the parent bone.")]]
79 [[=welder::doc("Rotation keyframes as raw quaternions.")]]
81 [[=welder::doc("Scale keyframes.")]]
83 [[=welder::doc("The bone's pivot point.")]]
84 C3Vector pivot{};
85
86 bool operator==(const M2CompBone&) const = default;
87 };
88
89 template <ClientVersion V>
90 requires (V >= M2CompressedBones)
91 struct [[
92 =welder::weld,
93 =welder::doc(
94 "A bone (TBC+): compressed-quaternion rotations plus the debug name "
95 "CRC; the track era inside follows the entity version.")
96 ]] M2CompBone<V> : M2CompBoneBase {
97 [[=welder::doc("Key-bone-lookup back reference, -1 if none.")]]
98 std::int32_t keyBoneId = -1;
99 [[=welder::doc("See BoneFlags.")]]
101 [[=welder::doc("Parent bone index, -1 for roots.")]]
102 std::int16_t parentBone = -1;
103 [[=welder::doc("Mesh part id.")]]
104 std::uint16_t submeshId = 0;
105 [[=welder::doc("CRC of the authoring bone name (debug only).")]]
106 std::uint32_t boneNameCrc = 0;
107 [[=welder::doc("Translation keyframes, relative to the parent bone.")]]
109 [[=welder::doc("Rotation keyframes as compressed quaternions.")]]
111 [[=welder::doc("Scale keyframes.")]]
113 [[=welder::doc("The bone's pivot point.")]]
114 C3Vector pivot{};
116 bool operator==(const M2CompBone&) const = default;
117 };
118 }
119
123 template <ClientVersion V>
124 using M2CompBone =
125 detail::M2CompBone<canonicalVersion(V, M2BonePivots, M2Versions)>;
126}
Client version identity, the flavor axis that separates a client's CONTENT version from the engine ge...
Binding-language identities welder's core does not name.
#define WOWLIB_CS_FAMILY_SURFACE
The C# rod's family-surface opt-in, spellable in every build.
Definition lang.hpp:44
The M2 version vocabulary: the layout pivots record/entity partial specializations key on,...
M2 body record structs (sequences, bones, tracks, textures, cameras, emitters) and their flag enums.
Definition bone.hpp:17
BoneFlags
M2CompBone flags: parent-transform exemptions, billboarding and physics participation.
Definition bone.hpp:31
@ Transformed
Has an animated transform.
Definition bone.hpp:39
@ IgnoreParentScale
Do not inherit parent scale.
Definition bone.hpp:33
@ SphericalBillboard
Always face the viewer.
Definition bone.hpp:35
@ CylindricalBillboardLockY
Billboard around the Y axis.
Definition bone.hpp:37
@ IgnoreParentRotation
Do not inherit parent rotation.
Definition bone.hpp:34
@ KinematicBone
MoP+: physics may drive this bone.
Definition bone.hpp:40
@ CylindricalBillboardLockX
Billboard around the X axis.
Definition bone.hpp:36
@ CylindricalBillboardLockZ
Billboard around the Z axis.
Definition bone.hpp:38
@ IgnoreParentTranslate
Do not inherit parent translation.
Definition bone.hpp:32
detail::M2Track< T, canonicalVersion(V, M2TrackPivots, M2Versions)> M2Track
An animation track for value type T — the canonicalizing face of detail::M2Track: every client versio...
Definition track.hpp:498
detail::M2CompBone< canonicalVersion(V, M2BonePivots, M2Versions)> M2CompBone
A bone — the canonicalizing face of detail::M2CompBone: every client version maps to its range's firs...
Definition bone.hpp:115
constexpr std::array M2BonePivots
M2CompBone: raw→compressed quaternions + name CRC at TBC, per-sequence track timelines at WotLK.
constexpr ClientVersion M2CompressedBones
TBC (v260+): bone rotations become compressed M2CompQuat (vanilla stored raw C4Quaternion),...
constexpr std::array M2Versions
The versions M2 is instantiated (and welded) for: every targeted last-minor-of-major release,...
constexpr ClientVersion canonicalVersion(ClientVersion v, std::span< const ClientVersion > pivots, std::span< const ClientVersion > grid)
The canonical version v collapses to: the FIRST grid version in v's range.
A 3D float vector — the workhorse: positions, normals, rotations-as-Euler-degrees in placements.
Definition types.hpp:49
The version-agnostic base of every M2CompBone<V> (welded as "M2CompBone").
Definition bone.hpp:25
bool operator==(const M2CompBoneBase &) const =default
record::M2Track< C4Quaternion, V > rotation
Definition bone.hpp:71
bool operator==(const M2CompBone &) const =default
The M2 animation vocabulary (namespace wowlib::formats::m2::root::record): the small fixed-size primi...