Struct worley_noise::WorleyNoise
source · pub struct WorleyNoise { /* private fields */ }
Expand description
The base noise struct.
Uses permutation arrays for efficiency. Use the WorleyNoise::permutate
function to randomize it / adjust the size.
Caches already sampled values.
Sampling individual points is relatively slow due to the internal locks.
Use the WorleyNoise::values
function if sampling multiple points instead as it’s concurrent.
Implementations§
source§impl WorleyNoise
impl WorleyNoise
pub const DEFAULT_RADIUS: u16 = 1u16
pub const DEFAULT_PERMUTATION_BITS: usize = 10usize
pub const DEFAULT_DENSITY: f64 = 3f64
pub const DEFAULT_CACHE_CAPACITY: usize = 2_500usize
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new noise struct with random permutation arrays.
Uses the default cache capacity of 2500.
sourcepub fn with_cache_capacity(capacity: usize) -> Self
pub fn with_cache_capacity(capacity: usize) -> Self
Initializes the struct with the specified cache capacity.
sourcepub fn permutate(&mut self, permutation_table_bit_length: usize)
pub fn permutate(&mut self, permutation_table_bit_length: usize)
Calls WorleyNoise::permutate_seeded
with a random seed.
sourcepub fn permutate_seeded(
&mut self,
permutation_table_bit_length: usize,
seed: u128
)
pub fn permutate_seeded(
&mut self,
permutation_table_bit_length: usize,
seed: u128
)
Randomizes the internal permutation arrays.
Generates permutation arrays with two to the power of permutation_table_bit_length
entries.
This operation is fairly slow.
sourcepub fn set_density(&mut self, density: f64)
pub fn set_density(&mut self, density: f64)
Sets the feature point density.
Might be slow since it precomputes a lot of stuff.
Default is 3.0.
sourcepub fn set_distance_function<F>(&mut self, function: F)where
F: Fn(f64, f64) -> f64 + Sync + 'static,
pub fn set_distance_function<F>(&mut self, function: F)where
F: Fn(f64, f64) -> f64 + Sync + 'static,
Sets the function to calculate the distance between feature points.
Default is the squared Euclidean distance.
sourcepub fn set_value_function<F>(&mut self, function: F)where
F: Fn(Vec<f64>) -> f64 + Sync + 'static,
pub fn set_value_function<F>(&mut self, function: F)where
F: Fn(Vec<f64>) -> f64 + Sync + 'static,
Sets the function to pick the final value from the nearby feature points.
The values are in no particular order.
Default is the minimum value.
sourcepub fn set_radius(&mut self, radius: u16)
pub fn set_radius(&mut self, radius: u16)
Specifies how many adjacent cells should be included in the value calculation.
A higher radius reduces the amount of possible errors but slows down sampling of individual points.
Default is 1. That means it includes the feature points of the surrounding cells.