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() { return "MinimapUpdateThread"; }
109 virtual void doUpdate();
112 JMutex m_queue_mutex;
113 std::deque<QueuedMinimapUpdate> m_update_queue;
114 std::map<v3s16, MinimapMapblock *> m_blocks_cache;
119 Mapper(IrrlichtDevice *device, Client *client);
122 void addBlock(v3s16 pos, MinimapMapblock *data);
125 MinimapMode getMinimapMode();
127 void setPos(v3s16 pos);
128 void setAngle(f32 angle);
129 void setMinimapMode(MinimapMode mode);
130 void toggleMinimapShape();
133 video::ITexture *getMinimapTexture();
135 void blitMinimapPixelsToImageRadar(video::IImage *map_image);
136 void blitMinimapPixelsToImageSurface(video::IImage *map_image,
137 video::IImage *heightmap_image);
139 scene::SMeshBuffer *getMinimapMeshBuffer();
142 video::IVideoDriver *driver;
146 ITextureSource *m_tsrc;
147 IShaderSource *m_shdrsrc;
148 INodeDefManager *m_ndef;
149 MinimapUpdateThread *m_minimap_update_thread;
150 scene::SMeshBuffer *m_meshbuffer;
151 bool m_enable_shaders;
152 u16 m_surface_mode_scan_height;