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 "threading/mutex.h"
27 #include "threading/semaphore.h"
33 #define MINIMAP_MAX_SX 512
34 #define MINIMAP_MAX_SY 512
39 MINIMAP_MODE_SURFACEx1,
40 MINIMAP_MODE_SURFACEx2,
41 MINIMAP_MODE_SURFACEx4,
48 struct MinimapModeDef {
55 //! The topmost node that the minimap displays.
61 struct MinimapMapblock {
62 void getMinimapNodes(VoxelManipulator *vmanip, v3s16 pos);
64 MinimapPixel data[MAP_BLOCKSIZE * MAP_BLOCKSIZE];
74 MinimapPixel minimap_scan[MINIMAP_MAX_SX * MINIMAP_MAX_SY];
76 bool minimap_shape_round;
77 video::IImage *minimap_image;
78 video::IImage *heightmap_image;
79 video::IImage *minimap_mask_round;
80 video::IImage *minimap_mask_square;
81 video::ITexture *texture;
82 video::ITexture *heightmap_texture;
83 video::ITexture *minimap_overlay_round;
84 video::ITexture *minimap_overlay_square;
85 video::ITexture *player_marker;
86 video::ITexture *object_marker_red;
89 struct QueuedMinimapUpdate {
91 MinimapMapblock *data;
94 class MinimapUpdateThread : public UpdateThread {
96 MinimapUpdateThread() : UpdateThread("Minimap") {}
97 virtual ~MinimapUpdateThread();
99 void getMap(v3s16 pos, s16 size, s16 height, bool radar);
100 MinimapPixel *getMinimapPixel(v3s16 pos, s16 height, s16 *pixel_height);
101 s16 getAirCount(v3s16 pos, s16 height);
102 video::SColor getColorFromId(u16 id);
104 void enqueueBlock(v3s16 pos, MinimapMapblock *data);
106 bool pushBlockUpdate(v3s16 pos, MinimapMapblock *data);
107 bool popBlockUpdate(QueuedMinimapUpdate *update);
112 virtual void doUpdate();
116 std::deque<QueuedMinimapUpdate> m_update_queue;
117 std::map<v3s16, MinimapMapblock *> m_blocks_cache;
122 Mapper(IrrlichtDevice *device, Client *client);
125 void addBlock(v3s16 pos, MinimapMapblock *data);
128 MinimapMode getMinimapMode();
130 void setPos(v3s16 pos);
131 void setAngle(f32 angle);
132 void setMinimapMode(MinimapMode mode);
133 void toggleMinimapShape();
136 video::ITexture *getMinimapTexture();
138 void blitMinimapPixelsToImageRadar(video::IImage *map_image);
139 void blitMinimapPixelsToImageSurface(video::IImage *map_image,
140 video::IImage *heightmap_image);
142 scene::SMeshBuffer *getMinimapMeshBuffer();
144 void updateActiveMarkers();
147 video::IVideoDriver *driver;
152 ITextureSource *m_tsrc;
153 IShaderSource *m_shdrsrc;
154 INodeDefManager *m_ndef;
155 MinimapUpdateThread *m_minimap_update_thread;
156 scene::SMeshBuffer *m_meshbuffer;
157 bool m_enable_shaders;
158 u16 m_surface_mode_scan_height;
161 std::list<v2f> m_active_markers;