// list of nodes that due to viscosity have not reached their max level height
std::deque<v3s16> must_reflow;
- // List of MapBlocks that will require a lighting update (due to lava)
- std::map<v3s16, MapBlock *> lighting_modified_blocks2;
-
std::vector<std::pair<v3s16, MapNode> > changed_nodes;
u32 liquid_loop_max = g_settings->getS32("liquid_loop_max");
Collect information about current node
*/
s8 liquid_level = -1;
+ // The liquid node which will be placed there if
+ // the liquid flows into this node.
content_t liquid_kind = CONTENT_IGNORE;
+ // The node which will be placed there if liquid
+ // can't flow into this node.
content_t floodable_node = CONTENT_AIR;
const ContentFeatures &cf = nodemgr->get(n0);
LiquidType liquid_type = cf.liquid_type;
MapBlock *block = getBlockNoCreateNoEx(blockpos);
if (block != NULL) {
modified_blocks[blockpos] = block;
- // If new or old node emits light, MapBlock requires lighting update
- /*if (nodemgr->get(n0).light_source != 0 ||
- nodemgr->get(n00).light_source != 0)
- lighting_modified_blocks[block->getPos()] = block;*/
changed_nodes.push_back(std::pair<v3s16, MapNode>(p0, n00));
}
for (std::deque<v3s16>::iterator iter = must_reflow.begin(); iter != must_reflow.end(); ++iter)
m_transforming_liquid.push_back(*iter);
- //updateLighting(lighting_modified_blocks, modified_blocks);
voxalgo::update_lighting_nodes(this, nodemgr, changed_nodes, modified_blocks);
#include "nodedef.h"
#include "mapblock.h"
#include "map.h"
-#include "util/timetaker.h"
namespace voxalgo
{
* 4=Y-
* 5=X-
* 6=no direction
- * Two directions ate opposite only if their sum is 5.
+ * Two directions are opposite only if their sum is 5.
*/
typedef u8 direction;
/*!
*/
typedef v3s16 relative_v3;
/*!
- * Position of a map block.
+ * Position of a map block (block coordinates).
* One block_pos unit is as long as 16 node position units.
*/
typedef v3s16 mapblock_v3;
relative_v3 rel_position;
//! Position of the node's block.
mapblock_v3 block_position;
- //! Reference to the node's block.
+ //! Pointer to the node's block.
MapBlock *block;
/*!
* Direction from the node that caused this node's changing
* The parameters are the same as in ChangingLight's constructor.
* \param light light level of the ChangingLight
*/
- inline void push(u8 light, relative_v3 &rel_pos, mapblock_v3 &block_pos,
- MapBlock *block, direction source_dir)
+ inline void push(u8 light, const relative_v3 &rel_pos,
+ const mapblock_v3 &block_pos, MapBlock *block,
+ direction source_dir)
{
lights[light].push_back(
ChangingLight(rel_pos, block_pos, block, source_dir));
* \param rel_pos the node's relative position in its map block
* \param block_pos position of the node's block
*/
-bool stepRelBlockPos(direction dir, relative_v3 &rel_pos,
+bool step_rel_block_pos(direction dir, relative_v3 &rel_pos,
mapblock_v3 &block_pos)
{
switch (dir) {
* \param light_sources nodes that should be re-lighted
* \param modified_blocks output, all modified map blocks are added to this
*/
-void unspreadLight(Map *map, INodeDefManager *nodemgr, LightBank bank,
+void unspread_light(Map *map, INodeDefManager *nodemgr, LightBank bank,
UnlightQueue &from_nodes, ReLightQueue &light_sources,
- std::map<v3s16, MapBlock*> & modified_blocks)
+ std::map<v3s16, MapBlock*> &modified_blocks)
{
// Stores data popped from from_nodes
u8 current_light;
neighbor_rel_pos = current.rel_position;
neighbor_block_pos = current.block_position;
MapBlock *neighbor_block;
- if (stepRelBlockPos(i, neighbor_rel_pos, neighbor_block_pos)) {
+ if (step_rel_block_pos(i, neighbor_rel_pos, neighbor_block_pos)) {
neighbor_block = map->getBlockNoCreateNoEx(neighbor_block_pos);
if (neighbor_block == NULL) {
continue;
* \param light_sources starting nodes
* \param modified_blocks output, all modified map blocks are added to this
*/
-void spreadLight(Map *map, INodeDefManager *nodemgr, LightBank bank,
- LightQueue & light_sources, std::map<v3s16, MapBlock*> & modified_blocks)
+void spread_light(Map *map, INodeDefManager *nodemgr, LightBank bank,
+ LightQueue &light_sources, std::map<v3s16, MapBlock*> &modified_blocks)
{
// The light the current node can provide to its neighbors.
u8 spreading_light;
neighbor_rel_pos = current.rel_position;
neighbor_block_pos = current.block_position;
MapBlock *neighbor_block;
- if (stepRelBlockPos(i, neighbor_rel_pos, neighbor_block_pos)) {
+ if (step_rel_block_pos(i, neighbor_rel_pos, neighbor_block_pos)) {
neighbor_block = map->getBlockNoCreateNoEx(neighbor_block_pos);
if (neighbor_block == NULL) {
continue;
*
* \param pos position of the node.
*/
-bool isSunlightAbove(Map *map, v3s16 pos, INodeDefManager *ndef)
+bool is_sunlight_above(Map *map, v3s16 pos, INodeDefManager *ndef)
{
bool sunlight = true;
mapblock_v3 source_block_pos;
void update_lighting_nodes(Map *map, INodeDefManager *ndef,
std::vector<std::pair<v3s16, MapNode> > &oldnodes,
- std::map<v3s16, MapBlock*> & modified_blocks)
+ std::map<v3s16, MapBlock*> &modified_blocks)
{
// For node getter functions
bool is_valid_position;
ReLightQueue light_sources(256);
// For each changed node process sunlight and initialize
for (std::vector<std::pair<v3s16, MapNode> >::iterator it =
- oldnodes.begin(); it < oldnodes.end(); it++) {
+ oldnodes.begin(); it < oldnodes.end(); ++it) {
// Get position and block of the changed node
v3s16 p = it->first;
relative_v3 rel_pos;
u8 new_light = 0;
if (ndef->get(n).light_propagates) {
if (bank == LIGHTBANK_DAY && ndef->get(n).sunlight_propagates
- && isSunlightAbove(map, p, ndef)) {
+ && is_sunlight_above(map, p, ndef)) {
new_light = LIGHT_SUN;
} else {
new_light = ndef->get(n).light_source;
}
// Remove lights
- unspreadLight(map, ndef, bank, disappearing_lights, light_sources,
+ unspread_light(map, ndef, bank, disappearing_lights, light_sources,
modified_blocks);
// Initialize light values for light spreading.
for (u8 i = 0; i <= LIGHT_SUN; i++) {
}
}
// Spread lights.
- spreadLight(map, ndef, bank, light_sources, modified_blocks);
+ spread_light(map, ndef, bank, light_sources, modified_blocks);
}
}