55 bins_count, |
55 bins_count, |
56 index: PotSize::square(GRID_BIN_SIZE).unwrap().to_grid_index(), |
56 index: PotSize::square(GRID_BIN_SIZE).unwrap().to_grid_index(), |
57 } |
57 } |
58 } |
58 } |
59 |
59 |
60 fn linear_bin_index(&self, index: Point) -> usize { |
60 fn linear_bin_index(&self, index: Point) -> u32 { |
61 self.bins_count |
61 self.bins_count |
62 .linear_index(index.x as usize, index.y as usize) |
62 .linear_index(index.x as u32, index.y as u32) |
63 } |
63 } |
64 |
64 |
65 fn bin_index(&self, position: &FPPoint) -> Point { |
65 fn bin_index(&self, position: &FPPoint) -> Point { |
66 self.index.map(Point::from_fppoint(position)) |
66 self.index.map(Point::from_fppoint(position)) |
67 } |
67 } |
68 |
68 |
69 fn get_bin(&mut self, index: Point) -> &mut GridBin { |
69 fn get_bin(&mut self, index: Point) -> &mut GridBin { |
70 let index = self.linear_bin_index(index); |
70 let index = self.linear_bin_index(index); |
71 &mut self.bins[index] |
71 &mut self.bins[index as usize] |
72 } |
72 } |
73 |
73 |
74 fn try_get_bin(&mut self, index: Point) -> Option<&mut GridBin> { |
74 fn try_get_bin(&mut self, index: Point) -> Option<&mut GridBin> { |
75 let index = self.linear_bin_index(index); |
75 let index = self.linear_bin_index(index); |
76 self.bins.get_mut(index) |
76 self.bins.get_mut(index as usize) |
77 } |
77 } |
78 |
78 |
79 fn lookup_bin(&mut self, position: &FPPoint) -> &mut GridBin { |
79 fn lookup_bin(&mut self, position: &FPPoint) -> &mut GridBin { |
80 self.get_bin(self.bin_index(position)) |
80 self.get_bin(self.bin_index(position)) |
81 } |
81 } |