replace common index code
This commit is contained in:
@@ -78,11 +78,8 @@ impl Grid {
|
||||
}
|
||||
|
||||
// Truncate x and y and return a corresponding index into the data slice.
|
||||
fn index(&self, x: f32, y: f32) -> usize {
|
||||
// x/y can come in negative, hence we shift them by width/height.
|
||||
let i = (x + self.width as f32) as usize & (self.width - 1);
|
||||
let j = (y + self.height as f32) as usize & (self.height - 1);
|
||||
j * self.width + i
|
||||
const fn index(&self, x: f32, y: f32) -> usize {
|
||||
crate::util::index(self.width, self.height, x, y)
|
||||
}
|
||||
|
||||
// Add a value to the grid data at a given position.
|
||||
|
||||
Reference in New Issue
Block a user