Minimap update

This commit is contained in:
RealBadAngel 2015-06-28 12:17:36 +02:00
parent 420125debd
commit b160f8dfe7
5 changed files with 31 additions and 11 deletions

View File

@ -266,6 +266,14 @@
#enable_mesh_cache = true #enable_mesh_cache = true
# Enables caching of facedir rotated meshes # 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 # The time in seconds it takes between repeated
# right clicks when holding the right mouse button. # right clicks when holding the right mouse button.
#repeat_rightclick_time = 0.25 #repeat_rightclick_time = 0.25

View File

@ -179,6 +179,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("enable_minimap", "true"); settings->setDefault("enable_minimap", "true");
settings->setDefault("minimap_shape_round", "true"); settings->setDefault("minimap_shape_round", "true");
settings->setDefault("minimap_double_scan_height", "true");
settings->setDefault("curl_timeout", "5000"); settings->setDefault("curl_timeout", "5000");
settings->setDefault("curl_parallel_limit", "8"); settings->setDefault("curl_parallel_limit", "8");

View File

@ -164,6 +164,15 @@ void *MinimapUpdateThread::Thread()
return NULL; 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) MinimapPixel *MinimapUpdateThread::getMinimapPixel (v3s16 pos, s16 height, s16 &pixel_height)
{ {
pixel_height = height - MAP_BLOCKSIZE; pixel_height = height - MAP_BLOCKSIZE;
@ -236,6 +245,12 @@ Mapper::Mapper(IrrlichtDevice *device, Client *client)
this->shdrsrc = client->getShaderSource(); this->shdrsrc = client->getShaderSource();
m_enable_shaders = g_settings->getBool("enable_shaders"); 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 = new MinimapData;
data->mode = MINIMAP_MODE_OFF; data->mode = MINIMAP_MODE_OFF;
data->radar = false; data->radar = false;
@ -265,13 +280,6 @@ Mapper::~Mapper()
{ {
m_minimap_update_thread->Stop(); m_minimap_update_thread->Stop();
m_minimap_update_thread->Wait(); 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(); m_meshbuffer->drop();
data->minimap_mask_round->drop(); data->minimap_mask_round->drop();
data->minimap_mask_square->drop(); data->minimap_mask_square->drop();
@ -303,9 +311,9 @@ void Mapper::setMinimapMode(MinimapMode mode)
{ {
static const u16 modeDefs[7 * 3] = { static const u16 modeDefs[7 * 3] = {
0, 0, 0, 0, 0, 0,
0, 256, 256, 0, m_surface_mode_scan_height, 256,
0, 256, 128, 0, m_surface_mode_scan_height, 128,
0, 256, 64, 0, m_surface_mode_scan_height, 64,
1, 32, 128, 1, 32, 128,
1, 32, 64, 1, 32, 64,
1, 32, 32}; 1, 32, 32};

View File

@ -124,6 +124,7 @@ public:
this->driver = device->getVideoDriver(); this->driver = device->getVideoDriver();
this->tsrc = client->getTextureSource(); this->tsrc = client->getTextureSource();
} }
~MinimapUpdateThread();
void getMap (v3s16 pos, s16 size, s16 height, bool radar); void getMap (v3s16 pos, s16 size, s16 height, bool radar);
MinimapPixel *getMinimapPixel (v3s16 pos, s16 height, s16 &pixel_height); MinimapPixel *getMinimapPixel (v3s16 pos, s16 height, s16 &pixel_height);
s16 getAirCount (v3s16 pos, s16 height); s16 getAirCount (v3s16 pos, s16 height);
@ -148,6 +149,7 @@ private:
video::ITexture *minimap_texture; video::ITexture *minimap_texture;
scene::SMeshBuffer *m_meshbuffer; scene::SMeshBuffer *m_meshbuffer;
bool m_enable_shaders; bool m_enable_shaders;
u16 m_surface_mode_scan_height;
JMutex m_mutex; JMutex m_mutex;
public: public:

View File

@ -787,6 +787,7 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef,
bool enable_bumpmapping = g_settings->getBool("enable_bumpmapping"); bool enable_bumpmapping = g_settings->getBool("enable_bumpmapping");
bool enable_parallax_occlusion = g_settings->getBool("enable_parallax_occlusion"); bool enable_parallax_occlusion = g_settings->getBool("enable_parallax_occlusion");
bool enable_mesh_cache = g_settings->getBool("enable_mesh_cache"); bool enable_mesh_cache = g_settings->getBool("enable_mesh_cache");
bool enable_minimap = g_settings->getBool("enable_minimap");
bool use_normal_texture = enable_shaders && bool use_normal_texture = enable_shaders &&
(enable_bumpmapping || enable_parallax_occlusion); (enable_bumpmapping || enable_parallax_occlusion);
@ -797,7 +798,7 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef,
ContentFeatures *f = &m_content_features[i]; ContentFeatures *f = &m_content_features[i];
// minimap pixel color - the average color of a texture // 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); f->minimap_color = tsrc->getTextureAverageColor(f->tiledef[0].name);
// Figure out the actual tiles to use // Figure out the actual tiles to use