From 384324c85a03ce28f82c63d3a0f6283f863761fe Mon Sep 17 00:00:00 2001 From: Orkuncakilkaya Date: Mon, 28 Sep 2026 16:29:15 +0300 Subject: [PATCH] frame allocs (25.2): ludic.anim's pose scratch made with its state (pose_part, the name no longer taken for udp_ip's part), a model's clips read at its load declared Co-Authored-By: Claude Opus 5.5 --- packages/ludic.anim/clip.ludic | 2 +- packages/ludic.anim/pose.ludic | 26 +++++++++++++------------- packages/ludic.anim/read.ludic | 1 + 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/ludic.anim/clip.ludic b/packages/ludic.anim/clip.ludic index 3da981cf..f9c89af9 100644 --- a/packages/ludic.anim/clip.ludic +++ b/packages/ludic.anim/clip.ludic @@ -22,7 +22,7 @@ export state AnimState { q_a: floats = floats(4) q_b: floats = floats(4) q_cur: floats = floats(4) - parts: []floats = null + parts: []floats = pose_parts_new() rot_s: floats = null pos_s: floats = null hit_s: words = null diff --git a/packages/ludic.anim/pose.ludic b/packages/ludic.anim/pose.ludic index cab8880c..26b9e3e3 100644 --- a/packages/ludic.anim/pose.ludic +++ b/packages/ludic.anim/pose.ludic @@ -2,22 +2,22 @@ # skin_pose folds a delta D in as local = (G_p^-1 . D . G_p) . R_rest, and a channel gives the # absolute local L, so D = G_p . (L . R_rest^-1) . G_p^-1 (a root: D = L . R_rest^-1) -function part(anim_st: mut AnimState, i: int) -> floats { - if anim_st.parts == null { - anim_st.parts = new []floats - for k in 0 .. 8 { push(anim_st.parts, floats(4)) } - } - return anim_st.parts[i] +# eight quaternions of scratch, made with the state +function pose_parts_new() -> []floats { + let l = new []floats + for k in 0 .. 8 { push(l, floats(4)) } + return l } +function pose_part(anim_st: AnimState, i: int) -> floats { return anim_st.parts[i] } export function anim_to_pose(anim_st: mut AnimState, sk: Skin, rot: floats, pos: floats, hit: words) -> void { - let l = part(anim_st, 0) - let rinv = part(anim_st, 1) - let gp = part(anim_st, 2) - let gpi = part(anim_st, 3) - let tmp = part(anim_st, 4) - let d = part(anim_st, 5) - let v = part(anim_st, 6) + let l = pose_part(anim_st, 0) + let rinv = pose_part(anim_st, 1) + let gp = pose_part(anim_st, 2) + let gpi = pose_part(anim_st, 3) + let tmp = pose_part(anim_st, 4) + let d = pose_part(anim_st, 5) + let v = pose_part(anim_st, 6) for i in 0 .. sk.n_nodes { let p = sk.par[i] if (hit[i] & 1) != 0 { diff --git a/packages/ludic.anim/read.ludic b/packages/ludic.anim/read.ludic index c4278b8c..ef132f10 100644 --- a/packages/ludic.anim/read.ludic +++ b/packages/ludic.anim/read.ludic @@ -3,6 +3,7 @@ # Call it straight after a load and before the next one: `gltf_doc` and `gltf_bin` point at # whichever file was read last, so a clip that is not taken now cannot be taken later. +@alloc_ok("a model's clips read as it loads, once per file") export function anim_read_doc(anim_st: mut AnimState, render3d_st: mut Render3dState, dir: string) -> int { clips_init() if render3d_st.gltf_doc == null { return 0 }