61 fn lookup_bin(&mut self, position: &FPPoint) -> &mut GridBin { |
61 fn lookup_bin(&mut self, position: &FPPoint) -> &mut GridBin { |
62 let index = self.bin_index(position); |
62 let index = self.bin_index(position); |
63 &mut self.bins[index.x as usize * self.bins_count.width + index.y as usize] |
63 &mut self.bins[index.x as usize * self.bins_count.width + index.y as usize] |
64 } |
64 } |
65 |
65 |
66 pub fn insert_static(&mut self, gear_id: GearId, position: &FPPoint, bounds: &CircleBounds) { |
66 pub fn insert_static(&mut self, gear_id: GearId, bounds: &CircleBounds) { |
67 self.lookup_bin(position).static_entries.push(*bounds) |
67 self.lookup_bin(&bounds.center).static_entries.push(*bounds) |
68 } |
68 } |
69 |
69 |
70 pub fn insert_dynamic(&mut self, gear_id: GearId, position: &FPPoint, bounds: &CircleBounds) { |
70 pub fn insert_dynamic(&mut self, gear_id: GearId, bounds: &CircleBounds) { |
71 self.lookup_bin(position).dynamic_entries.push(*bounds) |
71 self.lookup_bin(&bounds.center).dynamic_entries.push(*bounds) |
72 } |
72 } |
73 |
73 |
74 pub fn check_collisions(&self, collisions: &mut DetectedCollisions) { |
74 pub fn check_collisions(&self, collisions: &mut DetectedCollisions) { |
75 for bin in &self.bins { |
75 for bin in &self.bins { |
76 for bounds in &bin.dynamic_entries { |
76 for bounds in &bin.dynamic_entries { |