summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/cell/cell.rs6
-rw-r--r--src/sim/entity/mod.rs7
-rw-r--r--src/sim/lib/force.rs2
-rw-r--r--src/sim/sim_manager/mod.rs7
4 files changed, 10 insertions, 12 deletions
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) {