summaryrefslogtreecommitdiff
path: root/src/mapblock_mesh.cpp
diff options
context:
space:
mode:
authorRealBadAngel <maciej.kasatkin@o2.pl>2015-06-22 04:34:56 +0200
committerest31 <MTest31@outlook.com>2015-06-27 03:42:01 +0200
commitffd16e3feca90c356c55898de2b9f3f5c6bc5c98 (patch)
tree8fb350ba1d2afaa39b9d333290e16a68168a4ddd /src/mapblock_mesh.cpp
parent3376d2e114767eef06b87645edefcd2d42696919 (diff)
downloadminetest-ffd16e3feca90c356c55898de2b9f3f5c6bc5c98.tar.gz
minetest-ffd16e3feca90c356c55898de2b9f3f5c6bc5c98.tar.bz2
minetest-ffd16e3feca90c356c55898de2b9f3f5c6bc5c98.zip
Add minimap feature
Diffstat (limited to 'src/mapblock_mesh.cpp')
-rw-r--r--src/mapblock_mesh.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp
index 79e3e81ba..0e4831166 100644
--- a/src/mapblock_mesh.cpp
+++ b/src/mapblock_mesh.cpp
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h"
#include "gamedef.h"
#include "mesh.h"
+#include "minimap.h"
#include "content_mapblock.h"
#include "noise.h"
#include "shader.h"
@@ -1028,6 +1029,7 @@ static void updateAllFastFaceRows(MeshMakeData *data,
MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
m_mesh(new scene::SMesh()),
+ m_minimap_mapblock(new MinimapMapblock),
m_gamedef(data->m_gamedef),
m_tsrc(m_gamedef->getTextureSource()),
m_shdrsrc(m_gamedef->getShaderSource()),
@@ -1041,6 +1043,32 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
m_enable_shaders = data->m_use_shaders;
m_enable_highlighting = g_settings->getBool("enable_node_highlighting");
+ if (g_settings->getBool("enable_minimap")) {
+ v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE;
+ for(s16 x = 0; x < MAP_BLOCKSIZE; x++) {
+ for(s16 z = 0; z < MAP_BLOCKSIZE; z++) {
+ s16 air_count = 0;
+ bool surface_found = false;
+ MinimapPixel* minimap_pixel = &m_minimap_mapblock->data[x + z * MAP_BLOCKSIZE];
+ for(s16 y = MAP_BLOCKSIZE -1; y > -1; y--) {
+ v3s16 p(x, y, z);
+ MapNode n = data->m_vmanip.getNodeNoEx(blockpos_nodes + p);
+ if (!surface_found && n.getContent() != CONTENT_AIR) {
+ minimap_pixel->height = y;
+ minimap_pixel->id = n.getContent();
+ surface_found = true;
+ } else if (n.getContent() == CONTENT_AIR) {
+ air_count++;
+ }
+ }
+ if (!surface_found) {
+ minimap_pixel->id = CONTENT_AIR;
+ }
+ minimap_pixel->air_count = air_count;
+ }
+ }
+ }
+
// 4-21ms for MAP_BLOCKSIZE=16 (NOTE: probably outdated)
// 24-155ms for MAP_BLOCKSIZE=32 (NOTE: probably outdated)
//TimeTaker timer1("MapBlockMesh()");