Fix vanilla M2 walk animation timestamp normalization

Vanilla M2 tracks store absolute timestamps in the flat array (e.g.
1000-2000ms) but the renderer plays animTime from 0 to duration.
Normalize timestamps to 0-relative after slicing per-sequence ranges
so findKeyframeIndex matches correctly.
This commit is contained in:
Kelsi 2026-02-13 21:43:14 -08:00
parent 22728b461f
commit 811a2a97a8

View file

@ -520,9 +520,17 @@ void parseAnimTrackVanilla(const std::vector<uint8_t>& data,
if (start >= end || start >= disk.nTimestamps) continue;
end = std::min(end, disk.nTimestamps);
// Copy timestamps for this sequence
// Copy timestamps for this sequence, normalized to start at 0
// (vanilla stores absolute timestamps in the flat array, but the
// renderer expects 0-relative times matching sequence duration)
track.sequences[i].timestamps.assign(
allTimestamps.begin() + start, allTimestamps.begin() + end);
if (!track.sequences[i].timestamps.empty()) {
uint32_t firstTime = track.sequences[i].timestamps[0];
for (auto& ts : track.sequences[i].timestamps) {
ts -= firstTime;
}
}
// Copy key values for this sequence
if (start >= disk.nKeys) continue;