*/
#include "minimap.h"
-#include "threading/mutex_auto_lock.h"
-#include "threading/semaphore.h"
+#include "client.h"
#include "clientmap.h"
#include "settings.h"
-#include "nodedef.h"
-#include "porting.h"
-#include "util/numeric.h"
-#include "util/string.h"
+#include "shader.h"
#include "mapblock.h"
-#include <math.h>
+#include "client/renderingengine.h"
////
MinimapUpdateThread::~MinimapUpdateThread()
{
- for (std::map<v3s16, MinimapMapblock *>::iterator
- it = m_blocks_cache.begin();
- it != m_blocks_cache.end(); ++it) {
- delete it->second;
+ for (auto &it : m_blocks_cache) {
+ delete it.second;
}
- for (std::deque<QueuedMinimapUpdate>::iterator
- it = m_update_queue.begin();
- it != m_update_queue.end(); ++it) {
- QueuedMinimapUpdate &q = *it;
+ for (auto &q : m_update_queue) {
delete q.data;
}
}
// Find if block is already in queue.
// If it is, update the data and quit.
- for (std::deque<QueuedMinimapUpdate>::iterator
- it = m_update_queue.begin();
- it != m_update_queue.end(); ++it) {
- QueuedMinimapUpdate &q = *it;
+ for (QueuedMinimapUpdate &q : m_update_queue) {
if (q.pos == pos) {
delete q.data;
q.data = data;
void MinimapUpdateThread::getMap(v3s16 pos, s16 size, s16 height)
{
- v3s16 region(size, 0, size);
v3s16 pos_min(pos.X - size / 2, pos.Y - height / 2, pos.Z - size / 2);
v3s16 pos_max(pos_min.X + size - 1, pos.Y + height / 2, pos_min.Z + size - 1);
v3s16 blockpos_min = getNodeBlockPos(pos_min);
//// Mapper
////
-Minimap::Minimap(IrrlichtDevice *device, Client *client)
+Minimap::Minimap(Client *client)
{
this->client = client;
- this->driver = device->getVideoDriver();
+ this->driver = RenderingEngine::get_video_driver();
this->m_tsrc = client->getTextureSource();
this->m_shdrsrc = client->getShaderSource();
this->m_ndef = client->getNodeDefManager();
data->mode = MINIMAP_MODE_OFF;
data->is_radar = false;
data->map_invalidated = true;
- data->heightmap_image = NULL;
- data->minimap_image = NULL;
data->texture = NULL;
data->heightmap_texture = NULL;
data->minimap_shape_round = g_settings->getBool("minimap_shape_round");
m_minimap_update_thread->deferUpdate();
}
+void Minimap::setMinimapShape(MinimapShape shape)
+{
+ MutexAutoLock lock(m_mutex);
+
+ if (shape == MINIMAP_SHAPE_SQUARE)
+ data->minimap_shape_round = false;
+ else if (shape == MINIMAP_SHAPE_ROUND)
+ data->minimap_shape_round = true;
+
+ g_settings->setBool("minimap_shape_round", data->minimap_shape_round);
+ m_minimap_update_thread->deferUpdate();
+}
+
+MinimapShape Minimap::getMinimapShape()
+{
+ if (data->minimap_shape_round) {
+ return MINIMAP_SHAPE_ROUND;
+ }
+
+ return MINIMAP_SHAPE_SQUARE;
+}
+
void Minimap::setMinimapMode(MinimapMode mode)
{
static const MinimapModeDef modedefs[MINIMAP_MODE_COUNT] = {
cos(m_angle * core::DEGTORAD),
sin(m_angle * core::DEGTORAD),
1.0);
- } else {
- return v3f(1.0, 0.0, 1.0);
}
+
+ return v3f(1.0, 0.0, 1.0);
}
scene::SMeshBuffer *Minimap::getMinimapMeshBuffer()
return;
updateActiveMarkers();
- v2u32 screensize = porting::getWindowSize();
+ v2u32 screensize = RenderingEngine::get_instance()->getWindowSize();
const u32 size = 0.25 * screensize.Y;
core::rect<s32> oldViewPort = driver->getViewPort();
m_active_markers.clear();
- for (std::list<Nametag *>::const_iterator i = nametags.begin();
- i != nametags.end(); ++i) {
- v3s16 pos = floatToInt((*i)->parent_node->getPosition() +
+ for (Nametag *nametag : nametags) {
+ v3s16 pos = floatToInt(nametag->parent_node->getPosition() +
intToFloat(client->getCamera()->getOffset(), BS), BS);
pos -= data->pos - v3s16(data->map_size / 2,
data->scan_height / 2,
if (!mask_col.getAlpha()) {
continue;
}
- m_active_markers.push_back(v2f(((float)pos.X / (float)MINIMAP_MAX_SX) - 0.5,
- (1.0 - (float)pos.Z / (float)MINIMAP_MAX_SY) - 0.5));
+
+ m_active_markers.emplace_back(((float)pos.X / (float)MINIMAP_MAX_SX) - 0.5,
+ (1.0 - (float)pos.Z / (float)MINIMAP_MAX_SY) - 0.5);
}
}
//// MinimapMapblock
////
-void MinimapMapblock::getMinimapNodes(VoxelManipulator *vmanip, v3s16 pos)
+void MinimapMapblock::getMinimapNodes(VoxelManipulator *vmanip, const v3s16 &pos)
{
for (s16 x = 0; x < MAP_BLOCKSIZE; x++)