Add M2 skeletal animation and fix terrain texture layers

- Implement GPU bone skinning for M2 doodads/creatures (gryphons, birds)
- Store bone hierarchy and animation keyframes per model
- Compute bone matrices per-instance with keyframe interpolation
- Upload bone weights/indices in vertex buffer, skinning in vertex shader
- Fix terrain texture rendering: restore sampler-to-unit uniform bindings
  removed during texture bind optimization (roads were invisible)
This commit is contained in:
Kelsi 2026-02-04 11:40:00 -08:00
parent 4bc5064515
commit 15fa055726
3 changed files with 197 additions and 20 deletions

View file

@ -52,6 +52,11 @@ struct M2ModelGPU {
std::string name;
// Skeletal animation data (kept from M2Model for bone computation)
std::vector<pipeline::M2Bone> bones;
std::vector<pipeline::M2Sequence> sequences;
bool hasAnimation = false; // True if any bone has keyframes
bool isValid() const { return vao != 0 && indexCount > 0; }
};
@ -70,9 +75,12 @@ struct M2Instance {
glm::vec3 worldBoundsMax;
// Animation state
float animTime = 0.0f; // Current animation time
float animTime = 0.0f; // Current animation time (ms)
float animSpeed = 1.0f; // Animation playback speed
uint32_t animId = 0; // Current animation sequence
int currentSequenceIndex = 0;// Index into sequences array
float animDuration = 0.0f; // Duration of current animation (ms)
std::vector<glm::mat4> boneMatrices;
void updateModelMatrix();
};