cleanup Buf struct

This commit is contained in:
Simon Gardling 2025-03-27 14:35:54 -04:00
parent 75fab93907
commit d1f515b17d
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
2 changed files with 9 additions and 5 deletions

View File

@ -1,13 +1,17 @@
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Buf { pub struct Buf {
pub width: usize, width: usize,
pub height: usize, height: usize,
pub buf: Vec<f32>, pub buf: Vec<f32>,
} }
impl Buf { impl Buf {
pub const fn new(width: usize, height: usize, buf: Vec<f32>) -> Self { pub fn new(width: usize, height: usize) -> Self {
Buf { width, height, buf } Buf {
width,
height,
buf: vec![0.0; height * width],
}
} }
// Truncate x and y and return a corresponding index into the data slice. // Truncate x and y and return a corresponding index into the data slice.

View File

@ -71,7 +71,7 @@ impl Grid {
height, height,
data, data,
config: PopulationConfig::new(rng), config: PopulationConfig::new(rng),
buf: Buf::new(width, height, vec![0.0; width * height]), buf: Buf::new(width, height),
blur: Blur::new(width), blur: Blur::new(width),
agents, agents,
} }