diff options
| -rw-r--r-- | src/content/entities/entity_grenade.rs | 2 | ||||
| -rw-r--r-- | src/content/materials/liquid.rs | 2 | ||||
| -rw-r--r-- | src/renderer/mod.rs | 3 | ||||
| -rw-r--r-- | src/sim/cell/cell.rs | 6 | ||||
| -rw-r--r-- | src/sim/entity/mod.rs | 7 | ||||
| -rw-r--r-- | src/sim/lib/force.rs | 2 | ||||
| -rw-r--r-- | src/sim/sim_manager/mod.rs | 7 |
7 files changed, 13 insertions, 16 deletions
diff --git a/src/content/entities/entity_grenade.rs b/src/content/entities/entity_grenade.rs index ab7aaa4..c13c239 100644 --- a/src/content/entities/entity_grenade.rs +++ b/src/content/entities/entity_grenade.rs @@ -20,7 +20,7 @@ impl EntityBehaviour for GrenadeEntityBehaviour { update_ctx: &mut EntityUpdateCtx, ctx: &mut SimCtx, delta_time: f32, - ) -> () { + ) { self.fuse -= delta_time; if self.fuse <= 0.0 { apply_explosion( diff --git a/src/content/materials/liquid.rs b/src/content/materials/liquid.rs index 6c3bdcd..23ba0fe 100644 --- a/src/content/materials/liquid.rs +++ b/src/content/materials/liquid.rs @@ -57,7 +57,7 @@ pub fn sim_update(ctx: &mut UpdateCtx) -> PostUpdateAction { } } - return PostUpdateAction::Settle; + PostUpdateAction::Settle // we didn't find a hole, so just move "randomly" on the same surface // TODO when to settle? diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index c2e541b..29bd779 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -13,7 +13,6 @@ use crate::{ renderer::ui::draw_egui, sim::{ cell_manager::manager::CellManager, - entity::Entity, rb_manager::debug_render::DebugVertex, sim_manager::{SimCtx, SimManager}, }, @@ -747,7 +746,7 @@ impl RendererState { for (id, slot) in &self.renderer_rb_entities { if let Some(entity) = sim.entities.get(id) && let Some(cells) = &entity.data.cells - && let Some((pos, (cos, sin))) = entity.data.transform(&mut SimCtx { + && let Some((pos, (cos, sin))) = entity.data.transform(&SimCtx { cell_manager: &mut sim.cell_manager, particle_manager: &mut sim.particle_manager, rb_manager: &mut sim.rb_manager, diff --git a/src/sim/cell/cell.rs b/src/sim/cell/cell.rs index 6c6e704..be2cfad 100644 --- a/src/sim/cell/cell.rs +++ b/src/sim/cell/cell.rs @@ -22,11 +22,11 @@ impl Cell { } #[inline] pub fn match_parity(&mut self, seqno: u64) { - let parity = seqno % 2 != 0; + let parity = !seqno.is_multiple_of(2); if parity { self.flags |= Self::FLAG_PARITY; } else { - self.flags = self.flags & !Self::FLAG_PARITY + self.flags &= !Self::FLAG_PARITY } } @@ -39,7 +39,7 @@ impl Cell { if rb { self.flags |= Self::FLAG_ENTITY } else { - self.flags = self.flags & !Self::FLAG_ENTITY + self.flags &= !Self::FLAG_ENTITY } } diff --git a/src/sim/entity/mod.rs b/src/sim/entity/mod.rs index 4a79bf4..d8a03e0 100644 --- a/src/sim/entity/mod.rs +++ b/src/sim/entity/mod.rs @@ -48,14 +48,14 @@ pub trait EntityBehaviour { _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, - ) -> () { + ) { } } @@ -131,7 +131,7 @@ impl<'a> EntityUpdateCtx<'a> { impl EntityData { pub fn transform(&self, ctx: &SimCtx) -> Option<(Vec2, (f32, f32))> { self.rb_h - .map(|rb_h| { + .and_then(|rb_h| { ctx.rb_manager .physics_manager .rigid_body_set @@ -143,7 +143,6 @@ impl EntityData { ) }) }) - .flatten() } } diff --git a/src/sim/lib/force.rs b/src/sim/lib/force.rs index 39b7904..db8e076 100644 --- a/src/sim/lib/force.rs +++ b/src/sim/lib/force.rs @@ -20,7 +20,7 @@ pub fn apply_explosion( } let dir = (pos - centre) / d; let falloff = 1.0 - (d / radius as f32); - return (force_offset + dir) * force_multiplier * random_range(0.5..1.5) * falloff; + (force_offset + dir) * force_multiplier * random_range(0.5..1.5) * falloff }; // cell grid diff --git a/src/sim/sim_manager/mod.rs b/src/sim/sim_manager/mod.rs index 8f47761..805d152 100644 --- a/src/sim/sim_manager/mod.rs +++ b/src/sim/sim_manager/mod.rs @@ -164,13 +164,12 @@ impl SimManager { rb_manager: &mut self.rb_manager, particle_manager: &mut self.particle_manager, }; - if let Some(entity) = entity { - if let Some(result) = entity.physics_update(&mut ctx, delta_time) { + if let Some(entity) = entity + && let Some(result) = entity.physics_update(&mut ctx, delta_time) { for d in result.deferred_destructions { self.destroy_entity(d); } } - } } // before we move the rigidbodies, upsert the current terrain state @@ -197,7 +196,7 @@ impl SimManager { .tick(&mut self.cell_manager, delta_time); } - pub fn update(&mut self, config: &Config, delta_time: f32) -> () { + pub fn update(&mut self, config: &Config, delta_time: f32) { let entity_ids: Vec<u32> = self.entities.keys().cloned().collect(); for id in entity_ids { if let Some(entity) = self.entities.get_mut(&id) { |
