noise_functions/modifiers/
ceil.rs

1#[cfg(feature = "nightly-simd")]
2use core::simd::{LaneCount, Simd, SupportedLaneCount};
3
4use crate::{math::ceil, Noise, Sample};
5
6/// Computes the smallest integer greater than or equal to self.
7pub struct Ceil<A> {
8    pub noise: A,
9}
10
11impl<N> Noise for Ceil<N> {}
12
13impl<const DIM: usize, N> Sample<DIM> for Ceil<N>
14where
15    N: Sample<DIM>,
16{
17    #[inline]
18    fn sample_with_seed(&self, point: [f32; DIM], seed: i32) -> f32 {
19        ceil(self.noise.sample_with_seed(point, seed))
20    }
21}
22
23#[cfg(feature = "nightly-simd")]
24impl<const DIM: usize, const LANES: usize, N> Sample<DIM, Simd<f32, LANES>> for Ceil<N>
25where
26    N: Sample<DIM, Simd<f32, LANES>>,
27    LaneCount<LANES>: SupportedLaneCount,
28{
29    #[inline]
30    fn sample_with_seed(&self, point: Simd<f32, LANES>, seed: i32) -> f32 {
31        ceil(self.noise.sample_with_seed(point, seed))
32    }
33}