mirror of
https://github.com/minetest/minetest.git
synced 2024-12-23 14:42:24 +01:00
Add more neighbors on mesh update (#6765)
This commit is contained in:
parent
481bb90eac
commit
9b650b9efb
@ -475,6 +475,10 @@ connected_glass (Connect glass) bool false
|
||||
# Disable for speed or for different looks.
|
||||
smooth_lighting (Smooth lighting) bool true
|
||||
|
||||
# Enables tradeoffs that reduce CPU load or increase rendering performance
|
||||
# at the expense of minor visual glitches that do not impact game playability.
|
||||
performance_tradeoffs (Tradeoffs for performance) bool false
|
||||
|
||||
# Clouds are a client side effect.
|
||||
enable_clouds (Clouds) bool true
|
||||
|
||||
|
@ -1611,20 +1611,7 @@ void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server, bool urgent)
|
||||
|
||||
void Client::addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server, bool urgent)
|
||||
{
|
||||
try{
|
||||
addUpdateMeshTask(blockpos, ack_to_server, urgent);
|
||||
}
|
||||
catch(InvalidPositionException &e){}
|
||||
|
||||
// Leading edge
|
||||
for (int i=0;i<6;i++)
|
||||
{
|
||||
try{
|
||||
v3s16 p = blockpos + g_6dirs[i];
|
||||
addUpdateMeshTask(p, false, urgent);
|
||||
}
|
||||
catch(InvalidPositionException &e){}
|
||||
}
|
||||
m_mesh_update_thread.updateBlock(&m_env.getMap(), blockpos, ack_to_server, urgent, true);
|
||||
}
|
||||
|
||||
void Client::addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server, bool urgent)
|
||||
@ -1636,38 +1623,16 @@ void Client::addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server, bool ur
|
||||
<<std::endl;
|
||||
}
|
||||
|
||||
v3s16 blockpos = getNodeBlockPos(nodepos);
|
||||
v3s16 blockpos = getNodeBlockPos(nodepos);
|
||||
v3s16 blockpos_relative = blockpos * MAP_BLOCKSIZE;
|
||||
|
||||
try{
|
||||
addUpdateMeshTask(blockpos, ack_to_server, urgent);
|
||||
}
|
||||
catch(InvalidPositionException &e) {}
|
||||
|
||||
m_mesh_update_thread.updateBlock(&m_env.getMap(), blockpos, ack_to_server, urgent, false);
|
||||
// Leading edge
|
||||
if(nodepos.X == blockpos_relative.X){
|
||||
try{
|
||||
v3s16 p = blockpos + v3s16(-1,0,0);
|
||||
addUpdateMeshTask(p, false, urgent);
|
||||
}
|
||||
catch(InvalidPositionException &e){}
|
||||
}
|
||||
|
||||
if(nodepos.Y == blockpos_relative.Y){
|
||||
try{
|
||||
v3s16 p = blockpos + v3s16(0,-1,0);
|
||||
addUpdateMeshTask(p, false, urgent);
|
||||
}
|
||||
catch(InvalidPositionException &e){}
|
||||
}
|
||||
|
||||
if(nodepos.Z == blockpos_relative.Z){
|
||||
try{
|
||||
v3s16 p = blockpos + v3s16(0,0,-1);
|
||||
addUpdateMeshTask(p, false, urgent);
|
||||
}
|
||||
catch(InvalidPositionException &e){}
|
||||
}
|
||||
if (nodepos.X == blockpos_relative.X)
|
||||
addUpdateMeshTask(blockpos + v3s16(-1, 0, 0), false, urgent);
|
||||
if (nodepos.Y == blockpos_relative.Y)
|
||||
addUpdateMeshTask(blockpos + v3s16(0, -1, 0), false, urgent);
|
||||
if (nodepos.Z == blockpos_relative.Z)
|
||||
addUpdateMeshTask(blockpos + v3s16(0, 0, -1), false, urgent);
|
||||
}
|
||||
|
||||
ClientEvent *Client::getClientEvent()
|
||||
|
@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "client.h"
|
||||
#include "mapblock.h"
|
||||
#include "map.h"
|
||||
#include "util/directiontables.h"
|
||||
|
||||
/*
|
||||
CachedMapBlockData
|
||||
@ -69,7 +70,7 @@ MeshUpdateQueue::~MeshUpdateQueue()
|
||||
}
|
||||
}
|
||||
|
||||
void MeshUpdateQueue::addBlock(Map *map, v3s16 p, bool ack_block_to_server, bool urgent)
|
||||
bool MeshUpdateQueue::addBlock(Map *map, v3s16 p, bool ack_block_to_server, bool urgent)
|
||||
{
|
||||
MutexAutoLock lock(m_mutex);
|
||||
|
||||
@ -81,20 +82,15 @@ void MeshUpdateQueue::addBlock(Map *map, v3s16 p, bool ack_block_to_server, bool
|
||||
*/
|
||||
std::vector<CachedMapBlockData*> cached_blocks;
|
||||
size_t cache_hit_counter = 0;
|
||||
CachedMapBlockData *cached_block = cacheBlock(map, p, FORCE_UPDATE);
|
||||
if (!cached_block->data)
|
||||
return false; // nothing to update
|
||||
cached_blocks.reserve(3*3*3);
|
||||
v3s16 dp;
|
||||
for (dp.X = -1; dp.X <= 1; dp.X++)
|
||||
for (dp.Y = -1; dp.Y <= 1; dp.Y++)
|
||||
for (dp.Z = -1; dp.Z <= 1; dp.Z++) {
|
||||
v3s16 p1 = p + dp;
|
||||
CachedMapBlockData *cached_block;
|
||||
if (dp == v3s16(0, 0, 0))
|
||||
cached_block = cacheBlock(map, p1, FORCE_UPDATE);
|
||||
else
|
||||
cached_block = cacheBlock(map, p1, SKIP_UPDATE_IF_ALREADY_CACHED,
|
||||
&cache_hit_counter);
|
||||
cached_blocks.push_back(cached_block);
|
||||
}
|
||||
cached_blocks.push_back(cached_block);
|
||||
for (v3s16 dp : g_26dirs)
|
||||
cached_blocks.push_back(cacheBlock(map, p + dp,
|
||||
SKIP_UPDATE_IF_ALREADY_CACHED,
|
||||
&cache_hit_counter));
|
||||
g_profiler->avg("MeshUpdateQueue: MapBlocks from cache [%]",
|
||||
100.0f * cache_hit_counter / cached_blocks.size());
|
||||
|
||||
@ -116,7 +112,7 @@ void MeshUpdateQueue::addBlock(Map *map, v3s16 p, bool ack_block_to_server, bool
|
||||
q->ack_block_to_server = true;
|
||||
q->crack_level = m_client->getCrackLevel();
|
||||
q->crack_pos = m_client->getCrackPos();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,6 +130,7 @@ void MeshUpdateQueue::addBlock(Map *map, v3s16 p, bool ack_block_to_server, bool
|
||||
for (CachedMapBlockData *cached_block : cached_blocks) {
|
||||
cached_block->refcount_from_queue++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returned pointer must be deleted
|
||||
@ -212,10 +209,7 @@ void MeshUpdateQueue::fillDataFromMapBlockCache(QueuedMeshUpdate *q)
|
||||
std::time_t t_now = std::time(0);
|
||||
|
||||
// Collect data for 3*3*3 blocks from cache
|
||||
v3s16 dp;
|
||||
for (dp.X = -1; dp.X <= 1; dp.X++)
|
||||
for (dp.Y = -1; dp.Y <= 1; dp.Y++)
|
||||
for (dp.Z = -1; dp.Z <= 1; dp.Z++) {
|
||||
for (v3s16 dp : g_27dirs) {
|
||||
v3s16 p = q->p + dp;
|
||||
CachedMapBlockData *cached_block = getCachedBlock(p);
|
||||
if (cached_block) {
|
||||
@ -272,10 +266,25 @@ MeshUpdateThread::MeshUpdateThread(Client *client):
|
||||
}
|
||||
|
||||
void MeshUpdateThread::updateBlock(Map *map, v3s16 p, bool ack_block_to_server,
|
||||
bool urgent)
|
||||
bool urgent, bool update_neighbors)
|
||||
{
|
||||
// Allow the MeshUpdateQueue to do whatever it wants
|
||||
m_queue_in.addBlock(map, p, ack_block_to_server, urgent);
|
||||
static thread_local const bool many_neighbors =
|
||||
g_settings->getBool("smooth_lighting")
|
||||
&& !g_settings->getFlag("performance_tradeoffs");
|
||||
if (!m_queue_in.addBlock(map, p, ack_block_to_server, urgent)) {
|
||||
warningstream << "Update requested for non-existent block at ("
|
||||
<< p.X << ", " << p.Y << ", " << p.Z << ")" << std::endl;
|
||||
return;
|
||||
}
|
||||
if (update_neighbors) {
|
||||
if (many_neighbors) {
|
||||
for (v3s16 dp : g_26dirs)
|
||||
m_queue_in.addBlock(map, p + dp, false, urgent);
|
||||
} else {
|
||||
for (v3s16 dp : g_6dirs)
|
||||
m_queue_in.addBlock(map, p + dp, false, urgent);
|
||||
}
|
||||
}
|
||||
deferUpdate();
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
|
||||
// Caches the block at p and its neighbors (if needed) and queues a mesh
|
||||
// update for the block at p
|
||||
void addBlock(Map *map, v3s16 p, bool ack_block_to_server, bool urgent);
|
||||
bool addBlock(Map *map, v3s16 p, bool ack_block_to_server, bool urgent);
|
||||
|
||||
// Returned pointer must be deleted
|
||||
// Returns NULL if queue is empty
|
||||
@ -113,7 +113,8 @@ public:
|
||||
|
||||
// Caches the block at p and its neighbors (if needed) and queues a mesh
|
||||
// update for the block at p
|
||||
void updateBlock(Map *map, v3s16 p, bool ack_block_to_server, bool urgent);
|
||||
void updateBlock(Map *map, v3s16 p, bool ack_block_to_server, bool urgent,
|
||||
bool update_neighbors = false);
|
||||
|
||||
v3s16 m_camera_offset;
|
||||
MutexedQueue<MeshUpdateResult> m_queue_out;
|
||||
|
@ -184,6 +184,7 @@ void set_default_settings()
|
||||
settings->setDefault("leaves_style", "fancy");
|
||||
settings->setDefault("connected_glass", "false");
|
||||
settings->setDefault("smooth_lighting", "true");
|
||||
settings->setDefault("performance_tradeoffs", "false");
|
||||
settings->setDefault("lighting_alpha", "0.0");
|
||||
settings->setDefault("lighting_beta", "1.5");
|
||||
settings->setDefault("display_gamma", "1.0");
|
||||
@ -477,6 +478,7 @@ void set_default_settings()
|
||||
settings->setDefault("screen_h", "0");
|
||||
settings->setDefault("fullscreen", "true");
|
||||
settings->setDefault("smooth_lighting", "false");
|
||||
settings->setDefault("performance_tradeoffs", "true");
|
||||
settings->setDefault("max_simultaneous_block_sends_per_client", "10");
|
||||
settings->setDefault("emergequeue_limit_diskonly", "16");
|
||||
settings->setDefault("emergequeue_limit_generate", "16");
|
||||
|
Loading…
Reference in New Issue
Block a user