refactor(terrain): use WoweeModelLoader::toM2 for WOM loading in main game

terrain_manager.cpp had a 70-line duplicate of the WOM->M2 conversion that
ignored WOM3 multi-batch support. Replaced with a single toM2() call.
Also extended toM2 to copy bones and animation sequence headers so the
shared helper now produces a fully renderable M2Model from any WOM
version, with main game and editor both using the same code path.
This commit is contained in:
Kelsi 2026-05-06 01:38:31 -07:00
parent 23951d4075
commit a711a92875
2 changed files with 27 additions and 66 deletions

View file

@ -459,6 +459,29 @@ M2Model WoweeModelLoader::toM2(const WoweeModel& wom) {
m.materials.push_back(mat);
}
// Copy bones (WOM2/WOM3) — pivot/parent only, animation tracks are filled
// from the WoM animation block below.
for (const auto& wb : wom.bones) {
M2Bone bone;
bone.keyBoneId = wb.keyBoneId;
bone.parentBone = wb.parentBone;
bone.pivot = wb.pivot;
bone.flags = wb.flags;
m.bones.push_back(bone);
}
// Copy animation sequence headers (id/duration/movingSpeed). Per-bone
// keyframes inside WoM are richer than M2Sequence captures so a future
// animator may want a deeper conversion; this is enough for length-based
// selection in the renderer.
for (const auto& wa : wom.animations) {
M2Sequence seq;
seq.id = wa.id;
seq.duration = wa.durationMs;
seq.movingSpeed = wa.movingSpeed;
m.sequences.push_back(seq);
}
return m;
}