diff options
author | kwolekr <kwolekr@minetest.net> | 2014-12-08 03:25:14 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2014-12-08 03:26:29 -0500 |
commit | 2a7c6d27b32711e2439bf56715d813ef96b8f904 (patch) | |
tree | 4d10b13096a797a90284f9805844e03e0bb18af9 /src/noise.h | |
parent | 0183c05ee0ed0c6566a860119ee93cf88ba7d9ee (diff) | |
download | minetest-2a7c6d27b32711e2439bf56715d813ef96b8f904.tar.gz minetest-2a7c6d27b32711e2439bf56715d813ef96b8f904.tar.bz2 minetest-2a7c6d27b32711e2439bf56715d813ef96b8f904.zip |
Optimize noise implementations
Diffstat (limited to 'src/noise.h')
-rw-r--r-- | src/noise.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/noise.h b/src/noise.h index 1f7bdbbf4..a7212a298 100644 --- a/src/noise.h +++ b/src/noise.h @@ -127,8 +127,9 @@ public: int sx; int sy; int sz; - float *noisebuf; - float *buf; + float *noise_buf; + float *gradient_buf; + float *persist_buf; float *result; Noise(NoiseParams *np, int seed, int sx, int sy, int sz=1); @@ -137,7 +138,6 @@ public: void setSize(int sx, int sy, int sz=1); void setSpreadFactor(v3f spread); void setOctaves(int octaves); - void resizeNoiseBuf(bool is3d); void gradientMap2D( float x, float y, @@ -151,8 +151,13 @@ public: float *perlinMap2D(float x, float y, float *persistence_map=NULL); float *perlinMap3D(float x, float y, float z, float *persistence_map=NULL); - void updateResults(float g, float *gmap, float *persistence_map, size_t bufsize); void transformNoiseMap(); + +private: + void allocBuffers(); + void resizeNoiseBuf(bool is3d); + void updateResults(float g, float *gmap, float *persistence_map, size_t bufsize); + }; // Return value: -1 ... 1 @@ -174,7 +179,8 @@ float noise3d_perlin(float x, float y, float z, int seed, float noise3d_perlin_abs(float x, float y, float z, int seed, int octaves, float persistence, bool eased=false); -inline float easeCurve(float t) { +inline float easeCurve(float t) +{ return t * t * t * (t * (6.f * t - 15.f) + 10.f); } |