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/semaphore.h"
32 #define MINIMAP_MAX_SX 512
33 #define MINIMAP_MAX_SY 512
38 MINIMAP_MODE_SURFACEx1,
39 MINIMAP_MODE_SURFACEx2,
40 MINIMAP_MODE_SURFACEx4,
52 struct MinimapModeDef {
59 //! The topmost node that the minimap displays.
65 struct MinimapMapblock {
66 void getMinimapNodes(VoxelManipulator *vmanip, v3s16 pos);
68 MinimapPixel data[MAP_BLOCKSIZE * MAP_BLOCKSIZE];
78 MinimapPixel minimap_scan[MINIMAP_MAX_SX * MINIMAP_MAX_SY];
80 bool minimap_shape_round;
81 video::IImage *minimap_mask_round = nullptr;
82 video::IImage *minimap_mask_square = nullptr;
83 video::ITexture *texture = nullptr;
84 video::ITexture *heightmap_texture = nullptr;
85 video::ITexture *minimap_overlay_round = nullptr;
86 video::ITexture *minimap_overlay_square = nullptr;
87 video::ITexture *player_marker = nullptr;
88 video::ITexture *object_marker_red = nullptr;
91 struct QueuedMinimapUpdate {
93 MinimapMapblock *data = nullptr;
96 class MinimapUpdateThread : public UpdateThread {
98 MinimapUpdateThread() : UpdateThread("Minimap") {}
99 virtual ~MinimapUpdateThread();
101 void getMap(v3s16 pos, s16 size, s16 height);
102 void enqueueBlock(v3s16 pos, MinimapMapblock *data);
103 bool pushBlockUpdate(v3s16 pos, MinimapMapblock *data);
104 bool popBlockUpdate(QueuedMinimapUpdate *update);
106 MinimapData *data = nullptr;
109 virtual void doUpdate();
112 std::mutex m_queue_mutex;
113 std::deque<QueuedMinimapUpdate> m_update_queue;
114 std::map<v3s16, MinimapMapblock *> m_blocks_cache;
119 Minimap(Client *client);
122 void addBlock(v3s16 pos, MinimapMapblock *data);
126 void setPos(v3s16 pos);
127 v3s16 getPos() const { return data->pos; }
128 void setAngle(f32 angle);
129 f32 getAngle() const { return m_angle; }
130 void setMinimapMode(MinimapMode mode);
131 MinimapMode getMinimapMode() const { return data->mode; }
132 void toggleMinimapShape();
133 void setMinimapShape(MinimapShape shape);
134 MinimapShape getMinimapShape();
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();
145 void updateActiveMarkers();
148 video::IVideoDriver *driver;
153 ITextureSource *m_tsrc;
154 IShaderSource *m_shdrsrc;
155 INodeDefManager *m_ndef;
156 MinimapUpdateThread *m_minimap_update_thread;
157 scene::SMeshBuffer *m_meshbuffer;
158 bool m_enable_shaders;
159 u16 m_surface_mode_scan_height;
162 std::list<v2f> m_active_markers;