summaryrefslogtreecommitdiff
path: root/src/noise.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2013-04-06 11:19:59 -0400
committerkwolekr <kwolekr@minetest.net>2013-04-07 00:50:21 -0400
commit8ec3fc35c656544a55f7f8ece9359c9e2b472e8f (patch)
tree430e173e418763fb80f5b43c79c0344dd272d878 /src/noise.cpp
parentd50b2ede92bb33d6f471be34cd7e64efc6434c6b (diff)
downloadminetest-8ec3fc35c656544a55f7f8ece9359c9e2b472e8f.tar.gz
minetest-8ec3fc35c656544a55f7f8ece9359c9e2b472e8f.tar.bz2
minetest-8ec3fc35c656544a55f7f8ece9359c9e2b472e8f.zip
Add Mapgen V7, reorganize biomes
Diffstat (limited to 'src/noise.cpp')
-rw-r--r--src/noise.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/noise.cpp b/src/noise.cpp
index 49b5f7e58..5788a8320 100644
--- a/src/noise.cpp
+++ b/src/noise.cpp
@@ -1,6 +1,7 @@
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -536,6 +537,41 @@ float *Noise::perlinMap2D(float x, float y) {
}
+float *Noise::perlinMap2DModulated(float x, float y, float *persist_map) {
+ float f = 1.0;
+ int i, j, index, oct;
+
+ x /= np->spread.X;
+ y /= np->spread.Y;
+
+ memset(result, 0, sizeof(float) * sx * sy);
+
+ float *g = new float[sx * sy];
+ for (index = 0; index != sx * sy; index++)
+ g[index] = 1.0;
+
+ for (oct = 0; oct < np->octaves; oct++) {
+ gradientMap2D(x * f, y * f,
+ f / np->spread.X, f / np->spread.Y,
+ seed + np->seed + oct);
+
+ index = 0;
+ for (j = 0; j != sy; j++) {
+ for (i = 0; i != sx; i++) {
+ result[index] += g[index] * buf[index];
+ g[index] *= persist_map[index];
+ index++;
+ }
+ }
+
+ f *= 2.0;
+ }
+
+ delete[] g;
+ return result;
+}
+
+
float *Noise::perlinMap3D(float x, float y, float z) {
float f = 1.0, g = 1.0;
int i, j, k, index, oct;