Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
minimap.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2010-2015 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include "../hud.h"
9#include "irr_ptr.h"
10#include "util/thread.h"
11#include "voxel.h"
12#include <map>
13#include <string>
14#include <vector>
15
16class Client;
17class ITextureSource;
18class IShaderSource;
19
20#define MINIMAP_MAX_SX 512
21#define MINIMAP_MAX_SY 512
22
27
30 std::string label;
33 std::string texture;
34 u16 scale;
35};
36
38 MinimapMarker(scene::ISceneNode *parent_node):
40 {
41 }
42 scene::ISceneNode *parent_node;
43};
50
56
64 video::IImage *minimap_mask_round = nullptr;
65 video::IImage *minimap_mask_square = nullptr;
66 video::ITexture *texture = nullptr;
67 video::ITexture *heightmap_texture = nullptr;
68 bool textures_initialised = false; // True if the following textures are not nullptrs.
69 video::ITexture *minimap_overlay_round = nullptr;
70 video::ITexture *minimap_overlay_square = nullptr;
71 video::ITexture *player_marker = nullptr;
72 video::ITexture *object_marker_red = nullptr;
73};
74
79
81public:
83 virtual ~MinimapUpdateThread();
84
85 void getMap(v3s16 pos, s16 size, s16 height);
89
90 MinimapData *data = nullptr;
91
92protected:
93 virtual void doUpdate();
94
95private:
96 std::mutex m_queue_mutex;
97 std::deque<QueuedMinimapUpdate> m_update_queue;
98 std::map<v3s16, MinimapMapblock *> m_blocks_cache;
99};
100
101class Minimap {
102public:
104 ~Minimap();
105
107
108 v3f getYawVec();
109
110 void setPos(v3s16 pos);
111 v3s16 getPos() const { return data->pos; }
112 void setAngle(f32 angle);
113 f32 getAngle() const { return m_angle; }
114 void toggleMinimapShape();
115 void setMinimapShape(MinimapShape shape);
117
118 void clearModes() { m_modes.clear(); };
119 void addMode(MinimapModeDef mode);
120 void addMode(MinimapType type, u16 size = 0, const std::string &label = "",
121 const std::string &texture = "", u16 scale = 1);
122
123 void setModeIndex(size_t index);
124 size_t getModeIndex() const { return m_current_mode_index; };
125 size_t getMaxModeIndex() const { return m_modes.size() - 1; };
126 void nextMode();
127
128 MinimapModeDef getModeDef() const { return data->mode; }
129
130 video::IImage *getMinimapMask();
131 video::ITexture *getMinimapTexture();
132
133 void blitMinimapPixelsToImageRadar(video::IImage *map_image);
134 void blitMinimapPixelsToImageSurface(video::IImage *map_image,
135 video::IImage *heightmap_image);
136
137 irr_ptr<scene::SMeshBuffer> createMinimapMeshBuffer();
138
139 MinimapMarker* addMarker(scene::ISceneNode *parent_node);
140 void removeMarker(MinimapMarker **marker);
141
142 void updateActiveMarkers();
143 void drawMinimap(core::rect<s32> rect);
144
145 video::IVideoDriver *driver;
147 std::unique_ptr<MinimapData> data;
148
149private:
153 std::unique_ptr<MinimapUpdateThread> m_minimap_update_thread;
154 irr_ptr<scene::SMeshBuffer> m_meshbuffer;
155 std::vector<MinimapModeDef> m_modes;
159 std::mutex m_mutex;
160 std::list<std::unique_ptr<MinimapMarker>> m_markers;
161 std::list<v2f> m_active_markers;
162};
Definition client.h:105
Definition shader.h:201
Definition texturesource.h:36
Definition minimap.h:80
void enqueueBlock(v3s16 pos, MinimapMapblock *data)
Definition minimap.cpp:67
virtual void doUpdate()
Definition minimap.cpp:74
virtual ~MinimapUpdateThread()
Definition minimap.cpp:20
bool popBlockUpdate(QueuedMinimapUpdate *update)
Definition minimap.cpp:54
std::deque< QueuedMinimapUpdate > m_update_queue
Definition minimap.h:97
MinimapData * data
Definition minimap.h:90
std::mutex m_queue_mutex
Definition minimap.h:96
bool pushBlockUpdate(v3s16 pos, MinimapMapblock *data)
Definition minimap.cpp:31
std::map< v3s16, MinimapMapblock * > m_blocks_cache
Definition minimap.h:98
void getMap(v3s16 pos, s16 size, s16 height)
Definition minimap.cpp:106
MinimapUpdateThread()
Definition minimap.h:82
Definition minimap.h:101
ITextureSource * m_tsrc
Definition minimap.h:150
Client * client
Definition minimap.h:146
size_t getModeIndex() const
Definition minimap.h:124
std::mutex m_mutex
Definition minimap.h:159
video::IVideoDriver * driver
Definition minimap.h:145
void addBlock(v3s16 pos, MinimapMapblock *data)
Definition minimap.cpp:226
std::unique_ptr< MinimapData > data
Definition minimap.h:147
void setMinimapShape(MinimapShape shape)
Definition minimap.cpp:240
void blitMinimapPixelsToImageRadar(video::IImage *map_image)
Definition minimap.cpp:383
void setModeIndex(size_t index)
Definition minimap.cpp:262
~Minimap()
Definition minimap.cpp:205
std::unique_ptr< MinimapUpdateThread > m_minimap_update_thread
Definition minimap.h:153
std::list< std::unique_ptr< MinimapMarker > > m_markers
Definition minimap.h:160
void addMode(MinimapModeDef mode)
Definition minimap.cpp:280
size_t m_current_mode_index
Definition minimap.h:156
v3s16 getPos() const
Definition minimap.h:111
MinimapShape getMinimapShape()
Definition minimap.cpp:253
video::ITexture * getMinimapTexture()
Definition minimap.cpp:453
void setPos(v3s16 pos)
Definition minimap.cpp:360
void removeMarker(MinimapMarker **marker)
Definition minimap.cpp:680
IShaderSource * m_shdrsrc
Definition minimap.h:151
MinimapMarker * addMarker(scene::ISceneNode *parent_node)
Definition minimap.cpp:672
size_t getMaxModeIndex() const
Definition minimap.h:125
v3f getYawVec()
Definition minimap.cpp:526
const NodeDefManager * m_ndef
Definition minimap.h:152
std::vector< MinimapModeDef > m_modes
Definition minimap.h:155
f32 getAngle() const
Definition minimap.h:113
Minimap(Client *client)
Definition minimap.cpp:164
void nextMode()
Definition minimap.cpp:349
void blitMinimapPixelsToImageSurface(video::IImage *map_image, video::IImage *heightmap_image)
Definition minimap.cpp:399
f32 m_angle
Definition minimap.h:158
video::IImage * getMinimapMask()
Definition minimap.cpp:430
void toggleMinimapShape()
Definition minimap.cpp:231
void setAngle(f32 angle)
Definition minimap.cpp:378
MinimapModeDef getModeDef() const
Definition minimap.h:128
void clearModes()
Definition minimap.h:118
void drawMinimap(core::rect< s32 > rect)
Definition minimap.cpp:563
u16 m_surface_mode_scan_height
Definition minimap.h:157
irr_ptr< scene::SMeshBuffer > m_meshbuffer
Definition minimap.h:154
std::list< v2f > m_active_markers
Definition minimap.h:161
void updateActiveMarkers()
Definition minimap.cpp:686
irr_ptr< scene::SMeshBuffer > createMinimapMeshBuffer()
Definition minimap.cpp:538
This class is for getting the actual properties of nodes from their content ID.
Definition nodedef.h:540
Definition thread.h:174
Definition voxel.h:360
#define MAP_BLOCKSIZE
Definition constants.h:64
MinimapType
Definition hud.h:108
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
core::vector3df v3f
Definition irr_v3d.h:11
MinimapShape
Definition minimap.h:23
@ MINIMAP_SHAPE_SQUARE
Definition minimap.h:24
@ MINIMAP_SHAPE_ROUND
Definition minimap.h:25
#define MINIMAP_MAX_SY
Definition minimap.h:21
#define MINIMAP_MAX_SX
Definition minimap.h:20
Definition activeobjectmgr.cpp:11
Definition mapnode.h:124
Definition minimap.h:57
MinimapPixel minimap_scan[MINIMAP_MAX_SX *MINIMAP_MAX_SY]
Definition minimap.h:61
video::ITexture * minimap_overlay_square
Definition minimap.h:70
video::IImage * minimap_mask_square
Definition minimap.h:65
v3s16 old_pos
Definition minimap.h:60
video::ITexture * minimap_overlay_round
Definition minimap.h:69
video::ITexture * object_marker_red
Definition minimap.h:72
MinimapModeDef mode
Definition minimap.h:58
video::ITexture * texture
Definition minimap.h:66
bool textures_initialised
Definition minimap.h:68
video::ITexture * heightmap_texture
Definition minimap.h:67
video::ITexture * player_marker
Definition minimap.h:71
video::IImage * minimap_mask_round
Definition minimap.h:64
bool map_invalidated
Definition minimap.h:62
v3s16 pos
Definition minimap.h:59
bool minimap_shape_round
Definition minimap.h:63
Definition minimap.h:51
void getMinimapNodes(VoxelManipulator *vmanip, const v3s16 &pos)
Definition minimap.cpp:720
MinimapPixel data[MAP_BLOCKSIZE *MAP_BLOCKSIZE]
Definition minimap.h:54
Definition minimap.h:37
scene::ISceneNode * parent_node
Definition minimap.h:42
MinimapMarker(scene::ISceneNode *parent_node)
Definition minimap.h:38
Definition minimap.h:28
MinimapType type
Definition minimap.h:29
u16 scale
Definition minimap.h:34
std::string label
Definition minimap.h:30
u16 map_size
Definition minimap.h:32
std::string texture
Definition minimap.h:33
u16 scan_height
Definition minimap.h:31
Definition minimap.h:44
u16 height
Definition minimap.h:47
u16 air_count
Definition minimap.h:48
MapNode n
The topmost node that the minimap displays.
Definition minimap.h:46
Definition minimap.h:75
v3s16 pos
Definition minimap.h:76
MinimapMapblock * data
Definition minimap.h:77