From 0470d5bbc6ef9b4da9f1a8446303f8cd54288a13 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Wed, 16 Sep 2026 13:31:20 -0500 Subject: [PATCH] Fix animated frame budget for non-square emote cells main() capped resample() at the square-cell frame budget (128 across 4 columns) regardless of cell shape, but layout() forces a wide/tall cell to a single column, whose real budget is only 32. A long animation in a non-square cell would blow past MAX_TEXTURE and die instead of resampling down to a fitting framerate. --- tools/add_emote.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/add_emote.py b/tools/add_emote.py index 85a0d5e..d2c812f 100644 --- a/tools/add_emote.py +++ b/tools/add_emote.py @@ -126,6 +126,17 @@ def resample(durations, budget): return fps, indices +def max_frames(cell): + """Most frames `layout` can pack for this cell shape within MAX_TEXTURE. + + A non-square cell stays single-column (see `layout`), so its budget is + shallower than a square cell's, which can spread across MAX_COLS. + """ + cw, ch = cell + cols = MAX_COLS if cw == FRAME else 1 + return cols * (MAX_TEXTURE // ch) + + def layout(count, cell): """Column count and texture size for `count` frames. @@ -286,7 +297,7 @@ def main(): info = None print('%s: static, %s in a %dx%d texture' % (args.name, shape, tw, th)) else: - fps, indices = resample(durations, MAX_COLS * (MAX_TEXTURE // FRAME)) + fps, indices = resample(durations, max_frames(cell)) sheet, nframes, cols, tw, th = build_sheet(frames, indices, cell) info = (nframes, fps) print('%s: %d source frames (%.2fs) -> %d frames at %dfps (%.2fs, '