summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2026-08-18 08:55:24 -0700
committerKai Stevenson <kai@kaistevenson.com>2026-08-18 08:55:24 -0700
commit5877fbf3991b1f35696bf86d9e1b3da3ece01f42 (patch)
tree941eedd26173d200243b669dcf89150cfbd52246 /src/main.rs
parent4d4f28f4d0e93541e92277f44451aacdc23b8227 (diff)
automatic chunk marching
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs19
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);
}
}