From 811a2a97a8660775cc91271cc188ac1256e7a7f5 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 13 Feb 2026 21:43:14 -0800 Subject: [PATCH] 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. --- src/pipeline/m2_loader.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pipeline/m2_loader.cpp b/src/pipeline/m2_loader.cpp index a5dea683..55d8186b 100644 --- a/src/pipeline/m2_loader.cpp +++ b/src/pipeline/m2_loader.cpp @@ -520,9 +520,17 @@ void parseAnimTrackVanilla(const std::vector& 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;