diff --git a/src/AcDream.App/Rendering/GameWindow.cs b/src/AcDream.App/Rendering/GameWindow.cs index 351bf9b..b211b81 100644 --- a/src/AcDream.App/Rendering/GameWindow.cs +++ b/src/AcDream.App/Rendering/GameWindow.cs @@ -946,6 +946,23 @@ public sealed class GameWindow : IDisposable else if (idleCycle.Animation.PartFrames.Count <= 1) _liveAnimRejectPartFrames++; + // Per-entity dump for the first N spawns so we can see actual + // AnimData values for live creatures and compare against retail. + if (_liveSpawnReceived <= 30) + { + if (idleCycle is not null) + Console.WriteLine($"live: SPAWN[{_liveSpawnReceived}] name='{spawn.Name ?? "?"}' " + + $"setup=0x{spawn.SetupTableId:X8} mt=0x{(spawn.MotionTableId ?? 0):X8} " + + $"cycle: anim=0x{(uint)idleCycle.Animation.Id:X8} " + + $"low={idleCycle.LowFrame} high={idleCycle.HighFrame} " + + $"framerate={idleCycle.Framerate:F2} partFrames={idleCycle.Animation.PartFrames.Count} " + + $"numParts={idleCycle.Animation.NumParts}"); + else + Console.WriteLine($"live: SPAWN[{_liveSpawnReceived}] name='{spawn.Name ?? "?"}' " + + $"setup=0x{spawn.SetupTableId:X8} mt=0x{(spawn.MotionTableId ?? 0):X8} " + + $"cycle=null (no motion table / resolver failed)"); + } + if (idleCycle is not null && idleCycle.Framerate != 0f && idleCycle.HighFrame > idleCycle.LowFrame && idleCycle.Animation.PartFrames.Count > 1) diff --git a/src/AcDream.Core/Meshing/MotionResolver.cs b/src/AcDream.Core/Meshing/MotionResolver.cs index fdd118f..6e7e9b8 100644 --- a/src/AcDream.Core/Meshing/MotionResolver.cs +++ b/src/AcDream.Core/Meshing/MotionResolver.cs @@ -78,7 +78,39 @@ public static class MotionResolver var resolved = ResolveIdleCycleInternal(setup, dats, motionTableIdOverride, stanceOverride, commandOverride); if (resolved is null) return null; var (anim, ad) = resolved.Value; - return new IdleCycle(anim, ad.LowFrame, ad.HighFrame, ad.Framerate); + + // Sentinel resolution — matches ACViewer's AnimSequenceNode.set_animation_id + // (references/ACViewer/.../Physics/Animation/AnimSequenceNode.cs:96-113). + // + // AnimData in the dats encodes a few sentinel values that the raw int + // fields can't represent directly: + // * HighFrame == -1 → "play the whole animation" (use NumFrames - 1) + // * HighFrame > NumFrames - 1 → clamp (defensive for malformed data) + // * LowFrame >= NumFrames → clamp to NumFrames - 1 + // * LowFrame > HighFrame after clamping → collapse to a single frame + // + // Our Phase 6.1 code naively used the raw LowFrame/HighFrame and then + // rejected the cycle if `HighFrame <= LowFrame`, which silently threw + // away every animated creature whose AnimData used the -1 sentinel — + // i.e. almost all of them. Resolving here makes the IdleCycle carry + // the real frame range, so downstream playback/filtering sees a span + // it can advance through. + int numFrames = anim.PartFrames.Count; + int lowFrame = ad.LowFrame; + int highFrame = ad.HighFrame; + + if (highFrame < 0) + highFrame = numFrames - 1; + if (lowFrame >= numFrames) + lowFrame = numFrames - 1; + if (highFrame >= numFrames) + highFrame = numFrames - 1; + if (lowFrame < 0) + lowFrame = 0; + if (lowFrame > highFrame) + highFrame = lowFrame; + + return new IdleCycle(anim, lowFrame, highFrame, ad.Framerate); } public static AnimationFrame? GetIdleFrame(