noise_functions/modifiers/
max.rs1#[cfg(feature = "nightly-simd")]
2use core::simd::{LaneCount, Simd, SupportedLaneCount};
3
4use crate::{math::max, Noise, Sample};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8pub struct Max<A, B> {
9 pub lhs: A,
10 pub rhs: B,
11}
12
13impl<A, B> Noise for Max<A, B> {}
14
15impl<const DIM: usize, A, B> Sample<DIM> for Max<A, B>
16where
17 A: Sample<DIM>,
18 B: Sample<DIM>,
19{
20 #[inline]
21 fn sample_with_seed(&self, point: [f32; DIM], seed: i32) -> f32 {
22 max(self.lhs.sample_with_seed(point, seed), self.rhs.sample_with_seed(point, seed))
23 }
24}
25
26#[cfg(feature = "nightly-simd")]
27impl<const DIM: usize, const LANES: usize, A, B> Sample<DIM, Simd<f32, LANES>> for Max<A, B>
28where
29 A: Sample<DIM, Simd<f32, LANES>>,
30 B: Sample<DIM, Simd<f32, LANES>>,
31 LaneCount<LANES>: SupportedLaneCount,
32{
33 #[inline]
34 fn sample_with_seed(&self, point: Simd<f32, LANES>, seed: i32) -> f32 {
35 max(self.lhs.sample_with_seed(point, seed), self.rhs.sample_with_seed(point, seed))
36 }
37}