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
26 #include "irrlichttypes_extrabloated.h"
29 #include "jthread/jmutex.h"
30 #include "jthread/jsemaphore.h"
32 #define MINIMAP_MAX_SX 512
33 #define MINIMAP_MAX_SY 512
37 MINIMAP_MODE_SURFACEx1,
38 MINIMAP_MODE_SURFACEx2,
39 MINIMAP_MODE_SURFACEx4,
46 struct MinimapModeDef {
59 struct MinimapMapblock {
60 void getMinimapNodes(VoxelManipulator *vmanip, v3s16 pos);
62 MinimapPixel data[MAP_BLOCKSIZE * MAP_BLOCKSIZE];
72 MinimapPixel minimap_scan[MINIMAP_MAX_SX * MINIMAP_MAX_SY];
74 bool minimap_shape_round;
75 video::IImage *minimap_image;
76 video::IImage *heightmap_image;
77 video::IImage *minimap_mask_round;
78 video::IImage *minimap_mask_square;
79 video::ITexture *texture;
80 video::ITexture *heightmap_texture;
81 video::ITexture *minimap_overlay_round;
82 video::ITexture *minimap_overlay_square;
83 video::ITexture *player_marker;
86 struct QueuedMinimapUpdate {
88 MinimapMapblock *data;
91 class MinimapUpdateThread : public UpdateThread {
93 virtual ~MinimapUpdateThread();
95 void getMap(v3s16 pos, s16 size, s16 height, bool radar);
96 MinimapPixel *getMinimapPixel(v3s16 pos, s16 height, s16 *pixel_height);
97 s16 getAirCount(v3s16 pos, s16 height);
98 video::SColor getColorFromId(u16 id);
100 void enqueueBlock(v3s16 pos, MinimapMapblock *data);
102 bool pushBlockUpdate(v3s16 pos, MinimapMapblock *data);
103 bool popBlockUpdate(QueuedMinimapUpdate *update);
108 const char *getName()
110 return "MinimapUpdateThread";
113 virtual void doUpdate();
116 JMutex m_queue_mutex;
117 std::deque<QueuedMinimapUpdate> m_update_queue;
118 std::map<v3s16, MinimapMapblock *> m_blocks_cache;
123 Mapper(IrrlichtDevice *device, Client *client);
126 void addBlock(v3s16 pos, MinimapMapblock *data);
129 MinimapMode getMinimapMode();
131 void setPos(v3s16 pos);
132 void setAngle(f32 angle);
133 void setMinimapMode(MinimapMode mode);
134 void toggleMinimapShape();
137 video::ITexture *getMinimapTexture();
139 void blitMinimapPixelsToImageRadar(video::IImage *map_image);
140 void blitMinimapPixelsToImageSurface(video::IImage *map_image,
141 video::IImage *heightmap_image);
143 scene::SMeshBuffer *getMinimapMeshBuffer();
146 video::IVideoDriver *driver;
150 ITextureSource *m_tsrc;
151 IShaderSource *m_shdrsrc;
152 INodeDefManager *m_ndef;
153 MinimapUpdateThread *m_minimap_update_thread;
154 scene::SMeshBuffer *m_meshbuffer;
155 bool m_enable_shaders;
156 u16 m_surface_mode_scan_height;