| 247 | } |
| 248 | |
| 249 | pub fn step(&mut self, world_h: f64, dt: f32, collision_steps: u32) { |
| 250 | if let Some(&world) = self.worlds.get(world_h) { |
| 251 | unsafe { bj_world_step(world, dt, collision_steps.max(1)); } |
| 252 | // Drain contact events into our cache so they survive across queries. |
| 253 | let count = unsafe { bj_world_contact_count(world) }; |
| 254 | if count > 0 { |
| 255 | self.contact_cache.events.resize(count as usize, unsafe { std::mem::zeroed() }); |
| 256 | let drained = unsafe { |
| 257 | bj_world_pop_contacts(world, self.contact_cache.events.as_mut_ptr(), count) |
| 258 | }; |
| 259 | self.contact_cache.events.truncate(drained as usize); |
| 260 | } else { |
| 261 | self.contact_cache.events.clear(); |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | pub fn set_layer_collides(&self, world_h: f64, a: u32, b: u32, collides: bool) { |
| 267 | if let Some(&world) = self.worlds.get(world_h) { |