summaryrefslogtreecommitdiff
path: root/src/mapgen.cpp
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2015-12-02 03:28:03 +0000
committerparamat <mat.gregory@virginmedia.com>2015-12-07 03:18:24 +0000
commit49073ba2c34dfd8e286865ed2d108a4ec1eb3e3c (patch)
tree2372b48d5bfd846775ced52653afa92883e0a20c /src/mapgen.cpp
parenta78dd7f2b6b0e1fefdbaa1ae21b722dd4459e4f4 (diff)
downloadminetest-49073ba2c34dfd8e286865ed2d108a4ec1eb3e3c.tar.gz
minetest-49073ba2c34dfd8e286865ed2d108a4ec1eb3e3c.tar.bz2
minetest-49073ba2c34dfd8e286865ed2d108a4ec1eb3e3c.zip
Mapgen: Add propagate_shadow bool to calcLighting
To terminate unwanted shadows from floatlands or realms above Also add to LuaVoxelManip calc_lighting for use in mapgen mods Remove the 2 argument calcLighting, mapgens now use the 5 argument form to specify the volumes for propagateSunlight and spreadLight In mgsinglenode replace calcLighting with setLighting and clean-up use of tabs and spaces
Diffstat (limited to 'src/mapgen.cpp')
-rw-r--r--src/mapgen.cpp29
1 files changed, 6 insertions, 23 deletions
diff --git a/src/mapgen.cpp b/src/mapgen.cpp
index 5a209eddd..36d19bfa7 100644
--- a/src/mapgen.cpp
+++ b/src/mapgen.cpp
@@ -264,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);
@@ -308,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);
@@ -326,7 +310,6 @@ void Mapgen::propagateSunlight(v3s16 nmin, v3s16 nmax)
}
-
void Mapgen::spreadLight(v3s16 nmin, v3s16 nmax)
{
//TimeTaker t("spreadLight");