summaryrefslogtreecommitdiff
path: root/src/mapblock.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-01-15 13:07:10 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-01-15 13:07:10 +0200
commit83e083a667d8423ea27555ed58cc90a5f57d103f (patch)
tree094440273d10403b04106fe071f19fa7b30a128d /src/mapblock.cpp
parent3fb0d2fb65c968f91c333a1d31d2d7a1a02ab7d1 (diff)
downloadminetest-83e083a667d8423ea27555ed58cc90a5f57d103f.tar.gz
minetest-83e083a667d8423ea27555ed58cc90a5f57d103f.tar.bz2
minetest-83e083a667d8423ea27555ed58cc90a5f57d103f.zip
just backuppin' a working mapblock.cpp
Diffstat (limited to 'src/mapblock.cpp')
-rw-r--r--src/mapblock.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/mapblock.cpp b/src/mapblock.cpp
index 2d077121c..68b296154 100644
--- a/src/mapblock.cpp
+++ b/src/mapblock.cpp
@@ -864,8 +864,14 @@ void MapBlock::updateMesh(u32 daynight_ratio)
- SUGG: This could be optimized
Turns sunglighted mud into grass.
+
+ if remove_light==true, sets non-sunlighted nodes black.
+
+ if black_air_left!=NULL, it is set to true if non-sunlighted
+ air is left in block.
*/
-bool MapBlock::propagateSunlight(core::map<v3s16, bool> & light_sources)
+bool MapBlock::propagateSunlight(core::map<v3s16, bool> & light_sources,
+ bool remove_light, bool *black_air_left)
{
// Whether the sunlight at the top of the bottom block is valid
bool block_below_is_valid = true;
@@ -959,19 +965,27 @@ bool MapBlock::propagateSunlight(core::map<v3s16, bool> & light_sources)
}
bool sunlight_should_go_down = (y==-1);
-
- // Fill rest with black (only transparent ones)
- for(; y >= 0; y--){
+
+ /*
+ Check rest through to the bottom of the block
+ */
+ for(; y >= 0; y--)
+ {
v3s16 pos(x, y, z);
-
MapNode &n = getNodeRef(pos);
if(n.light_propagates())
{
- n.setLight(LIGHTBANK_DAY, 0);
- }
- else{
- break;
+ if(black_air_left)
+ {
+ *black_air_left = true;
+ }
+
+ if(remove_light)
+ {
+ // Fill transparent nodes with black
+ n.setLight(LIGHTBANK_DAY, 0);
+ }
}
}