aboutsummaryrefslogtreecommitdiff
path: root/src/content_mapnode.h
Commit message (Expand)AuthorAge
* Remove unused functions.onkrot2015-08-16
* Update Copyright YearsSfan52013-02-24
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
* Fix map deserialization and remove old serialization codePerttu Ahola2012-07-23
* Switch the license to be LGPLv2/later, with small parts still remaining as GP...Perttu Ahola2012-06-05
* The huge item definition and item namespace unification patch (itemdef), see ...Kahrl2012-01-12
* Add node definitions in Lua and do not use content_mapnode_init anymore (exce...Kahrl2011-11-29
* Do not expose CONTENT_* stuff in content_mapnode.h and use a name converter w...Perttu Ahola2011-11-29
* Node definition namesPerttu Ahola2011-11-29
* Completely generalized mesh generation; ContentFeatures serializationPerttu Ahola2011-11-29
* GameDef compilesPerttu Ahola2011-11-29
* Create framework for getting rid of global definitions of node/tool/item/what...Perttu Ahola2011-11-29
* Move ContentFeatures to mapnode_contentfeatures.{h,cpp} and clean stuffPerttu Ahola2011-11-29
* Merge remote-tracking branch 'marktraceur/master'Perttu Ahola2011-09-26
|\
| * Adding (most) of the sapling functionality. It has yet to work, since MEET_OT...Mark Holmquist2011-09-23
* | added locking chests - clean patchdarkrose2011-09-22
|/
* Removed Spacessfan52011-09-11
* Added Apple Treessfan52011-09-11
* lava!Perttu Ahola2011-08-15
* Changing CONTENT_LADDER to be an extended blockMark Holmquist2011-08-01
* Added ladders--they don't have any use yet, thoughMark Holmquist2011-08-01
* Added MaterialItem conversion from old content type namespace to newPerttu Ahola2011-07-31
* Fixed handling of inventory in creative mode (normal inventory is not trashed...Perttu Ahola2011-07-30
* changed jungletree/junglegrass content ids to extended rangePerttu Ahola2011-07-24
* merged jungle and bluish shadowsPerttu Ahola2011-07-23
|\
| * Jungle biome/whatever thingPerttu Ahola2011-07-23
* | merged the content type extension and deltaPerttu Ahola2011-07-23
|\|
| * Merge branch 'master' of https://github.com/erlehmann/minetest-delta.git into...Sebastian Rühl2011-06-26
* | extended content-type rangePerttu Ahola2011-07-23
|/
* New map generator added (and SQLite, messed up the commits at that time...) (...Perttu Ahola2011-06-25
* Moved some mapnode content stuff from mapnode.{h,cpp} and digging property st...Perttu Ahola2011-06-17
l opt">, 0, sizeof(m_lookup)); int block_idx = 1 + (1 * 9) + (1 * 3); m_lookup[block_idx] = block; m_lookup_state_bitset = 1 << block_idx; // Scan the columns in the block for (s16 z = 0; z < MAP_BLOCKSIZE; z++) for (s16 x = 0; x < MAP_BLOCKSIZE; x++) { scanColumn(x, z); } // Scan neighbouring columns from the nearby blocks as they might contain // liquid nodes that weren't allowed to flow to prevent gaps. for (s16 i = 0; i < MAP_BLOCKSIZE; i++) { scanColumn(i, -1); scanColumn(i, MAP_BLOCKSIZE); scanColumn(-1, i); scanColumn(MAP_BLOCKSIZE, i); } } inline MapBlock *ReflowScan::lookupBlock(int x, int y, int z) { // Gets the block that contains (x,y,z) relativ to the scanned block. // This uses a lookup as there might be many lookups into the same // neighbouring block which makes fetches from Map costly. int bx = (MAP_BLOCKSIZE + x) / MAP_BLOCKSIZE; int by = (MAP_BLOCKSIZE + y) / MAP_BLOCKSIZE; int bz = (MAP_BLOCKSIZE + z) / MAP_BLOCKSIZE; int idx = (bx + (by * 9) + (bz * 3)); MapBlock *result = m_lookup[idx]; if (!result && (m_lookup_state_bitset & (1 << idx)) == 0) { // The block wasn't requested yet so fetch it from Map and store it // in the lookup v3s16 pos = m_block_pos + v3s16(bx - 1, by - 1, bz - 1); m_lookup[idx] = result = m_map->getBlockNoCreateNoEx(pos); m_lookup_state_bitset |= (1 << idx); } return result; } inline bool ReflowScan::isLiquidFlowableTo(int x, int y, int z) { // Tests whether (x,y,z) is a node to which liquid might flow. bool valid_position; MapBlock *block = lookupBlock(x, y, z); if (block) { int dx = (MAP_BLOCKSIZE + x) % MAP_BLOCKSIZE; int dy = (MAP_BLOCKSIZE + y) % MAP_BLOCKSIZE; int dz = (MAP_BLOCKSIZE + z) % MAP_BLOCKSIZE; MapNode node = block->getNodeNoCheck(dx, dy, dz, &valid_position); if (node.getContent() != CONTENT_IGNORE) { const ContentFeatures &f = m_ndef->get(node); // NOTE: No need to check for flowing nodes with lower liquid level // as they should only occur on top of other columns where they // will be added to the queue themselves. return f.floodable; } } return false; } inline bool ReflowScan::isLiquidHorizontallyFlowable(int x, int y, int z) { // Check if the (x,y,z) might spread to one of the horizontally // neighbouring nodes return isLiquidFlowableTo(x - 1, y, z) || isLiquidFlowableTo(x + 1, y, z) || isLiquidFlowableTo(x, y, z - 1) || isLiquidFlowableTo(x, y, z + 1); } void ReflowScan::scanColumn(int x, int z) { bool valid_position; // Is the column inside a loaded block? MapBlock *block = lookupBlock(x, 0, z); if (!block) return; MapBlock *above = lookupBlock(x, MAP_BLOCKSIZE, z); int dx = (MAP_BLOCKSIZE + x) % MAP_BLOCKSIZE; int dz = (MAP_BLOCKSIZE + z) % MAP_BLOCKSIZE; // Get the state from the node above the scanned block bool was_ignore, was_liquid; if (above) { MapNode node = above->getNodeNoCheck(dx, 0, dz, &valid_position); was_ignore = node.getContent() == CONTENT_IGNORE; was_liquid = m_ndef->get(node).isLiquid(); } else { was_ignore = true; was_liquid = false; } bool was_checked = false; bool was_pushed = false; // Scan through the whole block for (s16 y = MAP_BLOCKSIZE - 1; y >= 0; y--) { MapNode node = block->getNodeNoCheck(dx, y, dz, &valid_position); const ContentFeatures &f = m_ndef->get(node); bool is_ignore = node.getContent() == CONTENT_IGNORE; bool is_liquid = f.isLiquid(); if (is_ignore || was_ignore || is_liquid == was_liquid) { // Neither topmost node of liquid column nor topmost node below column was_checked = false; was_pushed = false; } else if (is_liquid) { // This is the topmost node in the column bool is_pushed = false; if (f.liquid_type == LIQUID_FLOWING || isLiquidHorizontallyFlowable(x, y, z)) { m_liquid_queue->push_back(m_rel_block_pos + v3s16(x, y, z)); is_pushed = true; } // Remember waschecked and waspushed to avoid repeated // checks/pushes in case the column consists of only this node was_checked = true; was_pushed = is_pushed; } else { // This is the topmost node below a liquid column if (!was_pushed && (f.floodable || (!was_checked && isLiquidHorizontallyFlowable(x, y + 1, z)))) { // Activate the lowest node in the column which is one // node above this one m_liquid_queue->push_back(m_rel_block_pos + v3s16(x, y + 1, z)); } } was_liquid = is_liquid; was_ignore = is_ignore; } // Check the node below the current block MapBlock *below = lookupBlock(x, -1, z); if (below) { MapNode node = below->getNodeNoCheck(dx, MAP_BLOCKSIZE - 1, dz, &valid_position); const ContentFeatures &f = m_ndef->get(node); bool is_ignore = node.getContent() == CONTENT_IGNORE; bool is_liquid = f.isLiquid(); if (is_ignore || was_ignore || is_liquid == was_liquid) { // Neither topmost node of liquid column nor topmost node below column } else if (is_liquid) { // This is the topmost node in the column and might want to flow away if (f.liquid_type == LIQUID_FLOWING || isLiquidHorizontallyFlowable(x, -1, z)) { m_liquid_queue->push_back(m_rel_block_pos + v3s16(x, -1, z)); } } else { // This is the topmost node below a liquid column if (!was_pushed && (f.floodable || (!was_checked && isLiquidHorizontallyFlowable(x, 0, z)))) { // Activate the lowest node in the column which is one // node above this one m_liquid_queue->push_back(m_rel_block_pos + v3s16(x, 0, z)); } } } }