Minetest 5.10.0-dev
 
Loading...
Searching...
No Matches
minimap.h
Go to the documentation of this file.
1/*
2Minetest
3Copyright (C) 2010-2015 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation; either version 2.1 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU Lesser General Public License for more details.
14
15You should have received a copy of the GNU Lesser General Public License along
16with this program; if not, write to the Free Software Foundation, Inc.,
1751 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18*/
19
20#pragma once
21
22#include "../hud.h"
24#include "util/thread.h"
25#include "voxel.h"
26#include <map>
27#include <string>
28#include <vector>
29
30class Client;
31class ITextureSource;
32class IShaderSource;
33
34#define MINIMAP_MAX_SX 512
35#define MINIMAP_MAX_SY 512
36
41
44 std::string label;
47 std::string texture;
48 u16 scale;
49};
50
52 MinimapMarker(scene::ISceneNode *parent_node):
54 {
55 }
56 scene::ISceneNode *parent_node;
57};
64
70
78 video::IImage *minimap_mask_round = nullptr;
79 video::IImage *minimap_mask_square = nullptr;
80 video::ITexture *texture = nullptr;
81 video::ITexture *heightmap_texture = nullptr;
82 bool textures_initialised = false; // True if the following textures are not nullptrs.
83 video::ITexture *minimap_overlay_round = nullptr;
84 video::ITexture *minimap_overlay_square = nullptr;
85 video::ITexture *player_marker = nullptr;
86 video::ITexture *object_marker_red = nullptr;
87};
88
93
95public:
97 virtual ~MinimapUpdateThread();
98
99 void getMap(v3s16 pos, s16 size, s16 height);
103
104 MinimapData *data = nullptr;
105
106protected:
107 virtual void doUpdate();
108
109private:
110 std::mutex m_queue_mutex;
111 std::deque<QueuedMinimapUpdate> m_update_queue;
112 std::map<v3s16, MinimapMapblock *> m_blocks_cache;
113};
114
115class Minimap {
116public:
118 ~Minimap();
119
121
122 v3f getYawVec();
123
124 void setPos(v3s16 pos);
125 v3s16 getPos() const { return data->pos; }
126 void setAngle(f32 angle);
127 f32 getAngle() const { return m_angle; }
128 void toggleMinimapShape();
129 void setMinimapShape(MinimapShape shape);
131
132 void clearModes() { m_modes.clear(); };
133 void addMode(MinimapModeDef mode);
134 void addMode(MinimapType type, u16 size = 0, const std::string &label = "",
135 const std::string &texture = "", u16 scale = 1);
136
137 void setModeIndex(size_t index);
138 size_t getModeIndex() const { return m_current_mode_index; };
139 size_t getMaxModeIndex() const { return m_modes.size() - 1; };
140 void nextMode();
141
142 MinimapModeDef getModeDef() const { return data->mode; }
143
144 video::IImage *getMinimapMask();
145 video::ITexture *getMinimapTexture();
146
147 void blitMinimapPixelsToImageRadar(video::IImage *map_image);
148 void blitMinimapPixelsToImageSurface(video::IImage *map_image,
149 video::IImage *heightmap_image);
150
151 scene::SMeshBuffer *getMinimapMeshBuffer();
152
153 MinimapMarker* addMarker(scene::ISceneNode *parent_node);
154 void removeMarker(MinimapMarker **marker);
155
156 void updateActiveMarkers();
157 void drawMinimap(core::rect<s32> rect);
158
159 video::IVideoDriver *driver;
162
163private:
168 scene::SMeshBuffer *m_meshbuffer;
170 std::vector<MinimapModeDef> m_modes;
174 std::mutex m_mutex;
175 std::list<MinimapMarker*> m_markers;
176 std::list<v2f> m_active_markers;
177};
Definition client.h:119
Definition shader.h:216
Definition texturesource.h:45
Definition minimap.h:94
void enqueueBlock(v3s16 pos, MinimapMapblock *data)
Definition minimap.cpp:81
virtual void doUpdate()
Definition minimap.cpp:88
virtual ~MinimapUpdateThread()
Definition minimap.cpp:34
bool popBlockUpdate(QueuedMinimapUpdate *update)
Definition minimap.cpp:68
std::deque< QueuedMinimapUpdate > m_update_queue
Definition minimap.h:111
MinimapData * data
Definition minimap.h:104
std::mutex m_queue_mutex
Definition minimap.h:110
bool pushBlockUpdate(v3s16 pos, MinimapMapblock *data)
Definition minimap.cpp:45
std::map< v3s16, MinimapMapblock * > m_blocks_cache
Definition minimap.h:112
void getMap(v3s16 pos, s16 size, s16 height)
Definition minimap.cpp:120
MinimapUpdateThread()
Definition minimap.h:96
Definition minimap.h:115
ITextureSource * m_tsrc
Definition minimap.h:164
Client * client
Definition minimap.h:160
std::list< MinimapMarker * > m_markers
Definition minimap.h:175
size_t getModeIndex() const
Definition minimap.h:138
std::mutex m_mutex
Definition minimap.h:174
MinimapUpdateThread * m_minimap_update_thread
Definition minimap.h:167
video::IVideoDriver * driver
Definition minimap.h:159
bool m_enable_shaders
Definition minimap.h:169
void addBlock(v3s16 pos, MinimapMapblock *data)
Definition minimap.cpp:243
void setMinimapShape(MinimapShape shape)
Definition minimap.cpp:257
void blitMinimapPixelsToImageRadar(video::IImage *map_image)
Definition minimap.cpp:400
void setModeIndex(size_t index)
Definition minimap.cpp:279
~Minimap()
Definition minimap.cpp:220
void addMode(MinimapModeDef mode)
Definition minimap.cpp:297
size_t m_current_mode_index
Definition minimap.h:171
scene::SMeshBuffer * m_meshbuffer
Definition minimap.h:168
v3s16 getPos() const
Definition minimap.h:125
MinimapShape getMinimapShape()
Definition minimap.cpp:270
video::ITexture * getMinimapTexture()
Definition minimap.cpp:470
void setPos(v3s16 pos)
Definition minimap.cpp:377
void removeMarker(MinimapMarker **marker)
Definition minimap.cpp:695
IShaderSource * m_shdrsrc
Definition minimap.h:165
MinimapMarker * addMarker(scene::ISceneNode *parent_node)
Definition minimap.cpp:688
size_t getMaxModeIndex() const
Definition minimap.h:139
v3f getYawVec()
Definition minimap.cpp:543
const NodeDefManager * m_ndef
Definition minimap.h:166
std::vector< MinimapModeDef > m_modes
Definition minimap.h:170
f32 getAngle() const
Definition minimap.h:127
MinimapData * data
Definition minimap.h:161
Minimap(Client *client)
Definition minimap.cpp:178
scene::SMeshBuffer * getMinimapMeshBuffer()
Definition minimap.cpp:555
void nextMode()
Definition minimap.cpp:366
void blitMinimapPixelsToImageSurface(video::IImage *map_image, video::IImage *heightmap_image)
Definition minimap.cpp:416
f32 m_angle
Definition minimap.h:173
video::IImage * getMinimapMask()
Definition minimap.cpp:447
void toggleMinimapShape()
Definition minimap.cpp:248
void setAngle(f32 angle)
Definition minimap.cpp:395
MinimapModeDef getModeDef() const
Definition minimap.h:142
void clearModes()
Definition minimap.h:132
void drawMinimap(core::rect< s32 > rect)
Definition minimap.cpp:578
u16 m_surface_mode_scan_height
Definition minimap.h:172
std::list< v2f > m_active_markers
Definition minimap.h:176
void updateActiveMarkers()
Definition minimap.cpp:702
This class is for getting the actual properties of nodes from their content ID.
Definition nodedef.h:556
Definition thread.h:189
Definition voxel.h:381
#define MAP_BLOCKSIZE
Definition constants.h:79
MinimapType
Definition hud.h:123
core::vector3d< s16 > v3s16
Definition irr_v3d.h:28
core::vector3df v3f
Definition irr_v3d.h:26
MinimapShape
Definition minimap.h:37
@ MINIMAP_SHAPE_SQUARE
Definition minimap.h:38
@ MINIMAP_SHAPE_ROUND
Definition minimap.h:39
#define MINIMAP_MAX_SY
Definition minimap.h:35
#define MINIMAP_MAX_SX
Definition minimap.h:34
Definition activeobjectmgr.cpp:26
Definition mapnode.h:139
Definition minimap.h:71
MinimapPixel minimap_scan[MINIMAP_MAX_SX *MINIMAP_MAX_SY]
Definition minimap.h:75
video::ITexture * minimap_overlay_square
Definition minimap.h:84
video::IImage * minimap_mask_square
Definition minimap.h:79
v3s16 old_pos
Definition minimap.h:74
video::ITexture * minimap_overlay_round
Definition minimap.h:83
video::ITexture * object_marker_red
Definition minimap.h:86
MinimapModeDef mode
Definition minimap.h:72
video::ITexture * texture
Definition minimap.h:80
bool textures_initialised
Definition minimap.h:82
video::ITexture * heightmap_texture
Definition minimap.h:81
video::ITexture * player_marker
Definition minimap.h:85
video::IImage * minimap_mask_round
Definition minimap.h:78
bool map_invalidated
Definition minimap.h:76
v3s16 pos
Definition minimap.h:73
bool minimap_shape_round
Definition minimap.h:77
Definition minimap.h:65
void getMinimapNodes(VoxelManipulator *vmanip, const v3s16 &pos)
Definition minimap.cpp:736
MinimapPixel data[MAP_BLOCKSIZE *MAP_BLOCKSIZE]
Definition minimap.h:68
Definition minimap.h:51
scene::ISceneNode * parent_node
Definition minimap.h:56
MinimapMarker(scene::ISceneNode *parent_node)
Definition minimap.h:52
Definition minimap.h:42
MinimapType type
Definition minimap.h:43
u16 scale
Definition minimap.h:48
std::string label
Definition minimap.h:44
u16 map_size
Definition minimap.h:46
std::string texture
Definition minimap.h:47
u16 scan_height
Definition minimap.h:45
Definition minimap.h:58
u16 height
Definition minimap.h:61
u16 air_count
Definition minimap.h:62
MapNode n
The topmost node that the minimap displays.
Definition minimap.h:60
Definition minimap.h:89
v3s16 pos
Definition minimap.h:90
MinimapMapblock * data
Definition minimap.h:91