]> git.lizzy.rs Git - minetest.git/blobdiff - src/mapgen.cpp
Set proper GLSL pixel shader version
[minetest.git] / src / mapgen.cpp
index f5046459e92a10b123b06061681b0f92e166c349..36d19bfa74f96f6f09fc0960ac7f9028d973ea10 100644 (file)
@@ -41,11 +41,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "log.h"
 
 FlagDesc flagdesc_mapgen[] = {
-       {"trees",    MG_TREES},
-       {"caves",    MG_CAVES},
-       {"dungeons", MG_DUNGEONS},
-       {"flat",     MG_FLAT},
-       {"light",    MG_LIGHT},
+       {"trees",       MG_TREES},
+       {"caves",       MG_CAVES},
+       {"dungeons",    MG_DUNGEONS},
+       {"flat",        MG_FLAT},
+       {"light",       MG_LIGHT},
+       {"decorations", MG_DECORATIONS},
        {NULL,       0}
 };
 
@@ -161,6 +162,26 @@ s16 Mapgen::findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax)
 }
 
 
+// Returns -MAX_MAP_GENERATION_LIMIT if not found or if ground is found first
+s16 Mapgen::findLiquidSurface(v2s16 p2d, s16 ymin, s16 ymax)
+{
+       v3s16 em = vm->m_area.getExtent();
+       u32 i = vm->m_area.index(p2d.X, ymax, p2d.Y);
+       s16 y;
+
+       for (y = ymax; y >= ymin; y--) {
+               MapNode &n = vm->m_data[i];
+               if (ndef->get(n).walkable)
+                       return -MAX_MAP_GENERATION_LIMIT;
+               else if (ndef->get(n).isLiquid())
+                       break;
+
+               vm->m_area.add_y(em, i, -1);
+       }
+       return (y >= ymin) ? y : -MAX_MAP_GENERATION_LIMIT;
+}
+
+
 void Mapgen::updateHeightmap(v3s16 nmin, v3s16 nmax)
 {
        if (!heightmap)
@@ -243,37 +264,20 @@ void Mapgen::lightSpread(VoxelArea &a, v3s16 p, u8 light)
 }
 
 
-void Mapgen::calcLighting(v3s16 nmin, v3s16 nmax, v3s16 full_nmin, v3s16 full_nmax)
+void Mapgen::calcLighting(v3s16 nmin, v3s16 nmax, v3s16 full_nmin, v3s16 full_nmax,
+       bool propagate_shadow)
 {
        ScopeProfiler sp(g_profiler, "EmergeThread: mapgen lighting update", SPT_AVG);
        //TimeTaker t("updateLighting");
 
-       propagateSunlight(nmin, nmax);
+       propagateSunlight(nmin, nmax, propagate_shadow);
        spreadLight(full_nmin, full_nmax);
 
        //printf("updateLighting: %dms\n", t.stop());
 }
 
 
-
-void Mapgen::calcLighting(v3s16 nmin, v3s16 nmax)
-{
-       ScopeProfiler sp(g_profiler, "EmergeThread: mapgen lighting update", SPT_AVG);
-       //TimeTaker t("updateLighting");
-
-       propagateSunlight(
-               nmin - v3s16(1, 1, 1) * MAP_BLOCKSIZE,
-               nmax + v3s16(1, 0, 1) * MAP_BLOCKSIZE);
-
-       spreadLight(
-               nmin - v3s16(1, 1, 1) * MAP_BLOCKSIZE,
-               nmax + v3s16(1, 1, 1) * MAP_BLOCKSIZE);
-
-       //printf("updateLighting: %dms\n", t.stop());
-}
-
-
-void Mapgen::propagateSunlight(v3s16 nmin, v3s16 nmax)
+void Mapgen::propagateSunlight(v3s16 nmin, v3s16 nmax, bool propagate_shadow)
 {
        //TimeTaker t("propagateSunlight");
        VoxelArea a(nmin, nmax);
@@ -287,7 +291,8 @@ void Mapgen::propagateSunlight(v3s16 nmin, v3s16 nmax)
                        if (vm->m_data[i].getContent() == CONTENT_IGNORE) {
                                if (block_is_underground)
                                        continue;
-                       } else if ((vm->m_data[i].param1 & 0x0F) != LIGHT_SUN) {
+                       } else if ((vm->m_data[i].param1 & 0x0F) != LIGHT_SUN &&
+                                       propagate_shadow) {
                                continue;
                        }
                        vm->m_area.add_y(em, i, -1);
@@ -305,7 +310,6 @@ void Mapgen::propagateSunlight(v3s16 nmin, v3s16 nmax)
 }
 
 
-
 void Mapgen::spreadLight(v3s16 nmin, v3s16 nmax)
 {
        //TimeTaker t("spreadLight");