diff --git a/examples/perlin.rs b/examples/perlin.rs index fb6167d2..ff9b61c7 100644 --- a/examples/perlin.rs +++ b/examples/perlin.rs @@ -13,7 +13,7 @@ mod utils; fn main() { let hasher = PermutationTable::new(0); utils::write_example_to_file( - &PlaneMapBuilder::new_fn(|point| perlin_2d(point, &hasher)) + &PlaneMapBuilder::new_fn(|point| perlin_2d(point.into(), &hasher)) .set_size(1024, 1024) .set_x_bounds(-5.0, 5.0) .set_y_bounds(-5.0, 5.0) @@ -22,7 +22,7 @@ fn main() { ); utils::write_example_to_file( - &PlaneMapBuilder::new_fn(|point| perlin_3d(point, &hasher)) + &PlaneMapBuilder::new_fn(|point| perlin_3d(point.into(), &hasher)) .set_size(1024, 1024) .set_x_bounds(-5.0, 5.0) .set_y_bounds(-5.0, 5.0) @@ -31,7 +31,7 @@ fn main() { ); utils::write_example_to_file( - &PlaneMapBuilder::new_fn(|point| perlin_4d(point, &hasher)) + &PlaneMapBuilder::new_fn(|point| perlin_4d(point.into(), &hasher)) .set_size(1024, 1024) .set_x_bounds(-5.0, 5.0) .set_y_bounds(-5.0, 5.0) diff --git a/src/core/perlin.rs b/src/core/perlin.rs index a0e4a8f8..e6c0a5b1 100644 --- a/src/core/perlin.rs +++ b/src/core/perlin.rs @@ -50,7 +50,7 @@ where } #[inline(always)] -pub fn perlin_2d(point: [f64; 2], hasher: &NH) -> f64 +pub fn perlin_2d(point: Vector2, hasher: &NH) -> f64 where NH: NoiseHasher + ?Sized, { @@ -61,8 +61,6 @@ where // 1/(sqrt(N)/2), N=2 -> 2/sqrt(2) const SCALE_FACTOR: f64 = 2.0 / f64::consts::SQRT_2; - let point = Vector2::from(point); - let corner = point.floor_to_isize(); let distance = point - corner.numcast().unwrap(); @@ -101,7 +99,7 @@ where } #[inline(always)] -pub fn perlin_3d(point: [f64; 3], hasher: &NH) -> f64 +pub fn perlin_3d(point: Vector3, hasher: &NH) -> f64 where NH: NoiseHasher + ?Sized, { @@ -115,7 +113,6 @@ where // 2/sqrt(3) = 1.1547005383792515290182975610039149112952035025402537520372046529 const SCALE_FACTOR: f64 = 1.154_700_538_379_251_5; - let point = Vector3::from(point); let corner = point.floor_to_isize(); let distance = point - corner.numcast().unwrap(); @@ -174,7 +171,7 @@ where } #[inline(always)] -pub fn perlin_4d(point: [f64; 4], hasher: &NH) -> f64 +pub fn perlin_4d(point: Vector4, hasher: &NH) -> f64 where NH: NoiseHasher + ?Sized, { @@ -183,8 +180,6 @@ where // range of (-1, 1). const SCALE_FACTOR: f64 = 1.0; // 1/(sqrt(N)/2), N=4 -> 2/sqrt(4) -> 2/2 -> 1 - let point = Vector4::from(point); - let corner = point.floor_to_isize(); let distance = point - corner.numcast().unwrap();