diff options
Diffstat (limited to 'modules/opensimplex/open_simplex_noise.cpp')
-rw-r--r-- | modules/opensimplex/open_simplex_noise.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/modules/opensimplex/open_simplex_noise.cpp b/modules/opensimplex/open_simplex_noise.cpp index 238faa4130..00b3d47db9 100644 --- a/modules/opensimplex/open_simplex_noise.cpp +++ b/modules/opensimplex/open_simplex_noise.cpp @@ -33,7 +33,6 @@ #include "core/core_string_names.h" OpenSimplexNoise::OpenSimplexNoise() { - seed = 0; persistence = 0.5; octaves = 3; @@ -53,9 +52,9 @@ void OpenSimplexNoise::_init_seeds() { } void OpenSimplexNoise::set_seed(int p_seed) { - - if (seed == p_seed) + if (seed == p_seed) { return; + } seed = p_seed; @@ -65,12 +64,13 @@ void OpenSimplexNoise::set_seed(int p_seed) { } int OpenSimplexNoise::get_seed() { - return seed; } void OpenSimplexNoise::set_octaves(int p_octaves) { - if (p_octaves == octaves) return; + if (p_octaves == octaves) { + return; + } ERR_FAIL_COND_MSG(p_octaves > MAX_OCTAVES, vformat("The number of OpenSimplexNoise octaves is limited to %d; ignoring the new value.", MAX_OCTAVES)); @@ -79,25 +79,30 @@ void OpenSimplexNoise::set_octaves(int p_octaves) { } void OpenSimplexNoise::set_period(float p_period) { - if (p_period == period) return; + if (p_period == period) { + return; + } period = p_period; emit_changed(); } void OpenSimplexNoise::set_persistence(float p_persistence) { - if (p_persistence == persistence) return; + if (p_persistence == persistence) { + return; + } persistence = p_persistence; emit_changed(); } void OpenSimplexNoise::set_lacunarity(float p_lacunarity) { - if (p_lacunarity == lacunarity) return; + if (p_lacunarity == lacunarity) { + return; + } lacunarity = p_lacunarity; emit_changed(); } Ref<Image> OpenSimplexNoise::get_image(int p_width, int p_height) { - Vector<uint8_t> data; data.resize(p_width * p_height * 4); @@ -120,7 +125,6 @@ Ref<Image> OpenSimplexNoise::get_image(int p_width, int p_height) { } Ref<Image> OpenSimplexNoise::get_seamless_image(int p_size) { - Vector<uint8_t> data; data.resize(p_size * p_size * 4); @@ -128,7 +132,6 @@ Ref<Image> OpenSimplexNoise::get_seamless_image(int p_size) { for (int i = 0; i < p_size; i++) { for (int j = 0; j < p_size; j++) { - float ii = (float)i / (float)p_size; float jj = (float)j / (float)p_size; @@ -157,7 +160,6 @@ Ref<Image> OpenSimplexNoise::get_seamless_image(int p_size) { } void OpenSimplexNoise::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_seed"), &OpenSimplexNoise::get_seed); ClassDB::bind_method(D_METHOD("set_seed", "seed"), &OpenSimplexNoise::set_seed); @@ -192,12 +194,10 @@ void OpenSimplexNoise::_bind_methods() { } float OpenSimplexNoise::get_noise_1d(float x) { - return get_noise_2d(x, 1.0); } float OpenSimplexNoise::get_noise_2d(float x, float y) { - x /= period; y /= period; @@ -218,7 +218,6 @@ float OpenSimplexNoise::get_noise_2d(float x, float y) { } float OpenSimplexNoise::get_noise_3d(float x, float y, float z) { - x /= period; y /= period; z /= period; @@ -241,7 +240,6 @@ float OpenSimplexNoise::get_noise_3d(float x, float y, float z) { } float OpenSimplexNoise::get_noise_4d(float x, float y, float z, float w) { - x /= period; y /= period; z /= period; |