mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add minimap feature
This commit is contained in:
parent
3376d2e114
commit
ffd16e3fec
23 changed files with 883 additions and 30 deletions
|
@ -34,6 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "porting.h"
|
||||
#include "mapblock_mesh.h"
|
||||
#include "mapblock.h"
|
||||
#include "minimap.h"
|
||||
#include "settings.h"
|
||||
#include "profiler.h"
|
||||
#include "gettext.h"
|
||||
|
@ -185,11 +186,6 @@ void * MeshUpdateThread::Thread()
|
|||
ScopeProfiler sp(g_profiler, "Client: Mesh making");
|
||||
|
||||
MapBlockMesh *mesh_new = new MapBlockMesh(q->data, m_camera_offset);
|
||||
if(mesh_new->getMesh()->getMeshBufferCount() == 0)
|
||||
{
|
||||
delete mesh_new;
|
||||
mesh_new = NULL;
|
||||
}
|
||||
|
||||
MeshUpdateResult r;
|
||||
r.p = q->p;
|
||||
|
@ -274,6 +270,7 @@ Client::Client(
|
|||
// Add local player
|
||||
m_env.addPlayer(new LocalPlayer(this, playername));
|
||||
|
||||
m_mapper = new Mapper(device, this);
|
||||
m_cache_save_interval = g_settings->getU16("server_map_save_interval");
|
||||
|
||||
m_cache_smooth_lighting = g_settings->getBool("smooth_lighting");
|
||||
|
@ -537,27 +534,37 @@ void Client::step(float dtime)
|
|||
*/
|
||||
{
|
||||
int num_processed_meshes = 0;
|
||||
while(!m_mesh_update_thread.m_queue_out.empty())
|
||||
while (!m_mesh_update_thread.m_queue_out.empty())
|
||||
{
|
||||
num_processed_meshes++;
|
||||
MeshUpdateResult r = m_mesh_update_thread.m_queue_out.pop_frontNoEx();
|
||||
MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(r.p);
|
||||
if(block) {
|
||||
MinimapMapblock *minimap_mapblock = NULL;
|
||||
if (block) {
|
||||
// Delete the old mesh
|
||||
if(block->mesh != NULL)
|
||||
{
|
||||
// TODO: Remove hardware buffers of meshbuffers of block->mesh
|
||||
if (block->mesh != NULL) {
|
||||
delete block->mesh;
|
||||
block->mesh = NULL;
|
||||
}
|
||||
|
||||
// Replace with the new mesh
|
||||
block->mesh = r.mesh;
|
||||
if (r.mesh)
|
||||
minimap_mapblock = r.mesh->getMinimapMapblock();
|
||||
|
||||
if (r.mesh && r.mesh->getMesh()->getMeshBufferCount() == 0) {
|
||||
delete r.mesh;
|
||||
block->mesh = NULL;
|
||||
} else {
|
||||
// Replace with the new mesh
|
||||
block->mesh = r.mesh;
|
||||
}
|
||||
} else {
|
||||
delete r.mesh;
|
||||
minimap_mapblock = NULL;
|
||||
}
|
||||
|
||||
if(r.ack_block_to_server) {
|
||||
m_mapper->addBlock(r.p, minimap_mapblock);
|
||||
|
||||
if (r.ack_block_to_server) {
|
||||
/*
|
||||
Acknowledge block
|
||||
[0] u8 count
|
||||
|
@ -567,7 +574,7 @@ void Client::step(float dtime)
|
|||
}
|
||||
}
|
||||
|
||||
if(num_processed_meshes > 0)
|
||||
if (num_processed_meshes > 0)
|
||||
g_profiler->graphAdd("num_processed_meshes", num_processed_meshes);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue