macro_rules! declare_build {
($self:ident, $body:tt) => {
pub fn build($self) -> Vec<f32> $body
};
}
pub(crate) use declare_build;
macro_rules! declare_into_iter {
($arch:ident, $self:ident, $body:tt) => {
#[allow(clippy::should_implement_trait)]
pub fn into_iter($self) -> impl Iterator<Item = crate::simd::Simd<f32, $arch>> $body
};
}
pub(crate) use declare_into_iter;
macro_rules! declare_fill {
($self:ident, $result:ident, $body:tt) => {
#[inline(always)]
pub fn fill($self, $result: &mut [f32]) $body
};
}
pub(crate) use declare_fill;
macro_rules! params_grid_seed_builder {
($name:ident, [ $($full_generics:tt)* ], [ $($short_generics:tt)* ]) => {
impl< $($full_generics)* > $name< $($short_generics)* > {
pub fn seed_with_grid(mut self, grid_seed: i64, noise_seed: i64) -> Self {
let grid_seed = Random::mix_u64(grid_seed as u64);
let noise_seed = Random::mix_u64(noise_seed as u64 ^ 0xD5E7B3C94F8A1E6B);
self.noise_config.seed = Random::mix_u64_pair(grid_seed, noise_seed);
self
}
}
};
}
pub(crate) use params_grid_seed_builder;
macro_rules! params_noise_builder {
($name:ident, [ $($full_generics:tt)* ], [ $($short_generics:tt)* ]) => {
impl< $($full_generics)* > $name< $($short_generics)* > {
pub fn seed(mut self, seed: i64) -> Self {
self.noise_config.seed = Random::mix_u64(seed as u64 ^ 0xD5E7B3C94F8A1E6B);
self
}
pub fn amplitude(mut self, amplitude: f32) -> Self {
self.noise_config.amplitude = amplitude;
self
}
pub fn magnification(mut self, magnification: f32) -> Self {
self.noise_config.magnification = magnification;
self
}
pub fn normalization(mut self, normalization: bool) -> Self {
self.noise_config.normalization = normalization;
self
}
pub fn initialize(mut self, initialize: bool) -> Self {
self.noise_config.initialize = initialize;
self
}
pub fn finalize(mut self, finalize: bool) -> Self {
self.noise_config.finalize = finalize;
self
}
}
};
}
pub(crate) use params_noise_builder;
macro_rules! params_lacunarity_builder {
($name:ident, [ $($full_generics:tt)* ], [ $($short_generics:tt)* ]) => {
impl< $($full_generics)* > $name< $($short_generics)* > {
pub fn octaves(mut self, octaves: usize) -> Self {
self.noise_config.octaves = octaves;
self
}
pub fn frequency(mut self, frequency: f32) -> Self {
self.noise_config.frequency = frequency;
self
}
pub fn lacunarity(mut self, lacunarity: f32) -> Self {
self.noise_config.lacunarity = lacunarity;
self
}
pub fn persistence(mut self, persistence: f32) -> Self {
self.noise_config.persistence = persistence;
self
}
}
};
}
pub(crate) use params_lacunarity_builder;
macro_rules! params_noise_scaling_2d {
($name:ident, [ $($full_generics:tt)* ], [ $($short_generics:tt)* ]) => {
impl< $($full_generics)* > $name< $($short_generics)* > {
pub fn scaling(mut self, x_scaling: f32, y_scaling: f32) -> Self {
self.noise_config.scaling = [x_scaling, y_scaling];
self
}
}
};
}
pub(crate) use params_noise_scaling_2d;
macro_rules! params_noise_scaling_3d {
($name:ident, [ $($full_generics:tt)* ], [ $($short_generics:tt)* ]) => {
impl< $($full_generics)* > $name< $($short_generics)* > {
pub fn scaling(mut self, x_scaling: f32, y_scaling: f32, z_scaling: f32) -> Self {
self.noise_config.scaling = [x_scaling, y_scaling, z_scaling];
self
}
}
};
}
pub(crate) use params_noise_scaling_3d;
macro_rules! params_combiner_builder {
($name:ident, [ $($full_generics:tt)* ], [ $($short_generics:tt)* ]) => {
impl< $($full_generics)* > $name< $($short_generics)* > {
pub fn combiner_config(mut self, config: C::Config) -> Self {
self.combiner_config = config;
self
}
}
};
}
pub(crate) use params_combiner_builder;
macro_rules! params_ridged_builder {
($name:ident, [ $($full_generics:tt)* ], [ $($short_generics:tt)* ]) => {
impl< $($full_generics)* > $name< $($short_generics)* > {
pub fn gain(mut self, gain: f32) -> Self {
self.combiner_config.gain = gain;
self
}
}
};
}
pub(crate) use params_ridged_builder;
macro_rules! params_ping_pong_builder {
($name:ident, [ $($full_generics:tt)* ], [ $($short_generics:tt)* ]) => {
impl< $($full_generics)* > $name< $($short_generics)* > {
pub fn strength(mut self, strength: f32) -> Self {
self.combiner_config.strength = strength;
self
}
}
};
}
pub(crate) use params_ping_pong_builder;
macro_rules! params_terrace_builder {
($name:ident, [ $($full_generics:tt)* ], [ $($short_generics:tt)* ]) => {
impl< $($full_generics)* > $name< $($short_generics)* > {
pub fn steps(mut self, steps: f32) -> Self {
self.combiner_config.steps = steps;
self.combiner_config.step_size = 1.0 / steps;
self
}
}
};
}
pub(crate) use params_terrace_builder;
macro_rules! params_hybrid_multi_builder {
($name:ident, [ $($full_generics:tt)* ], [ $($short_generics:tt)* ]) => {
impl< $($full_generics)* > $name< $($short_generics)* > {
pub fn gain(mut self, gain: f32) -> Self {
self.combiner_config.gain = gain;
self
}
pub fn offset(mut self, offset: f32) -> Self {
self.combiner_config.offset = offset;
self
}
}
};
}
pub(crate) use params_hybrid_multi_builder;