summaryrefslogtreecommitdiff
path: root/modules/opensimplex
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-04-06 13:06:50 +0200
committerGitHub <noreply@github.com>2019-04-06 13:06:50 +0200
commit87ee2a9239928e2811ce1711bc381f601edd278a (patch)
tree1cdb3c57ab320aa1b4ea40a1fa90d55a506ec50b /modules/opensimplex
parent72be5ddc433cab895b31c613d517fb1f57de829f (diff)
parenta3ecfb7a823a8123f9e1e59c633090ad5fc4e531 (diff)
Merge pull request #26634 from psuhas77/patch-3
Added get_noise_1d
Diffstat (limited to 'modules/opensimplex')
-rw-r--r--modules/opensimplex/open_simplex_noise.cpp6
-rw-r--r--modules/opensimplex/open_simplex_noise.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/modules/opensimplex/open_simplex_noise.cpp b/modules/opensimplex/open_simplex_noise.cpp
index b2d6b5e718..3a3a698e5c 100644
--- a/modules/opensimplex/open_simplex_noise.cpp
+++ b/modules/opensimplex/open_simplex_noise.cpp
@@ -173,6 +173,7 @@ void OpenSimplexNoise::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image", "width", "height"), &OpenSimplexNoise::get_image);
ClassDB::bind_method(D_METHOD("get_seamless_image", "size"), &OpenSimplexNoise::get_seamless_image);
+ ClassDB::bind_method(D_METHOD("get_noise_1d", "x"), &OpenSimplexNoise::get_noise_1d);
ClassDB::bind_method(D_METHOD("get_noise_2d", "x", "y"), &OpenSimplexNoise::get_noise_2d);
ClassDB::bind_method(D_METHOD("get_noise_3d", "x", "y", "z"), &OpenSimplexNoise::get_noise_3d);
ClassDB::bind_method(D_METHOD("get_noise_4d", "x", "y", "z", "w"), &OpenSimplexNoise::get_noise_4d);
@@ -187,6 +188,11 @@ void OpenSimplexNoise::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "lacunarity", PROPERTY_HINT_RANGE, "0.1,4.0,0.01"), "set_lacunarity", "get_lacunarity");
}
+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;
diff --git a/modules/opensimplex/open_simplex_noise.h b/modules/opensimplex/open_simplex_noise.h
index ac4c6e361f..96885f5893 100644
--- a/modules/opensimplex/open_simplex_noise.h
+++ b/modules/opensimplex/open_simplex_noise.h
@@ -73,6 +73,7 @@ public:
Ref<Image> get_image(int p_width, int p_height);
Ref<Image> get_seamless_image(int p_size);
+ float get_noise_1d(float x);
float get_noise_2d(float x, float y);
float get_noise_3d(float x, float y, float z);
float get_noise_4d(float x, float y, float z, float w);