diff --git a/packages/ludic.physics/shapes.ludic b/packages/ludic.physics/shapes.ludic index b8ed83bd..f0f42f34 100644 --- a/packages/ludic.physics/shapes.ludic +++ b/packages/ludic.physics/shapes.ludic @@ -6,12 +6,15 @@ export function phys_open(physics_st: mut PhysicsState, max_bodies: int, threads phys_close(physics_st) ph_buffers(physics_st) physics_st.ph_world = jph_world_new(max_bodies, threads) + physics_st.ph_gen += 1 physics_st.ph_acc = 0.0 physics_st.ph_steps = 0 return physics_st.ph_world != null } export function phys_is_open(physics_st: PhysicsState) -> bool { return physics_st.ph_world != null } +# which world this is: a body, shape or walker id kept from an older one means nothing now +export function phys_generation(physics_st: PhysicsState) -> int { return physics_st.ph_gen } # everything let go: the world, every body in it and every shape (a world swap, a quit) export function phys_close(physics_st: mut PhysicsState) -> void { diff --git a/packages/ludic.physics/state.ludic b/packages/ludic.physics/state.ludic index 9ec38552..3ee35b70 100644 --- a/packages/ludic.physics/state.ludic +++ b/packages/ludic.physics/state.ludic @@ -42,6 +42,7 @@ export state PhysicsState { ph_max_steps: int = 4 # a slow frame catches up this far and no further ph_acc: float = 0.0 ph_steps: int = 0 + ph_gen: int = 0 # how many worlds have been opened: an id from an older one is stale ph_hard: float = 2.0 # metres a second: a contact under this is not a fact ph_floats: []int = null # buoyant bodies' ids ph_float_k: []float = null # and theirs: buoyancy, linear drag, angular drag, wet