From 0fa0e0752a28eeb43195f2288c018d5c0b24520b Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Mon, 17 Jan 2011 14:57:37 +0200 Subject: [PATCH] old water removed, some fixes here and there --- src/client.h | 12 ++-- src/constants.h | 21 ++++-- src/defaultsettings.cpp | 3 +- src/environment.cpp | 4 +- src/main.cpp | 2 + src/map.cpp | 38 +++++++---- src/map.h | 141 ++++++++-------------------------------- src/mapblock.cpp | 11 ++-- src/mapblock.h | 32 +++++++-- src/mapnode.cpp | 4 +- src/mapnode.h | 107 ++++++++++++++++++++---------- src/mapsector.h | 4 +- src/player.cpp | 16 +++-- src/server.cpp | 37 ++++++++--- src/server.h | 6 +- src/utility.cpp | 1 - src/utility.h | 41 ++++++++++++ src/voxel.cpp | 71 +------------------- src/voxel.h | 2 - 19 files changed, 276 insertions(+), 277 deletions(-) diff --git a/src/client.h b/src/client.h index b96ddcbc..9110d33f 100644 --- a/src/client.h +++ b/src/client.h @@ -201,15 +201,19 @@ public: { JMutexAutoLock envlock(m_env_mutex); assert(m_env.getMap().mapType() == MAPTYPE_CLIENT); - v3s16 blockpos = ((ClientMap&)m_env.getMap()).setTempMod(p, mod); - m_env.getMap().updateMeshes(blockpos, m_env.getDayNightRatio()); + bool changed = false; + v3s16 blockpos = ((ClientMap&)m_env.getMap()).setTempMod(p, mod, &changed); + if(changed) + m_env.getMap().updateMeshes(blockpos, m_env.getDayNightRatio()); } void clearTempMod(v3s16 p) { JMutexAutoLock envlock(m_env_mutex); assert(m_env.getMap().mapType() == MAPTYPE_CLIENT); - v3s16 blockpos = ((ClientMap&)m_env.getMap()).clearTempMod(p); - m_env.getMap().updateMeshes(blockpos, m_env.getDayNightRatio()); + bool changed = false; + v3s16 blockpos = ((ClientMap&)m_env.getMap()).clearTempMod(p, &changed); + if(changed) + m_env.getMap().updateMeshes(blockpos, m_env.getDayNightRatio()); } float getAvgRtt() diff --git a/src/constants.h b/src/constants.h index e31f75d3..fc800760 100644 --- a/src/constants.h +++ b/src/constants.h @@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., Cross-platform compatibility crap should go in porting.h. */ -#define HAXMODE 0 +//#define HAXMODE 0 #define APPNAME "minetest" @@ -52,6 +52,19 @@ with this program; if not, write to the Free Software Foundation, Inc., // The absolute working limit is (2^15 - viewing_range). #define MAP_GENERATION_LIMIT (31000) +// Size of node in rendering units +#define BS 10 + +#define MAP_BLOCKSIZE 16 +/* + This makes mesh updates too slow, as many meshes are updated during + the main loop (related to TempMods and day/night) +*/ +//#define MAP_BLOCKSIZE 32 + +// Sectors are split to SECTOR_HEIGHTMAP_SPLIT^2 heightmaps +#define SECTOR_HEIGHTMAP_SPLIT (MAP_BLOCKSIZE/8) + // Time after building, during which the following limit // is in use //#define FULL_BLOCK_SEND_ENABLE_MIN_TIME_FROM_BUILDING 2.0 @@ -61,15 +74,11 @@ with this program; if not, write to the Free Software Foundation, Inc., // is very low #define BLOCK_SEND_DISABLE_LIMITS_MAX_D 1 -// Viewing range stuff - +// The fps limiter will leave this much free time //#define FREETIME_RATIO 0.15 //#define FREETIME_RATIO 0.0 #define FREETIME_RATIO 0.05 -// Sectors are split to SECTOR_HEIGHTMAP_SPLIT^2 heightmaps -#define SECTOR_HEIGHTMAP_SPLIT 2 - #define PLAYER_INVENTORY_SIZE (8*4) #define SIGN_TEXT_MAX_LENGTH 50 diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index d3e193f9..b7b7013d 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -40,6 +40,7 @@ void set_default_settings() // Server stuff g_settings.setDefault("creative_mode", "false"); + g_settings.setDefault("haxmode", "false"); /*g_settings.setDefault("heightmap_blocksize", "32"); g_settings.setDefault("height_randmax", "constant 45.0"); g_settings.setDefault("height_randfactor", "constant 0.6"); @@ -63,7 +64,7 @@ void set_default_settings() g_settings.setDefault("max_simultaneous_block_sends_server_total", "4"); g_settings.setDefault("water_moves", "true"); g_settings.setDefault("disable_water_climb", "true"); - g_settings.setDefault("endless_water", "true"); + //g_settings.setDefault("endless_water", "true"); g_settings.setDefault("max_block_send_distance", "6"); g_settings.setDefault("max_block_generate_distance", "6"); g_settings.setDefault("time_send_interval", "20"); diff --git a/src/environment.cpp b/src/environment.cpp index 42068135..17b98acd 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -18,7 +18,6 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "environment.h" -#include "main.h" // g_device for timing debug Environment::Environment(Map *map, std::ostream &dout): m_dout(dout) @@ -107,7 +106,8 @@ void Environment::step(float dtime) v3f playerpos = player->getPosition(); // Apply physics to local player - if(player->isLocal() && HAXMODE == false) + bool haxmode = g_settings.getBool("haxmode"); + if(player->isLocal() && haxmode == false) { // Apply gravity to local player v3f speed = player->getSpeed(); diff --git a/src/main.cpp b/src/main.cpp index 9f4ad61a..61f791f8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -207,6 +207,8 @@ TODO: Map generator version 2 - Separate points for heightmap, caves, plants and minerals? - Flat land, mountains, forest, jungle - Cliffs, arcs + - There could be a certain height (to which mountains only reach) + where some minerals are found Doing now: ====================================================================== diff --git a/src/map.cpp b/src/map.cpp index d15ac0a7..170868f1 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -35,8 +35,7 @@ Map::Map(std::ostream &dout): m_camera_position(0,0,0), m_camera_direction(0,0,1), m_sector_cache(NULL), - m_hwrapper(this), - drawoffset(0,0,0) + m_hwrapper(this) { m_sector_mutex.Init(); m_camera_mutex.Init(); @@ -1236,7 +1235,7 @@ void Map::deleteSectors(core::list &list, bool only_blocks) This disables the existence of caches while locked */ - SharedPtr cachelock(m_blockcachelock.waitCaches()); + //SharedPtr cachelock(m_blockcachelock.waitCaches()); core::list::Iterator j; for(j=list.begin(); j!=list.end(); j++) @@ -1723,7 +1722,8 @@ MapSector * ServerMap::emergeSector(v2s16 p2d) //hm->generateContinued(0.5, 0.2, corners); //hm->generateContinued(1.0, 0.2, corners); //hm->generateContinued(2.0, 0.2, corners); - hm->generateContinued(2.0 * avgslope, 0.5, corners); + //hm->generateContinued(2.0 * avgslope, 0.5, corners); + hm->generateContinued(avgslope * MAP_BLOCKSIZE/8, 0.5, corners); //hm->print(); } @@ -1735,6 +1735,8 @@ MapSector * ServerMap::emergeSector(v2s16 p2d) core::map *objects = new core::map; sector->setObjects(objects); + float area = MAP_BLOCKSIZE * MAP_BLOCKSIZE; + /* Plant some trees if there is not much slope */ @@ -1742,7 +1744,7 @@ MapSector * ServerMap::emergeSector(v2s16 p2d) // Avgslope is the derivative of a hill //float t = avgslope * avgslope; float t = avgslope; - float a = MAP_BLOCKSIZE * m_params.plants_amount * local_plants_amount; + float a = area/16 * m_params.plants_amount * local_plants_amount; u32 tree_max; //float something = 0.17*0.17; float something = 0.3; @@ -1770,7 +1772,7 @@ MapSector * ServerMap::emergeSector(v2s16 p2d) { // Pitness usually goes at around -0.5...0.5 u32 bush_max = 0; - u32 a = MAP_BLOCKSIZE * 3.0 * m_params.plants_amount * local_plants_amount; + u32 a = area/16 * 3.0 * m_params.plants_amount * local_plants_amount; if(pitness > 0) bush_max = (pitness*a*4); if(bush_max > a) @@ -1910,9 +1912,10 @@ MapBlock * ServerMap::emergeBlock( block->unDummify(); } - u8 water_material = CONTENT_WATER; + /*u8 water_material = CONTENT_WATER; if(g_settings.getBool("endless_water")) - water_material = CONTENT_OCEAN; + water_material = CONTENT_WATERSOURCE;*/ + u8 water_material = CONTENT_WATERSOURCE; s32 lowest_ground_y = 32767; s32 highest_ground_y = -32768; @@ -2732,7 +2735,8 @@ continue_generating: /* Debug mode operation */ - if(HAXMODE) + bool haxmode = g_settings.getBool("haxmode"); + if(haxmode) { // Don't calculate lighting at all lighting_invalidated_blocks.clear(); @@ -3624,7 +3628,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass) <<", rendered "<setTempMod(relpos, mod); + if(blockref->setTempMod(relpos, mod)) + { + if(changed != NULL) + *changed = true; + } } return getNodeBlockPos(p); } -v3s16 ClientMap::clearTempMod(v3s16 p) +v3s16 ClientMap::clearTempMod(v3s16 p, bool *changed) { v3s16 dirs[7] = { v3s16(0,0,0), // this @@ -3673,7 +3681,11 @@ v3s16 ClientMap::clearTempMod(v3s16 p) continue; // Relative position of requested node v3s16 relpos = p - blockpos*MAP_BLOCKSIZE; - blockref->clearTempMod(relpos); + if(blockref->clearTempMod(relpos)) + { + if(changed != NULL) + *changed = true; + } } return getNodeBlockPos(p); } diff --git a/src/map.h b/src/map.h index d858a990..5cee3b7c 100644 --- a/src/map.h +++ b/src/map.h @@ -41,110 +41,14 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "constants.h" #include "voxel.h" -class CacheLock -{ -public: - CacheLock() - { - m_count = 0; - m_count_mutex.Init(); - m_cache_mutex.Init(); - m_waitcache_mutex.Init(); - } - - void cacheCreated() - { - //dstream<<"cacheCreated() begin"< 0); - - m_count--; - - // If this is the last one, release the cache lock - if(m_count == 0) - m_cache_mutex.Unlock(); - - //dstream<<"cacheRemoved() end"< m_sectors; - JMutex m_sector_mutex; - - v3f m_camera_position; - v3f m_camera_direction; - JMutex m_camera_mutex; - - // Be sure to set this to NULL when the cached sector is deleted - MapSector *m_sector_cache; - v2s16 m_sector_cache_p; - - WrapperHeightmap m_hwrapper; - public: - v3s16 drawoffset; // for drawbox() - - /* - Used by MapBlockPointerCache. - - waitCaches() can be called to remove all caches before continuing - - TODO: Remove this, MapBlockPointerCache doesn't exist anymore, - because it doesn't give any speed benefits - */ - CacheLock m_blockcachelock; - Map(std::ostream &dout); virtual ~Map(); @@ -170,23 +74,6 @@ public: m_camera_direction = dir; } - /*void StartUpdater() - { - updater.Start(); - } - - void StopUpdater() - { - updater.setRun(false); - while(updater.IsRunning()) - sleep_s(1); - } - - bool UpdaterIsRunning() - { - return updater.IsRunning(); - }*/ - static core::aabbox3d getNodeBox(v3s16 p) { return core::aabbox3d( @@ -349,6 +236,30 @@ public: // For debug printing virtual void PrintInfo(std::ostream &out); + + /* + Variables + */ + +protected: + + std::ostream &m_dout; + + core::map m_sectors; + JMutex m_sector_mutex; + + v3f m_camera_position; + v3f m_camera_direction; + JMutex m_camera_mutex; + + // Be sure to set this to NULL when the cached sector is deleted + MapSector *m_sector_cache; + v2s16 m_sector_cache_p; + + WrapperHeightmap m_hwrapper; + + // Queued transforming water nodes + UniqueQueue m_transforming_liquid; }; // Master heightmap parameters @@ -572,8 +483,8 @@ public: drawing. Return value is position of changed block. */ - v3s16 setTempMod(v3s16 p, NodeMod mod); - v3s16 clearTempMod(v3s16 p); + v3s16 setTempMod(v3s16 p, NodeMod mod, bool *changed=NULL); + v3s16 clearTempMod(v3s16 p, bool *changed=NULL); // Efficient implementation needs a cache of TempMods //void clearTempMods(); diff --git a/src/mapblock.cpp b/src/mapblock.cpp index 9f91f058..cf9114b2 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -570,8 +570,9 @@ void MapBlock::updateMesh(u32 daynight_ratio) } #endif - // 4-21ms - //TimeTaker timer1("updateMesh()", g_device); + // 4-21ms for MAP_BLOCKSIZE=16 + // 24-155ms for MAP_BLOCKSIZE=32 + //TimeTaker timer1("updateMesh()"); core::array fastfaces_new; @@ -691,7 +692,7 @@ void MapBlock::updateMesh(u32 daynight_ratio) // This will lead to infinite memory usage because or irrlicht. //mesh_new->setHardwareMappingHint(scene::EHM_STATIC); - /*std::cout<<"MapBlock has "<getSize()<<" faces " + /*std::cout<<"MapBlock has "<getMeshBufferCount() <<" materials (meshbuffers)"< & light_sources, else { MapNode n = getNode(v3s16(x, MAP_BLOCKSIZE-1, z)); - if(n.d == CONTENT_WATER || n.d == CONTENT_OCEAN) + if(n.d == CONTENT_WATER || n.d == CONTENT_WATERSOURCE) { no_sunlight = true; } } - // NOTE: As of now, it just would make everything dark. + // NOTE: As of now, this just would make everything dark. // No sunlight here //no_sunlight = true; } diff --git a/src/mapblock.h b/src/mapblock.h index b3fa76bb..e4f93a03 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -32,8 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mapblockobject.h" #include "voxel.h" -#define MAP_BLOCKSIZE 16 - // Named by looking towards z+ enum{ FACE_BACK=0, @@ -64,6 +62,10 @@ struct NodeMod type = a_type; param = a_param; } + bool operator==(const NodeMod &other) + { + return (type == other.type && param == other.param); + } enum NodeModType type; u16 param; }; @@ -393,8 +395,10 @@ public: /* Methods for setting temporary modifications to nodes for drawing + + returns true if the mod was different last time */ - void setTempMod(v3s16 p, NodeMod mod) + bool setTempMod(v3s16 p, NodeMod mod) { /*dstream<<"setTempMod called on block" <<" ("< &dirs) +{ + if(b & DIR_PX) + dirs.push_back(v3s16(1,0,0)); + if(b & DIR_NX) + dirs.push_back(v3s16(-1,0,0)); + if(b & DIR_PZ) + dirs.push_back(v3s16(0,0,1)); + if(b & DIR_NZ) + dirs.push_back(v3s16(0,0,-1)); + if(b & DIR_PY) + dirs.push_back(v3s16(0,1,0)); + if(b & DIR_NY) + dirs.push_back(v3s16(0,-1,0)); +} + +inline u8 encode_dirs(core::list &dirs) +{ + u8 b = 0; + for(core::list::Iterator + i = dirs.begin(); + i != dirs.end(); i++) + { + if(*i == v3s16(1,0,0)) + b += DIR_PX; + else if(*i == v3s16(-1,0,0)) + b += DIR_NX; + else if(*i == v3s16(0,0,1)) + b += DIR_PZ; + else if(*i == v3s16(0,0,-1)) + b += DIR_NZ; + else if(*i == v3s16(0,1,0)) + b += DIR_PY; + else if(*i == v3s16(0,-1,0)) + b += DIR_NY; + } + return b; +} +#endif + struct MapNode { // Content @@ -303,6 +343,7 @@ struct MapNode - For light_propagates() blocks, this is light intensity, stored logarithmically from 0 to LIGHT_MAX. Sunlight is LIGHT_SUN, which is LIGHT_MAX+1. + - Contains 2 values, day- and night lighting. Each takes 4 bits. */ s8 param; @@ -315,7 +356,7 @@ struct MapNode /* Direction for torches and other stuff. - If possible, packed with packDir. + Format is freeform. e.g. packDir or encode_dirs can be used. */ u8 dir; }; diff --git a/src/mapsector.h b/src/mapsector.h index b5768811..0c32e260 100644 --- a/src/mapsector.h +++ b/src/mapsector.h @@ -39,7 +39,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #define SECTOR_OBJECT_BUSH_1 2 #define SECTOR_OBJECT_RAVINE 3 -#define MAPSECTOR_FIXEDHEIGHTMAPS_MAXCOUNT 4 +//#define MAPSECTOR_FIXEDHEIGHTMAPS_MAXCOUNT 4 +#define MAPSECTOR_FIXEDHEIGHTMAPS_MAXCOUNT \ + (SECTOR_HEIGHTMAP_SPLIT * SECTOR_HEIGHTMAP_SPLIT) #define MAPSECTOR_SERVER 0 #define MAPSECTOR_CLIENT 1 diff --git a/src/player.cpp b/src/player.cpp index 72e44f0e..bb25015b 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -223,8 +223,10 @@ void LocalPlayer::move(f32 dtime, Map &map) position += m_speed * dtime; + bool haxmode = g_settings.getBool("haxmode"); + // Skip collision detection if player is non-local - if(isLocal() == false || HAXMODE) + if(isLocal() == false || haxmode) { setPosition(position); return; @@ -389,7 +391,9 @@ void LocalPlayer::applyControl(float dtime) v3f speed = v3f(0,0,0); - if(HAXMODE) + bool haxmode = g_settings.getBool("haxmode"); + + if(haxmode) { v3f speed = getSpeed(); speed.Y = 0; @@ -400,7 +404,7 @@ void LocalPlayer::applyControl(float dtime) bool superspeed = false; if(control.superspeed) { - if(HAXMODE) + if(haxmode) { v3f speed = getSpeed(); speed.Y = -20*BS; @@ -413,7 +417,7 @@ void LocalPlayer::applyControl(float dtime) } } - if(HAXMODE) + if(haxmode) superspeed = true; if(control.up) @@ -434,7 +438,7 @@ void LocalPlayer::applyControl(float dtime) } if(control.jump) { - if(HAXMODE) + if(haxmode) { v3f speed = getSpeed(); /*speed.Y += 20.*BS * dtime * 2; @@ -465,7 +469,7 @@ void LocalPlayer::applyControl(float dtime) f32 inc = walk_acceleration * BS * dtime; - if(HAXMODE) + if(haxmode) inc = walk_acceleration * BS * dtime * 10; // Accelerate to target speed with maximum increment diff --git a/src/server.cpp b/src/server.cpp index 3b3dfb65..312e2b6d 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -163,7 +163,8 @@ void * EmergeThread::Thread() only_from_disk, changed_blocks, lighting_invalidated_blocks); - + +#if 0 /* EXPERIMENTAL: Create a few other blocks too */ @@ -179,7 +180,7 @@ void * EmergeThread::Thread() only_from_disk, changed_blocks, lighting_invalidated_blocks); - +#endif } // If it is a dummy, block was not found on disk @@ -211,6 +212,7 @@ void * EmergeThread::Thread() dout_server<getKey(); //m_server->UpdateBlockWaterPressure(p, modified_blocks); } +#endif /* Collect a list of blocks that have been modified in @@ -318,6 +321,8 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime, } } + bool haxmode = g_settings.getBool("haxmode"); + Player *player = server->m_env.getPlayer(peer_id); assert(player != NULL); @@ -491,7 +496,7 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime, bool generate = d <= d_max_gen; - if(HAXMODE) + if(haxmode) { // Don't generate above player if(p.Y > center.Y) @@ -523,7 +528,7 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime, continue; } - if(HAXMODE) + if(haxmode) { /* Ignore block if it is not at ground surface @@ -868,12 +873,12 @@ void RemoteClient::GotBlock(v3s16 p) void RemoteClient::SentBlock(v3s16 p) { JMutexAutoLock lock(m_blocks_sending_mutex); - if(m_blocks_sending.size() > 15) + /*if(m_blocks_sending.size() > 15) { dstream<<"RemoteClient::SentBlock(): " <<"m_blocks_sending.size()=" < &modified_blocks) { @@ -3251,6 +3267,7 @@ void Server::UpdateBlockWaterPressure(MapBlock *block, v.blitBack(modified_blocks); } +#endif void Server::handlePeerChange(PeerChange &c) { diff --git a/src/server.h b/src/server.h index 3d7d133f..a1c4a1cd 100644 --- a/src/server.h +++ b/src/server.h @@ -449,8 +449,8 @@ private: environment has to be locked when calling. */ - void UpdateBlockWaterPressure(MapBlock *block, - core::map &modified_blocks); + /*void UpdateBlockWaterPressure(MapBlock *block, + core::map &modified_blocks);*/ // Locks environment and connection by its own struct PeerChange; @@ -481,7 +481,7 @@ private: BlockEmergeQueue m_emerge_queue; // Nodes that are destinations of flowing liquid at the moment - core::map m_flow_active_nodes; + //core::map m_flow_active_nodes; // 0-23999 MutexedVariable m_time_of_day; diff --git a/src/utility.cpp b/src/utility.cpp index 6f16b765..3aa397e9 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "utility.h" #include "irrlichtwrapper.h" #include "gettime.h" -#include "mapblock.h" TimeTaker::TimeTaker(const char *name, u32 *result) { diff --git a/src/utility.h b/src/utility.h index c4f45ba0..a38d15f3 100644 --- a/src/utility.h +++ b/src/utility.h @@ -1580,6 +1580,47 @@ private: bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 range); +/* + Queue with unique values with fast checking of value existence +*/ + +template +class UniqueQueue +{ +public: + + /* + Does nothing if value is already queued. + Return value: + true: value added + false: value already exists + */ + bool push_back(Value value) + { + // Check if already exists + if(m_map.find(value) != NULL) + return false; + + // Add + m_map.insert(value, 0); + m_list.push_back(value); + + return true; + } + + void pop_front() + { + typename core::list::Iterator i = m_list.begin(); + Value value = *i; + m_map.remove(value); + m_list.erase(i); + return value; + } + +private: + core::map m_map; + core::list m_list; +}; #endif diff --git a/src/voxel.cpp b/src/voxel.cpp index 2fd4e7b4..7ba4e21c 100644 --- a/src/voxel.cpp +++ b/src/voxel.cpp @@ -221,71 +221,6 @@ void VoxelManipulator::copyFrom(MapNode *src, VoxelArea src_area, } } -void VoxelManipulator::interpolate(VoxelArea area) -{ - VoxelArea emerge_area = area; - emerge_area.MinEdge -= v3s16(1,1,1); - emerge_area.MaxEdge += v3s16(1,1,1); - emerge(emerge_area); - - SharedBuffer buf(area.getVolume()); - - for(s32 z=area.MinEdge.Z; z<=area.MaxEdge.Z; z++) - for(s32 y=area.MinEdge.Y; y<=area.MaxEdge.Y; y++) - for(s32 x=area.MinEdge.X; x<=area.MaxEdge.X; x++) - { - v3s16 p(x,y,z); - - v3s16 dirs[] = { - v3s16(1,1,0), - v3s16(1,0,1), - v3s16(1,-1,0), - v3s16(1,0,-1), - v3s16(-1,1,0), - v3s16(-1,0,1), - v3s16(-1,-1,0), - v3s16(-1,0,-1), - }; - //const v3s16 *dirs = g_26dirs; - - s16 total = 0; - s16 airness = 0; - u8 m = CONTENT_IGNORE; - - for(s16 i=0; i<8; i++) - //for(s16 i=0; i<26; i++) - { - v3s16 p2 = p + dirs[i]; - - u8 f = m_flags[m_area.index(p2)]; - assert(!(f & VOXELFLAG_NOT_LOADED)); - if(f & VOXELFLAG_INEXISTENT) - continue; - - MapNode &n = m_data[m_area.index(p2)]; - - airness += (n.d == CONTENT_AIR) ? 1 : -1; - total++; - - if(m == CONTENT_IGNORE && n.d != CONTENT_AIR) - m = n.d; - } - - // 1 if air, 0 if not - buf[area.index(p)] = airness > -total/2 ? CONTENT_AIR : m; - //buf[area.index(p)] = airness > -total ? CONTENT_AIR : m; - //buf[area.index(p)] = airness >= -7 ? CONTENT_AIR : m; - } - - for(s32 z=area.MinEdge.Z; z<=area.MaxEdge.Z; z++) - for(s32 y=area.MinEdge.Y; y<=area.MaxEdge.Y; y++) - for(s32 x=area.MinEdge.X; x<=area.MaxEdge.X; x++) - { - v3s16 p(x,y,z); - m_data[m_area.index(p)].d = buf[area.index(p)]; - } -} - void VoxelManipulator::clearFlag(u8 flags) { @@ -373,7 +308,7 @@ int VoxelManipulator::getWaterPressure(v3s16 p, s16 &highest_y, int recur_count) int pr; // If at ocean surface - if(n.pressure == 1 && n.d == CONTENT_OCEAN) + if(n.pressure == 1 && n.d == CONTENT_WATERSOURCE) //if(n.pressure == 1) // Causes glitches but is fast { pr = 1; @@ -718,7 +653,7 @@ bool VoxelManipulator::flowWater(v3s16 removed_pos, u8 m = m_data[m_area.index(p)].d; u8 f = m_flags[m_area.index(p)]; - if(m == CONTENT_OCEAN) + if(m == CONTENT_WATERSOURCE) from_ocean = true; // Move air bubble if not taking water from ocean @@ -751,7 +686,7 @@ bool VoxelManipulator::flowWater(v3s16 removed_pos, /* NOTE: This does not work as-is - if(m == CONTENT_OCEAN) + if(m == CONTENT_WATERSOURCE) { // If block was raised to surface, increase pressure of // source node diff --git a/src/voxel.h b/src/voxel.h index a90fc37e..ed7fba08 100644 --- a/src/voxel.h +++ b/src/voxel.h @@ -395,8 +395,6 @@ public: Algorithms */ - void interpolate(VoxelArea area); - void clearFlag(u8 flag); // VOXELFLAG_CHECKED2s must usually be cleared before calling -- 2.30.2