parallel grid deposit

This commit is contained in:
Simon Gardling
2021-03-31 15:48:58 -04:00
parent b5bc14faa3
commit 99960c9523
3 changed files with 43 additions and 9 deletions

View File

@@ -88,6 +88,8 @@ pub struct Grid {
// Scratch space for the blur operation.
buf: Vec<f32>,
blur: Blur,
pub i: Vec<usize>,
}
impl Clone for Grid {
@@ -99,13 +101,14 @@ impl Clone for Grid {
data: self.data.clone(),
buf: self.buf.clone(),
blur: self.blur.clone(),
i: self.i.clone(),
}
}
}
impl Grid {
// Create a new grid filled with random floats in the [0.0..1.0) range.
pub fn new<R: Rng + ?Sized>(width: usize, height: usize, rng: &mut R) -> Self {
pub fn new<R: Rng + ?Sized>(width: usize, height: usize, rng: &mut R, i: Vec<usize>) -> Self {
if !width.is_power_of_two() || !height.is_power_of_two() {
panic!("Grid dimensions must be a power of two.");
}
@@ -119,6 +122,7 @@ impl Grid {
config: PopulationConfig::new(rng),
buf: vec![0.0; width * height],
blur: Blur::new(width),
i,
}
}