feat(ludic.physics): phys_own - a body owns a shape made for it alone, and phys_remove frees it with the body
A chunk's trunks and boulders put in and taken out made a new shape each time and freed none. The table is by the body's index, made once at the world's size. tests/reuse_test: 1000 owned bodies put and removed hold no more shapes and 32 bytes of heap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
404ee2ee3b
commit
5cd53d4024
6 changed files with 54 additions and 1 deletions
|
|
@ -36,11 +36,12 @@ export function phys_count(physics_st: PhysicsState) -> int {
|
|||
return jph_world_bodies(physics_st.ph_world)
|
||||
}
|
||||
|
||||
# gone from the world, for good: what a struck tent needs
|
||||
# gone from the world, for good: what a struck tent needs, and the shape it owned (owned.ludic) with it
|
||||
export function phys_remove(physics_st: mut PhysicsState, id: int) -> void {
|
||||
if physics_st.ph_world == null or id < 0 { return }
|
||||
phys_sink(physics_st, id)
|
||||
jph_body_remove(physics_st.ph_world, id)
|
||||
ph_own_free(physics_st, id)
|
||||
}
|
||||
|
||||
# where a body is, how it is turned and how fast it goes, into the caller's own record (a query asked
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue