Skip to content

Commit

Permalink
Minimap update
Browse files Browse the repository at this point in the history
  • Loading branch information
RealBadAngel committed Jun 28, 2015
1 parent 420125d commit b160f8d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
8 changes: 8 additions & 0 deletions minetest.conf.example
Expand Up @@ -266,6 +266,14 @@
#enable_mesh_cache = true
# Enables caching of facedir rotated meshes

#enable_minimap = true
# Enables minimap
#minimap_shape_round = true
# true - round shape, false - square
#minimap_double_scan_height = true
# true = 256, false = 128
# useable to make minimap smoother on slower machines

# The time in seconds it takes between repeated
# right clicks when holding the right mouse button.
#repeat_rightclick_time = 0.25
Expand Down
1 change: 1 addition & 0 deletions src/defaultsettings.cpp
Expand Up @@ -179,6 +179,7 @@ void set_default_settings(Settings *settings)

settings->setDefault("enable_minimap", "true");
settings->setDefault("minimap_shape_round", "true");
settings->setDefault("minimap_double_scan_height", "true");

settings->setDefault("curl_timeout", "5000");
settings->setDefault("curl_parallel_limit", "8");
Expand Down
28 changes: 18 additions & 10 deletions src/minimap.cpp
Expand Up @@ -164,6 +164,15 @@ void *MinimapUpdateThread::Thread()
return NULL;
}

MinimapUpdateThread::~MinimapUpdateThread()
{
for (std::map<v3s16, MinimapMapblock *>::iterator
it = m_blocks_cache.begin();
it != m_blocks_cache.end(); it++) {
delete it->second;
}
}

MinimapPixel *MinimapUpdateThread::getMinimapPixel (v3s16 pos, s16 height, s16 &pixel_height)
{
pixel_height = height - MAP_BLOCKSIZE;
Expand Down Expand Up @@ -236,6 +245,12 @@ Mapper::Mapper(IrrlichtDevice *device, Client *client)
this->shdrsrc = client->getShaderSource();

m_enable_shaders = g_settings->getBool("enable_shaders");
m_enable_shaders = g_settings->getBool("enable_shaders");
if (g_settings->getBool("minimap_double_scan_height")) {
m_surface_mode_scan_height = 256;
} else {
m_surface_mode_scan_height = 128;
}
data = new MinimapData;
data->mode = MINIMAP_MODE_OFF;
data->radar = false;
Expand Down Expand Up @@ -265,13 +280,6 @@ Mapper::~Mapper()
{
m_minimap_update_thread->Stop();
m_minimap_update_thread->Wait();

for (std::map<v3s16, MinimapMapblock *>::iterator
it = m_minimap_update_thread->m_blocks_cache.begin();
it != m_minimap_update_thread->m_blocks_cache.end(); it++){
delete it->second;
}

m_meshbuffer->drop();
data->minimap_mask_round->drop();
data->minimap_mask_square->drop();
Expand Down Expand Up @@ -303,9 +311,9 @@ void Mapper::setMinimapMode(MinimapMode mode)
{
static const u16 modeDefs[7 * 3] = {
0, 0, 0,
0, 256, 256,
0, 256, 128,
0, 256, 64,
0, m_surface_mode_scan_height, 256,
0, m_surface_mode_scan_height, 128,
0, m_surface_mode_scan_height, 64,
1, 32, 128,
1, 32, 64,
1, 32, 32};
Expand Down
2 changes: 2 additions & 0 deletions src/minimap.h
Expand Up @@ -124,6 +124,7 @@ class MinimapUpdateThread : public JThread
this->driver = device->getVideoDriver();
this->tsrc = client->getTextureSource();
}
~MinimapUpdateThread();
void getMap (v3s16 pos, s16 size, s16 height, bool radar);
MinimapPixel *getMinimapPixel (v3s16 pos, s16 height, s16 &pixel_height);
s16 getAirCount (v3s16 pos, s16 height);
Expand All @@ -148,6 +149,7 @@ class Mapper
video::ITexture *minimap_texture;
scene::SMeshBuffer *m_meshbuffer;
bool m_enable_shaders;
u16 m_surface_mode_scan_height;
JMutex m_mutex;

public:
Expand Down
3 changes: 2 additions & 1 deletion src/nodedef.cpp
Expand Up @@ -787,6 +787,7 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef,
bool enable_bumpmapping = g_settings->getBool("enable_bumpmapping");
bool enable_parallax_occlusion = g_settings->getBool("enable_parallax_occlusion");
bool enable_mesh_cache = g_settings->getBool("enable_mesh_cache");
bool enable_minimap = g_settings->getBool("enable_minimap");

bool use_normal_texture = enable_shaders &&
(enable_bumpmapping || enable_parallax_occlusion);
Expand All @@ -797,7 +798,7 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef,
ContentFeatures *f = &m_content_features[i];

// minimap pixel color - the average color of a texture
if (f->tiledef[0].name != "")
if (enable_minimap && f->tiledef[0].name != "")
f->minimap_color = tsrc->getTextureAverageColor(f->tiledef[0].name);

// Figure out the actual tiles to use
Expand Down

0 comments on commit b160f8d

Please sign in to comment.