summaryrefslogtreecommitdiff
path: root/src/mapblock.cpp
diff options
context:
space:
mode:
authorDániel Juhász <juhdanad@gmail.com>2018-02-04 04:16:45 +0100
committerAndrew Ward <rw@rubenwardy.com>2018-02-04 03:16:45 +0000
commit735fc2a1f25eed78460c02867a4960fbf1e66a72 (patch)
tree45c25a6958309bf6b6277f5a201dc6b112a91e22 /src/mapblock.cpp
parentcf0bcebc7620ff2a4bfb44bcbc4909ff9dbe8d24 (diff)
downloadminetest-735fc2a1f25eed78460c02867a4960fbf1e66a72.tar.gz
minetest-735fc2a1f25eed78460c02867a4960fbf1e66a72.tar.bz2
minetest-735fc2a1f25eed78460c02867a4960fbf1e66a72.zip
Remove unused light updating code
Also remove the unit test that tests the removed algorithms.
Diffstat (limited to 'src/mapblock.cpp')
-rw-r--r--src/mapblock.cpp192
1 files changed, 0 insertions, 192 deletions
diff --git a/src/mapblock.cpp b/src/mapblock.cpp
index 88f04e0bb..ad98373f2 100644
--- a/src/mapblock.cpp
+++ b/src/mapblock.cpp
@@ -132,198 +132,6 @@ std::string MapBlock::getModifiedReasonString()
return reason;
}
-/*
- Propagates sunlight down through the block.
- Doesn't modify nodes that are not affected by sunlight.
-
- Returns false if sunlight at bottom block is invalid.
- Returns true if sunlight at bottom block is valid.
- Returns true if bottom block doesn't exist.
-
- If there is a block above, continues from it.
- If there is no block above, assumes there is sunlight, unless
- is_underground is set or highest node is water.
-
- All sunlighted nodes are added to light_sources.
-
- 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(std::set<v3s16> & light_sources,
- bool remove_light, bool *black_air_left)
-{
- INodeDefManager *nodemgr = m_gamedef->ndef();
-
- // Whether the sunlight at the top of the bottom block is valid
- bool block_below_is_valid = true;
-
- v3s16 pos_relative = getPosRelative();
-
- for(s16 x=0; x<MAP_BLOCKSIZE; x++)
- {
- for(s16 z=0; z<MAP_BLOCKSIZE; z++)
- {
-#if 1
- bool no_sunlight = false;
- //bool no_top_block = false;
-
- // Check if node above block has sunlight
-
- bool is_valid_position;
- MapNode n = getNodeParent(v3s16(x, MAP_BLOCKSIZE, z),
- &is_valid_position);
- if (is_valid_position)
- {
- if(n.getContent() == CONTENT_IGNORE)
- {
- // Trust heuristics
- no_sunlight = is_underground;
- }
- else if(n.getLight(LIGHTBANK_DAY, m_gamedef->ndef()) != LIGHT_SUN)
- {
- no_sunlight = true;
- }
- }
- else
- {
- //no_top_block = true;
-
- // NOTE: This makes over-ground roofed places sunlighted
- // Assume sunlight, unless is_underground==true
- if(is_underground)
- {
- no_sunlight = true;
- }
- else
- {
- MapNode n = getNodeNoEx(v3s16(x, MAP_BLOCKSIZE-1, z));
- if (!m_gamedef->ndef()->get(n).sunlight_propagates) {
- no_sunlight = true;
- }
- }
- // NOTE: As of now, this just would make everything dark.
- // No sunlight here
- //no_sunlight = true;
- }
-#endif
-#if 0 // Doesn't work; nothing gets light.
- bool no_sunlight = true;
- bool no_top_block = false;
- // Check if node above block has sunlight
- try{
- MapNode n = getNodeParent(v3s16(x, MAP_BLOCKSIZE, z));
- if(n.getLight(LIGHTBANK_DAY) == LIGHT_SUN)
- {
- no_sunlight = false;
- }
- }
- catch(InvalidPositionException &e)
- {
- no_top_block = true;
- }
-#endif
-
- /*std::cout<<"("<<x<<","<<z<<"): "
- <<"no_top_block="<<no_top_block
- <<", is_underground="<<is_underground
- <<", no_sunlight="<<no_sunlight
- <<std::endl;*/
-
- s16 y = MAP_BLOCKSIZE-1;
-
- // This makes difference to diminishing in water.
- bool stopped_to_solid_object = false;
-
- u8 current_light = no_sunlight ? 0 : LIGHT_SUN;
-
- for(; y >= 0; y--)
- {
- v3s16 pos(x, y, z);
- MapNode &n = getNodeRef(pos);
-
- if(current_light == 0)
- {
- // Do nothing
- }
- else if(current_light == LIGHT_SUN && nodemgr->get(n).sunlight_propagates)
- {
- // Do nothing: Sunlight is continued
- } else if (!nodemgr->get(n).light_propagates) {
- // A solid object is on the way.
- stopped_to_solid_object = true;
-
- // Light stops.
- current_light = 0;
- }
- else
- {
- // Diminish light
- current_light = diminish_light(current_light);
- }
-
- u8 old_light = n.getLight(LIGHTBANK_DAY, nodemgr);
-
- if(current_light > old_light || remove_light)
- {
- n.setLight(LIGHTBANK_DAY, current_light, nodemgr);
- }
-
- if(diminish_light(current_light) != 0)
- {
- light_sources.insert(pos_relative + pos);
- }
-
- if(current_light == 0 && stopped_to_solid_object)
- {
- if(black_air_left)
- {
- *black_air_left = true;
- }
- }
- }
-
- // Whether or not the block below should see LIGHT_SUN
- bool sunlight_should_go_down = (current_light == LIGHT_SUN);
-
- /*
- If the block below hasn't already been marked invalid:
-
- Check if the node below the block has proper sunlight at top.
- If not, the block below is invalid.
-
- Ignore non-transparent nodes as they always have no light
- */
-
- if(block_below_is_valid)
- {
- MapNode n = getNodeParent(v3s16(x, -1, z), &is_valid_position);
- if (is_valid_position) {
- if(nodemgr->get(n).light_propagates)
- {
- if(n.getLight(LIGHTBANK_DAY, nodemgr) == LIGHT_SUN
- && !sunlight_should_go_down)
- block_below_is_valid = false;
- else if(n.getLight(LIGHTBANK_DAY, nodemgr) != LIGHT_SUN
- && sunlight_should_go_down)
- block_below_is_valid = false;
- }
- }
- else
- {
- /*std::cout<<"InvalidBlockException for bottom block node"
- <<std::endl;*/
- // Just no block below, no need to panic.
- }
- }
- }
- }
-
- return block_below_is_valid;
-}
-
-
void MapBlock::copyTo(VoxelManipulator &dst)
{
v3s16 data_size(MAP_BLOCKSIZE, MAP_BLOCKSIZE, MAP_BLOCKSIZE);