Minimap update
authorRealBadAngel <maciej.kasatkin@o2.pl>
Sun, 28 Jun 2015 10:17:36 +0000 (12:17 +0200)
committerRealBadAngel <maciej.kasatkin@o2.pl>
Sun, 28 Jun 2015 10:17:36 +0000 (12:17 +0200)
minetest.conf.example
src/defaultsettings.cpp
src/minimap.cpp
src/minimap.h
src/nodedef.cpp

index d1f1de6fb89a00aa11ba8e8a5aedbe7785d77a0e..6aaae2b14699126aa989cbd20bba0c5af7f78ce0 100644 (file)
 #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
index 73e36da98f68b8680f275a492d82b37b1d4cd8d9..ecd89242b4594e5fd8619e5d7d3dba47d5679a6d 100644 (file)
@@ -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");
index 753468c32425c952bd19c7c6bf4749e3dd3c631e..9adeb84bca2e44ac1a7ee57beeaef8f667f3a14c 100644 (file)
@@ -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;
@@ -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;
@@ -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();
@@ -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};
index 1794da1907b9d24c6de437e08473d005b7a4a34a..220c3add0794585613c8cea9b289205c30be0ee6 100644 (file)
@@ -124,6 +124,7 @@ public:
                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);
@@ -148,6 +149,7 @@ private:
        video::ITexture *minimap_texture;
        scene::SMeshBuffer *m_meshbuffer;
        bool m_enable_shaders;
+       u16 m_surface_mode_scan_height;
        JMutex m_mutex;
 
 public:
index ba1ca2c65ad2162a887a403e5254069a47f66058..e392f477ab2c3ad9db1881574585e861773c6902 100644 (file)
@@ -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);
@@ -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