ludic/packages/ludic.physics/fact_pool.ludic

21 lines
747 B
Text

# ludic.physics/fact_pool.ludic - the facts' records made at the start (PHYSFACTS of them) with a free list
# of room for all, so a frame holding a new peak of facts makes nothing until that many are held
const PH_FACTS: int = 64
function ph_fpool_new() -> []PhysFact {
let l = new []PhysFact
for i in 0 .. PH_FACTS { push(l, new PhysFact) }
return l
}
function ph_ffree_new() -> []PhysFact {
let l = ph_fpool_new()
List.clear(l)
return l
}
# past them: a record for the new peak, kept in the pool for good
@alloc_ok("a new peak of facts held at once, past the 64 made at the start; kept and reused")
function ph_fact_more(physics_st: mut PhysicsState) -> PhysFact {
let f = new PhysFact
push(physics_st.ph_fpool, f)
return f
}