diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 640e5b9..586b456 100644 --- a/src/main.rs +++ b/src/main.rs @@ -120,10 +120,6 @@ impl App { && let Some(rbsm) = &mut self.rb_sim_manager { self.input.trigger_test_2 = false; - rbsm.test_add_collider_from_chunk( - Vec2::new((cx * CHUNK_SIZE) as f32, (cy * CHUNK_SIZE) as f32), - &world.chunks[*world.chunk_position_to_chunk_idx.get(&(cx, cy)).unwrap()], - ); } // --TEST DRAWING-- @@ -202,7 +198,22 @@ impl App { // may be called multiple times if the physics time is behind // physics_delta_time is statically 1/PHYSICS_FPS fn physics_update(&mut self, physics_delta_time: f32) { + // before we move the rigidbodies, upsert the current terrain state + // TODO use the chunk sleeping, and make this range dynamic if let Some(physics_manager) = &mut self.rb_sim_manager { + if let Some(world) = &self.world { + for cx in -5..5 { + for cy in -5..5 { + if let Some(chunk) = world + .chunk_position_to_chunk_idx + .get(&(cx, cy)) + .map(|&idx| &world.chunks[idx]) + { + physics_manager.upsert_chunk_collider(cx, cy, chunk); + } + } + } + } physics_manager.rb_tick(physics_delta_time); } } |
