noise_functions/modifiers/
seeded.rs

1use crate::{Noise, Sample};
2
3/// Wraps a noise with a seed.
4///
5/// This structs' [`Sample`] implementation will call [`sample_with_seed`] on the base noise with `self.seed` overwriting the `seed` provided by the callee.
6///
7/// [`sample_with_seed`]: Sample::sample_with_seed
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub struct Seeded<Noise> {
10    pub noise: Noise,
11    pub seed: i32,
12}
13
14impl<N> Noise for Seeded<N> {}
15
16impl<const DIM: usize, Point, Noise> Sample<DIM, Point> for Seeded<Noise>
17where
18    Noise: Sample<DIM, Point>,
19{
20    fn sample_with_seed(&self, point: Point, _seed: i32) -> f32 {
21        self.noise.sample_with_seed(point, self.seed)
22    }
23}