3 Copyright (C) 2010-2015 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef MINIMAP_HEADER
21 #define MINIMAP_HEADER
23 #include "irrlichttypes_extrabloated.h"
26 #include "jthread/jmutex.h"
27 #include "jthread/jsemaphore.h"
34 MINIMAP_MODE_SURFACEx1,
35 MINIMAP_MODE_SURFACEx2,
36 MINIMAP_MODE_SURFACEx4,
50 struct MinimapMapblock
52 MinimapPixel data[MAP_BLOCKSIZE * MAP_BLOCKSIZE];
63 MinimapPixel minimap_scan[512 * 512];
65 bool minimap_shape_round;
66 video::IImage *minimap_image;
67 video::IImage *heightmap_image;
68 video::IImage *minimap_mask_round;
69 video::IImage *minimap_mask_square;
70 video::ITexture *texture;
71 video::ITexture *heightmap_texture;
72 video::ITexture *minimap_overlay_round;
73 video::ITexture *minimap_overlay_square;
74 video::ITexture *player_marker;
77 struct QueuedMinimapUpdate
80 MinimapMapblock *data;
82 QueuedMinimapUpdate();
83 ~QueuedMinimapUpdate();
87 A thread-safe queue of minimap mapblocks update tasks
90 class MinimapUpdateQueue
95 ~MinimapUpdateQueue();
97 bool addBlock(v3s16 pos, MinimapMapblock *data);
99 QueuedMinimapUpdate *pop();
103 JMutexAutoLock lock(m_mutex);
104 return m_queue.size();
108 std::list<QueuedMinimapUpdate*> m_queue;
112 class MinimapUpdateThread : public UpdateThread
115 MinimapUpdateQueue m_queue;
116 std::map<v3s16, MinimapMapblock *> m_blocks_cache;
119 const char *getName()
120 { return "MinimapUpdateThread"; }
121 virtual void doUpdate();
124 MinimapUpdateThread(IrrlichtDevice *device, Client *client)
126 this->device = device;
127 this->client = client;
128 this->driver = device->getVideoDriver();
129 this->tsrc = client->getTextureSource();
131 ~MinimapUpdateThread();
132 void getMap (v3s16 pos, s16 size, s16 height, bool radar);
133 MinimapPixel *getMinimapPixel (v3s16 pos, s16 height, s16 &pixel_height);
134 s16 getAirCount (v3s16 pos, s16 height);
135 video::SColor getColorFromId(u16 id);
137 void enqueue_Block(v3s16 pos, MinimapMapblock *data);
138 IrrlichtDevice *device;
140 video::IVideoDriver *driver;
141 ITextureSource *tsrc;
148 MinimapUpdateThread *m_minimap_update_thread;
149 video::ITexture *minimap_texture;
150 scene::SMeshBuffer *m_meshbuffer;
151 bool m_enable_shaders;
152 u16 m_surface_mode_scan_height;
156 Mapper(IrrlichtDevice *device, Client *client);
159 void addBlock(v3s16 pos, MinimapMapblock *data);
160 void setPos(v3s16 pos);
161 video::ITexture* getMinimapTexture();
163 MinimapMode getMinimapMode();
164 void setMinimapMode(MinimapMode mode);
165 void toggleMinimapShape();
166 scene::SMeshBuffer *getMinimapMeshBuffer();
168 IrrlichtDevice *device;
170 video::IVideoDriver *driver;
172 ITextureSource *tsrc;
173 IShaderSource *shdrsrc;