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"
33 MINIMAP_MODE_SURFACEx1,
34 MINIMAP_MODE_SURFACEx2,
35 MINIMAP_MODE_SURFACEx4,
49 struct MinimapMapblock
51 MinimapPixel data[MAP_BLOCKSIZE * MAP_BLOCKSIZE];
62 MinimapPixel minimap_scan[512 * 512];
64 bool minimap_shape_round;
65 video::IImage *minimap_image;
66 video::IImage *heightmap_image;
67 video::IImage *minimap_mask_round;
68 video::IImage *minimap_mask_square;
69 video::ITexture *texture;
70 video::ITexture *heightmap_texture;
71 video::ITexture *minimap_overlay_round;
72 video::ITexture *minimap_overlay_square;
73 video::ITexture *player_marker;
76 struct QueuedMinimapUpdate
79 MinimapMapblock *data;
81 QueuedMinimapUpdate();
82 ~QueuedMinimapUpdate();
86 A thread-safe queue of minimap mapblocks update tasks
89 class MinimapUpdateQueue
94 ~MinimapUpdateQueue();
96 void addBlock(v3s16 pos, MinimapMapblock *data);
98 QueuedMinimapUpdate *pop();
102 JMutexAutoLock lock(m_mutex);
103 return m_queue.size();
107 std::vector<QueuedMinimapUpdate*> m_queue;
111 class MinimapUpdateThread : public JThread
116 MinimapUpdateThread(IrrlichtDevice *device, Client *client)
118 this->device = device;
119 this->client = client;
120 this->driver = device->getVideoDriver();
121 this->tsrc = client->getTextureSource();
123 void getMap (v3s16 pos, s16 size, s16 height, bool radar);
124 MinimapPixel *getMinimapPixel (v3s16 pos, s16 height, s16 &pixel_height);
125 s16 getAirCount (v3s16 pos, s16 height);
126 video::SColor getColorFromId(u16 id);
127 IrrlichtDevice *device;
129 video::IVideoDriver *driver;
130 ITextureSource *tsrc;
133 MinimapUpdateQueue m_queue;
134 std::map<v3s16, MinimapMapblock *> m_blocks_cache;
140 MinimapUpdateThread *m_minimap_update_thread;
141 video::ITexture *minimap_texture;
142 scene::SMeshBuffer *m_meshbuffer;
143 bool m_enable_shaders;
147 Mapper(IrrlichtDevice *device, Client *client);
150 void addBlock(v3s16 pos, MinimapMapblock *data);
151 void setPos(v3s16 pos);
152 video::ITexture* getMinimapTexture();
154 MinimapMode getMinimapMode();
155 void setMinimapMode(MinimapMode mode);
156 void toggleMinimapShape();
157 scene::SMeshBuffer *getMinimapMeshBuffer();
159 IrrlichtDevice *device;
161 video::IVideoDriver *driver;
163 ITextureSource *tsrc;
164 IShaderSource *shdrsrc;