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 <noreply@anthropic.com>
This commit is contained in:
parent
8dfcccad41
commit
01d3aa725f
7 changed files with 23 additions and 11 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
# with the same bone names, and skin_find's first hit in the file belongs to whichever came first
|
# 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 {
|
export function skin_joint(sk: Skin, name: string) -> int {
|
||||||
let i = skin_joint_quiet(sk, name)
|
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`) }
|
if i < 0 { print(`skin: no joint {name} in this skin`) }
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ export property Clip {
|
||||||
export state AnimState {
|
export state AnimState {
|
||||||
clips: []Clip = new []Clip
|
clips: []Clip = new []Clip
|
||||||
positions: bool = false
|
positions: bool = false
|
||||||
q_a: floats = null
|
q_a: floats = floats(4)
|
||||||
q_b: floats = null
|
q_b: floats = floats(4)
|
||||||
q_cur: floats = null
|
q_cur: floats = floats(4)
|
||||||
parts: []floats = null
|
parts: []floats = null
|
||||||
rot_s: floats = null
|
rot_s: floats = null
|
||||||
pos_s: floats = null
|
pos_s: floats = null
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
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 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
|
var tt = t
|
||||||
if c.dur > 0.0 { tt = t % c.dur }
|
if c.dur > 0.0 { tt = t % c.dur }
|
||||||
for ch in 0 .. c.n {
|
for ch in 0 .. c.n {
|
||||||
|
|
|
||||||
|
|
@ -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.
|
# 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 {
|
function scratch(anim_st: mut AnimState, n: int) -> void {
|
||||||
if anim_st.cap >= n { return }
|
if anim_st.cap >= n { return }
|
||||||
anim_st.rot_s = floats(n * 4)
|
anim_st.rot_s = floats(n * 4)
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,24 @@ function fishing_fact_record(fishing_st: mut FishingState) -> FishingFact {
|
||||||
fishing_st.fishing_fnext[0] += 1
|
fishing_st.fishing_fnext[0] += 1
|
||||||
return f
|
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
|
let f = new FishingFact
|
||||||
push(fishing_st.fishing_fpool, f)
|
push(fishing_st.fishing_fpool, f)
|
||||||
return 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
|
# 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) }
|
export function fishing_fact_records(fishing_st: FishingState) -> int { return len(fishing_st.fishing_fpool) }
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ export state FishingState {
|
||||||
fishing_run_next: float = 0.0
|
fishing_run_next: float = 0.0
|
||||||
fishing_dice: Rng = null
|
fishing_dice: Rng = null
|
||||||
fishing_fact_q: Queue<FishingFact> = fishing_fact_q__new()
|
fishing_fact_q: Queue<FishingFact> = fishing_fact_q__new()
|
||||||
fishing_fpool: []FishingFact = new []FishingFact # every fact record made, reused once no drain holds it (facts.ludic)
|
fishing_fpool: []FishingFact = fishing_fpool_new() # every fact record made, reused once no drain holds it (facts.ludic)
|
||||||
fishing_ffree: []FishingFact = new []FishingFact
|
fishing_ffree: []FishingFact = fishing_ffree_new()
|
||||||
fishing_fnext: []int = words(1)
|
fishing_fnext: []int = words(1)
|
||||||
fishing_n: int = 0 # the record: caught, the biggest (cm), a legend landed
|
fishing_n: int = 0 # the record: caught, the biggest (cm), a legend landed
|
||||||
fishing_big: int = 0
|
fishing_big: int = 0
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,6 @@ program FishingTest {
|
||||||
facts(fishing_st)
|
facts(fishing_st)
|
||||||
}
|
}
|
||||||
print(`fishing: 50 fish, {fishing_fact_records(fishing_st)} fact records made`)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue