summaryrefslogtreecommitdiff
path: root/src/sim/entity/mod.rs
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2026-08-23 00:29:26 -0700
committerKai Stevenson <kai@kaistevenson.com>2026-08-23 00:29:26 -0700
commita0ff76837ca7ed6bd90cedcfee3832c1d9ad2287 (patch)
tree413e574f0b5f41fafc6ced91d3d7bb2d0462237e /src/sim/entity/mod.rs
parent4380928861c2a43f0d0b9793b9e501c720cf5803 (diff)
steel and collider mass
Diffstat (limited to 'src/sim/entity/mod.rs')
-rw-r--r--src/sim/entity/mod.rs24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/sim/entity/mod.rs b/src/sim/entity/mod.rs
index 555d2c6..0f4ae3c 100644
--- a/src/sim/entity/mod.rs
+++ b/src/sim/entity/mod.rs
@@ -5,7 +5,7 @@ use rapier2d::{
};
use crate::{
- config::CELLS_TO_METRES,
+ config::{CELLS_TO_METRES, MASS_SCALING},
sim::{
cell::{cell::Cell, materials::MaterialId},
lib::marching_squares::Marchable,
@@ -48,16 +48,16 @@ impl Marchable for EntityCells {
pub trait EntityBehaviour {
fn update(
&mut self,
- update_ctx: &mut EntityUpdateCtx,
- ctx: &mut SimCtx,
- delta_time: f32,
+ _update_ctx: &mut EntityUpdateCtx,
+ _ctx: &mut SimCtx,
+ _delta_time: f32,
) -> () {
}
fn physics_update(
&mut self,
- update_ctx: &mut EntityUpdateCtx,
- ctx: &mut SimCtx,
- delta_time: f32,
+ _update_ctx: &mut EntityUpdateCtx,
+ _ctx: &mut SimCtx,
+ _delta_time: f32,
) -> () {
}
}
@@ -79,7 +79,15 @@ impl EntityDef {
.translation(position / CELLS_TO_METRES)
.build();
- let collider = RbManager::convex_hull_collider_from_marchable(&cells, None).build();
+ let mass = cells
+ .cells
+ .iter()
+ .fold(0, |acc, cur| acc + cur.material.def().density) as f32
+ * MASS_SCALING;
+
+ let collider = RbManager::convex_hull_collider_from_marchable(&cells, None)
+ .mass(mass)
+ .build();
EntityDef {
rb: Some(rb),