diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-23 23:35:57 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-23 23:35:57 -0700 |
| commit | 5bedb15c61ad26824dbe6053f0b66b11b6ad5047 (patch) | |
| tree | 97c91f976a9ccaf81c3fb91d40f18752a81d7685 /src/sim/rb_manager | |
| parent | 245d8eb77d7b92a50a48d4b953e5a8e0d789307c (diff) | |
fix scaling
Diffstat (limited to 'src/sim/rb_manager')
| -rw-r--r-- | src/sim/rb_manager/debug_render.rs | 6 | ||||
| -rw-r--r-- | src/sim/rb_manager/mod.rs | 13 |
2 files changed, 7 insertions, 12 deletions
diff --git a/src/sim/rb_manager/debug_render.rs b/src/sim/rb_manager/debug_render.rs index 532d9a6..77eba7a 100644 --- a/src/sim/rb_manager/debug_render.rs +++ b/src/sim/rb_manager/debug_render.rs @@ -1,7 +1,5 @@ use rapier2d::pipeline::{DebugColor, DebugRenderBackend, DebugRenderObject}; -use crate::config::CELLS_TO_METRES; - #[repr(C)] #[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] pub struct DebugVertex { @@ -24,11 +22,11 @@ impl DebugRenderBackend for DebugLineBuffer { ) { let color = hsla_to_linear_rgba(color); self.vertices.push(DebugVertex { - position: [a.x * CELLS_TO_METRES, a.y * CELLS_TO_METRES], + position: [a.x, a.y], color, }); self.vertices.push(DebugVertex { - position: [b.x * CELLS_TO_METRES, b.y * CELLS_TO_METRES], + position: [b.x, b.y], color, }); } diff --git a/src/sim/rb_manager/mod.rs b/src/sim/rb_manager/mod.rs index 1a2abbf..36893b5 100644 --- a/src/sim/rb_manager/mod.rs +++ b/src/sim/rb_manager/mod.rs @@ -29,7 +29,7 @@ pub struct PhysicsManager { impl PhysicsManager { pub fn new() -> Self { let mut world = PhysicsWorld::new(); - let gravity = vec2(0.0, 9.81); + let gravity = vec2(0.0, 9.81 * CELLS_TO_METRES); world.gravity = gravity; world.integration_parameters = IntegrationParameters { // 20 pixels <-> 1 meter @@ -95,9 +95,7 @@ impl RbManager { continue; } for i in 0..p { - vertices.push( - (poly[i as usize] - (marchable.size().as_vec2() - 1.0) / 2.0) / CELLS_TO_METRES, - ); + vertices.push(poly[i as usize] - (marchable.size().as_vec2() - 1.0) / 2.0); indices.push([v + i, v + (i + 1) % p]); } } @@ -129,12 +127,11 @@ impl RbManager { pub fn upsert_chunk_collider(&mut self, cx: i32, cy: i32, chunk: &Chunk) { puffin::profile_function!(); - let collider = RbManager::polyline_collider_from_marchable(chunk, Some(20)).translation( - vec2( + let collider = + RbManager::polyline_collider_from_marchable(chunk, Some(20)).translation(vec2( (cx as f32 + 0.5) * CHUNK_SIZE as f32, (cy as f32 + 0.5) * CHUNK_SIZE as f32, - ) / CELLS_TO_METRES, - ); + )); if let Some(handle) = self.chunk_colliders.remove(&(cx, cy)) { self.physics_manager.world.remove_collider(handle); |
