--- a/rust/hwphysics/src/grid.rs Fri Mar 22 23:46:48 2019 +0300
+++ b/rust/hwphysics/src/grid.rs Sat Mar 23 01:07:23 2019 +0300
@@ -1,23 +1,15 @@
use crate::{
+ collision::{fppoint_round, CircleBounds, DetectedCollisions},
common::GearId,
- collision::{
- fppoint_round,
- CircleBounds,
- DetectedCollisions
- }
};
-use integral_geometry::{
- Point,
- Size,
- GridIndex
-};
use fpnum::FPPoint;
+use integral_geometry::{GridIndex, Point, Size};
struct GridBin {
refs: Vec<GearId>,
static_entries: Vec<CircleBounds>,
- dynamic_entries: Vec<CircleBounds>
+ dynamic_entries: Vec<CircleBounds>,
}
impl GridBin {
@@ -25,7 +17,7 @@
Self {
refs: vec![],
static_entries: vec![],
- dynamic_entries: vec![]
+ dynamic_entries: vec![],
}
}
}
@@ -36,21 +28,19 @@
bins: Vec<GridBin>,
space_size: Size,
bins_count: Size,
- index: GridIndex
+ index: GridIndex,
}
impl Grid {
pub fn new(size: Size) -> Self {
assert!(size.is_power_of_two());
- let bins_count =
- Size::new(size.width / GRID_BIN_SIZE,
- size.height / GRID_BIN_SIZE);
+ let bins_count = Size::new(size.width / GRID_BIN_SIZE, size.height / GRID_BIN_SIZE);
Self {
bins: (0..bins_count.area()).map(|_| GridBin::new()).collect(),
space_size: size,
bins_count,
- index: Size::square(GRID_BIN_SIZE).to_grid_index()
+ index: Size::square(GRID_BIN_SIZE).to_grid_index(),
}
}
@@ -68,7 +58,9 @@
}
pub fn insert_dynamic(&mut self, gear_id: GearId, bounds: &CircleBounds) {
- self.lookup_bin(&bounds.center).dynamic_entries.push(*bounds)
+ self.lookup_bin(&bounds.center)
+ .dynamic_entries
+ .push(*bounds)
}
pub fn check_collisions(&self, collisions: &mut DetectedCollisions) {
@@ -88,4 +80,4 @@
}
}
}
-}
\ No newline at end of file
+}