MapgenValleys: Fixed submarine valleys shape
authorGael-de-Sailly <gael.chretien@akeonet.com>
Wed, 28 Feb 2018 17:51:53 +0000 (18:51 +0100)
committerparamat <mat.gregory@virginmedia.com>
Sat, 3 Mar 2018 22:59:26 +0000 (22:59 +0000)
src/mapgen/mapgen_valleys.cpp

index 1705dce1ce3145e6b48803a1705eaac0e58652a0..0c606f3e870e5bd9c2e50a78ef49006d8c2a6d2f 100644 (file)
@@ -40,6 +40,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "mg_decoration.h"
 #include "mapgen_valleys.h"
 #include "cavegen.h"
+#include <cmath>
 
 
 //#undef NDEBUG
@@ -373,7 +374,7 @@ float MapgenValleys::terrainLevelFromNoise(TerrainNoise *tn)
        //   (here x = "river" and a = valley_profile).
        //  "valley" represents the height of the terrain, from the rivers.
        {
-               float t = river / tn->valley_profile;
+               float t = std::fmax(river / tn->valley_profile, 0.0f);
                *tn->valley = valley_d * (1.f - exp(- MYSQUARE(t)));
        }