diff options
Diffstat (limited to 'src/sim')
| -rw-r--r-- | src/sim/lib/components.rs | 2 | ||||
| -rw-r--r-- | src/sim/sim_manager/mod.rs | 5 | ||||
| -rw-r--r-- | src/sim/sim_manager/utils.rs | 8 |
3 files changed, 7 insertions, 8 deletions
diff --git a/src/sim/lib/components.rs b/src/sim/lib/components.rs index f1c34ac..d43a567 100644 --- a/src/sim/lib/components.rs +++ b/src/sim/lib/components.rs @@ -111,7 +111,7 @@ pub fn compute_components(cells: &[Cell], w: i32, h: i32) -> Vec<PositionedCompo as usize] = old_cell.cell; } - let pc_centre = ((c.bounds[0] + c.bounds[1] + IVec2::ONE).as_vec2() / 2.0); + let pc_centre = (c.bounds[0] + c.bounds[1] + IVec2::ONE).as_vec2() / 2.0 ; let adjusted_pc_centre = pc_centre - (Vec2::new(w as f32, h as f32) / 2.0); let pc = PositionedComponent { position: adjusted_pc_centre, diff --git a/src/sim/sim_manager/mod.rs b/src/sim/sim_manager/mod.rs index ca68831..bbfd05e 100644 --- a/src/sim/sim_manager/mod.rs +++ b/src/sim/sim_manager/mod.rs @@ -174,13 +174,12 @@ impl SimManager { } } - if input_manager.pressed(Input::Action2) { - if let Some(entity_id) = written_entities_scope + if input_manager.pressed(Input::Action2) + && let Some(entity_id) = written_entities_scope .get_entity_id_at_position(input_manager.world_mouse_pos.round().as_ivec2()) { self.atomize_entity(entity_id); } - } // TEST ATOMIZATION diff --git a/src/sim/sim_manager/utils.rs b/src/sim/sim_manager/utils.rs index 45960bf..5bb7573 100644 --- a/src/sim/sim_manager/utils.rs +++ b/src/sim/sim_manager/utils.rs @@ -159,7 +159,7 @@ pub fn read_back_entities_from_world( let ec = entity.data.cells.as_mut().unwrap(); // first check if the entity has been partitioned let components = compute_components(&ec.cells, ec.size.x, ec.size.y); - if components.len() == 0 { + if components.is_empty() { sim.destroy_entity(entity_id); } else if components.len() == 1 { // the entity's cells were changed, but not partitioned @@ -193,9 +193,9 @@ pub fn read_back_entities_from_world( .get(entity.data.rb_h.unwrap()) // correctness -- not correct! because we don't have pos without rb .unwrap(); - let old_pose = old_rb.position().clone(); - let old_linvel = old_rb.linvel().clone(); - let old_angvel = old_rb.angvel().clone(); + let old_pose = *old_rb.position(); + let old_linvel = old_rb.linvel(); + let old_angvel = old_rb.angvel(); sim.destroy_entity(entity_id); |
