From 01d3aa725f05228e49bd3789a38e62548b45a647 Mon Sep 17 00:00:00 2001 From: Orkuncakilkaya Date: Mon, 28 Sep 2026 16:21:25 +0300 Subject: [PATCH] frame allocs (25.2): ludic.anim's quaternion scratch in its state's defaults, its skeleton scratch and missing-bone line declared; ludic.fishing's fact records made at the start (64) as the others' Co-Authored-By: Claude Opus 5.5 --- packages/ludic.anim/bones.ludic | 1 + packages/ludic.anim/clip.ludic | 6 +++--- packages/ludic.anim/mix.ludic | 5 ----- packages/ludic.anim/pose.ludic | 1 + packages/ludic.fishing/facts.ludic | 15 +++++++++++++++ packages/ludic.fishing/state.ludic | 4 ++-- packages/ludic.fishing/tests/fishing_test.ludic | 2 +- 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/packages/ludic.anim/bones.ludic b/packages/ludic.anim/bones.ludic index ea79251f..3401d2cc 100644 --- a/packages/ludic.anim/bones.ludic +++ b/packages/ludic.anim/bones.ludic @@ -2,6 +2,7 @@ # with the same bone names, and skin_find's first hit in the file belongs to whichever came first export function skin_joint(sk: Skin, name: string) -> int { let i = skin_joint_quiet(sk, name) + @alloc_ok("a line for a bone the rig does not have: a fault to fix, said as it happens") if i < 0 { print(`skin: no joint {name} in this skin`) } return i } diff --git a/packages/ludic.anim/clip.ludic b/packages/ludic.anim/clip.ludic index 09efbaab..3da981cf 100644 --- a/packages/ludic.anim/clip.ludic +++ b/packages/ludic.anim/clip.ludic @@ -19,9 +19,9 @@ export property Clip { export state AnimState { clips: []Clip = new []Clip positions: bool = false - q_a: floats = null - q_b: floats = null - q_cur: floats = null + q_a: floats = floats(4) + q_b: floats = floats(4) + q_cur: floats = floats(4) parts: []floats = null rot_s: floats = null pos_s: floats = null diff --git a/packages/ludic.anim/mix.ludic b/packages/ludic.anim/mix.ludic index 829996ca..7e951267 100644 --- a/packages/ludic.anim/mix.ludic +++ b/packages/ludic.anim/mix.ludic @@ -4,11 +4,6 @@ export function anim_mix(anim_st: mut AnimState, c: Clip, sk: Skin, t: float, w: float, rot: floats, pos: floats, hit: words) -> void { if c == null or sk == null { return } - if anim_st.q_a == null { - anim_st.q_a = floats(4) - anim_st.q_b = floats(4) - anim_st.q_cur = floats(4) - } var tt = t if c.dur > 0.0 { tt = t % c.dur } for ch in 0 .. c.n { diff --git a/packages/ludic.anim/pose.ludic b/packages/ludic.anim/pose.ludic index 427eb8f8..cab8880c 100644 --- a/packages/ludic.anim/pose.ludic +++ b/packages/ludic.anim/pose.ludic @@ -49,6 +49,7 @@ export function anim_to_pose(anim_st: mut AnimState, sk: Skin, rot: floats, pos: } # The scratch is made ONCE and grown, never allocated per call: a call is per actor per frame. +@alloc_ok("grown once to the largest skeleton posed, kept after") function scratch(anim_st: mut AnimState, n: int) -> void { if anim_st.cap >= n { return } anim_st.rot_s = floats(n * 4) diff --git a/packages/ludic.fishing/facts.ludic b/packages/ludic.fishing/facts.ludic index 1df7836e..68520b85 100644 --- a/packages/ludic.fishing/facts.ludic +++ b/packages/ludic.fishing/facts.ludic @@ -11,9 +11,24 @@ function fishing_fact_record(fishing_st: mut FishingState) -> FishingFact { fishing_st.fishing_fnext[0] += 1 return f } + return fishing_fact_more(fishing_st) +} +@alloc_ok("a new peak of facts held at once, past the 64 made at the start; kept and reused") +function fishing_fact_more(fishing_st: mut FishingState) -> FishingFact { let f = new FishingFact push(fishing_st.fishing_fpool, f) return f } +# the records made at the start, with a free list of room for them all +function fishing_fpool_new() -> []FishingFact { + let l = new []FishingFact + for i in 0 .. 64 { push(l, new FishingFact) } + return l +} +function fishing_ffree_new() -> []FishingFact { + let l = fishing_fpool_new() + List.clear(l) + return l +} # how many fact records have ever been made: the peak held at once, not the facts said export function fishing_fact_records(fishing_st: FishingState) -> int { return len(fishing_st.fishing_fpool) } diff --git a/packages/ludic.fishing/state.ludic b/packages/ludic.fishing/state.ludic index 72babe6f..6bc9ee2d 100644 --- a/packages/ludic.fishing/state.ludic +++ b/packages/ludic.fishing/state.ludic @@ -25,8 +25,8 @@ export state FishingState { fishing_run_next: float = 0.0 fishing_dice: Rng = null fishing_fact_q: Queue = fishing_fact_q__new() - fishing_fpool: []FishingFact = new []FishingFact # every fact record made, reused once no drain holds it (facts.ludic) - fishing_ffree: []FishingFact = new []FishingFact + fishing_fpool: []FishingFact = fishing_fpool_new() # every fact record made, reused once no drain holds it (facts.ludic) + fishing_ffree: []FishingFact = fishing_ffree_new() fishing_fnext: []int = words(1) fishing_n: int = 0 # the record: caught, the biggest (cm), a legend landed fishing_big: int = 0 diff --git a/packages/ludic.fishing/tests/fishing_test.ludic b/packages/ludic.fishing/tests/fishing_test.ludic index bf510c4d..341fdf18 100644 --- a/packages/ludic.fishing/tests/fishing_test.ludic +++ b/packages/ludic.fishing/tests/fishing_test.ludic @@ -268,6 +268,6 @@ program FishingTest { facts(fishing_st) } print(`fishing: 50 fish, {fishing_fact_records(fishing_st)} fact records made`) - expect(fishing_fact_records(fishing_st) < 30) + expect_eq(fishing_fact_records(fishing_st), 64) } }