]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/noise.cpp
Remove texture atlas / AtlasPointer, rename getTextureRaw to getTexture
[dragonfireclient.git] / src / noise.cpp
index ba7c30574a8cbd5357d3dbf1860a8e40c6a63b4e..5788a83203e3ba08230728676bbc56592ab8c9f0 100644 (file)
@@ -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
@@ -524,7 +525,6 @@ float *Noise::perlinMap2D(float x, float y) {
                for (j = 0; j != sy; j++) {
                        for (i = 0; i != sx; i++) {
                                result[index] += g * buf[index];
-//dstream << "pm2d i="<<index<<" r="<< result[index]<<std::endl;
                                index++;
                        }
                }
@@ -537,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;