aboutsummaryrefslogtreecommitdiff
path: root/assets/interlocking.html.LyXconv/interlocking.lg
blob: a16881c6af0281913cd34e678c2c02b9aa38041e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
htfcss: ecbx  font-weight: bold;
htfcss: ecsx  font-weight: bold;
htfcss: ecbi  font-weight: bold;   font-style: italic;
htfcss: ecit  font-style: italic; font-family: monospace;
htfcss: ecss  font-family: sans-serif;
htfcss: ecff  font-family: fantasy;
htfcss: ecti  font-style: italic;
htfcss: ectt  font-family: monospace;
htfcss: ecbx  font-weight: bold;
htfcss: ecsx  font-weight: bold;
htfcss: ecbi  font-weight: bold;   font-style: italic;
htfcss: ecit  font-style: italic; font-family: monospace;
htfcss: ecss  font-family: sans-serif;
htfcss: ecff  font-family: fantasy;
htfcss: ecti  font-style: italic;
htfcss: ectt  font-family: monospace;
htfcss: ecbx  font-weight: bold;
htfcss: ecsx  font-weight: bold;
htfcss: ecbi  font-weight: bold;   font-style: italic;
htfcss: ecit  font-style: italic; font-family: monospace;
htfcss: ecss  font-family: sans-serif;
htfcss: ecff  font-family: fantasy;
htfcss: ecti  font-style: italic;
htfcss: ectt  font-family: monospace;
htfcss: ecbx  font-weight: bold;
htfcss: ecsx  font-weight: bold;
htfcss: ecbi  font-weight: bold;   font-style: italic;
htfcss: ecit  font-style: italic; font-family: monospace;
htfcss: ecss  font-family: sans-serif;
htfcss: ecff  font-family: fantasy;
htfcss: ecti  font-style: italic;
htfcss: ectt  font-family: monospace;
htfcss: ecbx  font-weight: bold;
htfcss: ecsx  font-weight: bold;
htfcss: ecbi  font-weight: bold;   font-style: italic;
htfcss: ecit  font-style: italic; font-family: monospace;
htfcss: ecss  font-family: sans-serif;
htfcss: ecff  font-family: fantasy;
htfcss: ecti  font-style: italic;
htfcss: ectt  font-family: monospace;
htfcss: ecbx  font-weight: bold;
htfcss: ecsx  font-weight: bold;
htfcss: ecbi  font-weight: bold;   font-style: italic;
htfcss: ecit  font-style: italic; font-family: monospace;
htfcss: ecss  font-family: sans-serif;
htfcss: ecff  font-family: fantasy;
htfcss: ecti  font-style: italic;
htfcss: ectt  font-family: monospace;
File: interlocking.html
File: interlocking.css
File: interlocking.tmp
Css: p.noindent { text-indent: 0em }
Css: td p.noindent { text-indent: 0em; margin-top:0em; }
Css: p.nopar { text-indent: 0em; }
Css: p.indent{ text-indent: 1.5em }
Css: @media print {div.crosslinks {visibility:hidden;}}
Css: a img { border-top: 0; border-left: 0; border-right: 0; }
Font_Css("4"): .small-caps{font-variant: small-caps; }
Font_Css("10"): .htf-cmbx {font-weight: bold; font-style:normal;}
Font_Css("12"): .htf-calligraphy {font-family:cursive}
Font_Css("14"): .htf-italic {font-style: italic;}
Font_Css("16"): .htf-bold {font-weight: bold;}
Font_Css("12"): .htf-calligraphy-bold {font-family:cursive ; font-weight: bold; }
Css: center { margin-top:1em; margin-bottom:1em; }
Css: td center { margin-top:0em; margin-bottom:0em; }
Css: .Canvas { position:relative; }
Css: img.math{vertical-align:middle;}
Css: li p.indent { text-indent: 0em }
Css: li p:first-child{ margin-top:0em; }
Css: li p:last-child, li div:last-child { margin-bottom:0.5em; }
Css: li p~ul:last-child, li p~ol:last-child{ margin-bottom:0.5em; }
Css: .enumerate1 {list-style-type:decimal;}
Css: .enumerate2 {list-style-type:lower-alpha;}
Css: .enumerate3 {list-style-type:lower-roman;}
Css: .enumerate4 {list-style-type:upper-alpha;}
Css: div.newtheorem { margin-bottom: 2em; margin-top: 2em;}
Css: .obeylines-h,.obeylines-v {white-space: nowrap; }
Css: div.obeylines-v p { margin-top:0; margin-bottom:0; }
Css: .overline{ text-decoration:overline; }
Css: .overline img{ border-top: 1px solid black; }
Css: td.displaylines {text-align:center; white-space:nowrap;}
Css: .centerline {text-align:center;}
Css: .rightline {text-align:right;}
Css: div.verbatim {font-family: monospace; white-space: nowrap; text-align:left; clear:both; }
Css: .fbox {padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
Css: div.fbox {display:table}
Css: div.center div.fbox {text-align:center; clear:both; padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
Css: div.minipage{width:100%;}
Css: div.center, div.center div.center {text-align: center; margin-left:1em; margin-right:1em;}
Css: div.center div {text-align: left;}
Css: div.flushright, div.flushright div.flushright {text-align: right;}
Css: div.flushright div {text-align: left;}
Css: div.flushleft {text-align: left;}
Css: .underline{ text-decoration:underline; }
Css: .underline img{ border-bottom: 1px solid black; margin-bottom:1pt; }
Css: .framebox-c, .framebox-l, .framebox-r { padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
Css: .framebox-c {text-align:center;}
Css: .framebox-l {text-align:left;}
Css: .framebox-r {text-align:right;}
Css: span.thank-mark{ vertical-align: super }
Css: span.footnote-mark sup.textsuperscript, span.footnote-mark a sup.textsuperscript{ font-size:80%; }
Css: div.tabular, div.center div.tabular {text-align: center; margin-top:0.5em; margin-bottom:0.5em; }
Css: table.tabular td p{margin-top:0em;}
Css: table.tabular {margin-left: auto; margin-right: auto;}
Css: td p:first-child{ margin-top:0em; }
Css: td p:last-child{ margin-bottom:0em; }
Css: div.td00{ margin-left:0pt; margin-right:0pt; }
Css: div.td01{ margin-left:0pt; margin-right:5pt; }
Css: div.td10{ margin-left:5pt; margin-right:0pt; }
Css: div.td11{ margin-left:5pt; margin-right:5pt; }
Css: table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; }
Css: td.td00{ padding-left:0pt; padding-right:0pt; }
Css: td.td01{ padding-left:0pt; padding-right:5pt; }
Css: td.td10{ padding-left:5pt; padding-right:0pt; }
Css: td.td11{ padding-left:5pt; padding-right:5pt; }
Css: table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; }
Css: .hline hr, .cline hr{ height : 1px; margin:0px; }
Css: .tabbing-right {text-align:right;}
Css: span.TEX {letter-spacing: -0.125em; }
Css: span.TEX span.E{ position:relative;top:0.5ex;left:-0.0417em;}
Css: a span.TEX span.E {text-decoration: none; }
Css: span.LATEX span.A{ position:relative; top:-0.5ex; left:-0.4em; font-size:85%;}
Css: span.LATEX span.TEX{ position:relative; left: -0.4em; }
Css: div.float, div.figure {margin-left: auto; margin-right: auto;}
Css: div.float img {text-align:center;}
Css: div.figure img {text-align:center;}
Css: .marginpar {width:20%; float:right; text-align:left; margin-left:auto; margin-top:0.5em; font-size:85%; text-decoration:underline;}
Css: .marginpar p{margin-top:0.4em; margin-bottom:0.4em;}
Css: table.equation {width:100%;}
Css: .equation td{text-align:center; }
Css: td.equation { margin-top:1em; margin-bottom:1em; } 
Css: td.equation-label { width:5%; text-align:center; }
Css: td.eqnarray4 { width:5%; white-space: normal; }
Css: td.eqnarray2 { width:5%; }
Css: table.eqnarray-star, table.eqnarray {width:100%;}
Css: div.eqnarray{text-align:center;}
Css: div.array {text-align:center;}
Css: div.pmatrix {text-align:center;}
Css: table.pmatrix {width:100%;}
Css: span.pmatrix img{vertical-align:middle;}
Css: div.pmatrix {text-align:center;}
Css: table.pmatrix {width:100%;}
Css: span.bar-css {text-decoration:overline;}
Css: img.cdots{vertical-align:middle;}
Css: .figure img.graphics {margin-left:10%;}
File: 0_home_moritz_Home_Projekte_Minetest_minetest_m___s_assets_lyx_img_screenshot_20180830_142551.png
File: 1_home_moritz_Home_Projekte_Minetest_minetest_m____lyx_img_Bildschirmfoto_2018-08-30_14-26-35.png
File: 2_home_moritz_Home_Projekte_Minetest_minetest_m____lyx_img_Bildschirmfoto_2018-08-30_14-32-48.png
File: 3_home_moritz_Home_Projekte_Minetest_minetest_m____lyx_img_Bildschirmfoto_2018-08-30_14-27-25.png
File: 4_home_moritz_Home_Projekte_Minetest_minetest_m____lyx_img_Bildschirmfoto_2018-08-30_14-28-32.png
File: 5_home_moritz_Home_Projekte_Minetest_minetest_m____lyx_img_Bildschirmfoto_2018-08-30_14-51-25.png
File: 6_home_moritz_Home_Projekte_Minetest_minetest_mods_advtrains_assets_lyx_img_route_ex1.png
File: 7_home_moritz_Home_Projekte_Minetest_minetest_mods_advtrains_assets_lyx_img_route_ex2.png
File: 8_home_moritz_Home_Projekte_Minetest_minetest_mods_advtrains_assets_lyx_img_assign_signal.png
File: 9_home_moritz_Home_Projekte_Minetest_minetest_mods_advtrains_assets_lyx_img_route_ex3.png
File: 10_home_moritz_Home_Projekte_Minetest_minetest_____lyx_img_Bildschirmfoto_2019-01-15_19-28-09.png
File: 11_home_moritz_Home_Projekte_Minetest_minetest_mods_advtrains_assets_lyx_img_arslin_ex1.png
File: 12_home_moritz_Home_Projekte_Minetest_minetest_mods_advtrains_assets_lyx_img_arslin_ex2.png
File: 13_home_moritz_Home_Projekte_Minetest_minetest_mods_advtrains_assets_lyx_img_ars_ex1.png
--- characters ---
Font("ecrm","1000","10","100")
Font("ecsx","1728","17","100")
Font("ecst","1440","14","100")
Font("ecsx","1200","12","100")
Font("ecsx","1000","10","100")
Font("ecbx","1000","10","100")
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
/*
Minetest
Copyright (C) 2010-2015 celeron55, Perttu Ahola <celeron55@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "minimap.h"
#include <cmath>
#include "client.h"
#include "clientmap.h"
#include "settings.h"
#include "shader.h"
#include "mapblock.h"
#include "client/renderingengine.h"


////
//// MinimapUpdateThread
////

MinimapUpdateThread::~MinimapUpdateThread()
{
	for (auto &it : m_blocks_cache) {
		delete it.second;
	}

	for (auto &q : m_update_queue) {
		delete q.data;
	}
}

bool MinimapUpdateThread::pushBlockUpdate(v3s16 pos, MinimapMapblock *data)
{
	MutexAutoLock lock(m_queue_mutex);

	// Find if block is already in queue.
	// If it is, update the data and quit.
	for (QueuedMinimapUpdate &q : m_update_queue) {
		if (q.pos == pos) {
			delete q.data;
			q.data = data;
			return false;
		}
	}

	// Add the block
	QueuedMinimapUpdate q;
	q.pos  = pos;
	q.data = data;
	m_update_queue.push_back(q);

	return true;
}

bool MinimapUpdateThread::popBlockUpdate(QueuedMinimapUpdate *update)
{
	MutexAutoLock lock(m_queue_mutex);

	if (m_update_queue.empty())
		return false;

	*update = m_update_queue.front();
	m_update_queue.pop_front();

	return true;
}

void MinimapUpdateThread::enqueueBlock(v3s16 pos, MinimapMapblock *data)
{
	pushBlockUpdate(pos, data);
	deferUpdate();
}


void MinimapUpdateThread::doUpdate()
{
	QueuedMinimapUpdate update;

	while (popBlockUpdate(&update)) {
		if (update.data) {
			// Swap two values in the map using single lookup
			std::pair<std::map<v3s16, MinimapMapblock*>::iterator, bool>
			    result = m_blocks_cache.insert(std::make_pair(update.pos, update.data));
			if (!result.second) {
				delete result.first->second;
				result.first->second = update.data;
			}
		} else {
			std::map<v3s16, MinimapMapblock *>::iterator it;
			it = m_blocks_cache.find(update.pos);
			if (it != m_blocks_cache.end()) {
				delete it->second;
				m_blocks_cache.erase(it);
			}
		}
	}

	if (data->map_invalidated && data->mode != MINIMAP_MODE_OFF) {
		getMap(data->pos, data->map_size, data->scan_height);
		data->map_invalidated = false;
	}
}

void MinimapUpdateThread::getMap(v3s16 pos, s16 size, s16 height)
{
	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);
	v3s16 blockpos_max = getNodeBlockPos(pos_max);

// clear the map
	for (int z = 0; z < size; z++)
	for (int x = 0; x < size; x++) {
		MinimapPixel &mmpixel = data->minimap_scan[x + z * size];
		mmpixel.air_count = 0;
		mmpixel.height = 0;
		mmpixel.n = MapNode(CONTENT_AIR);
	}

// draw the map
	v3s16 blockpos;
	for (blockpos.Z = blockpos_min.Z; blockpos.Z <= blockpos_max.Z; ++blockpos.Z)
	for (blockpos.Y = blockpos_min.Y; blockpos.Y <= blockpos_max.Y; ++blockpos.Y)
	for (blockpos.X = blockpos_min.X; blockpos.X <= blockpos_max.X; ++blockpos.X) {
		std::map<v3s16, MinimapMapblock *>::const_iterator pblock =
			m_blocks_cache.find(blockpos);
		if (pblock == m_blocks_cache.end())
			continue;
		const MinimapMapblock &block = *pblock->second;

		v3s16 block_node_min(blockpos * MAP_BLOCKSIZE);
		v3s16 block_node_max(block_node_min + MAP_BLOCKSIZE - 1);
		// clip
		v3s16 range_min = componentwise_max(block_node_min, pos_min);
		v3s16 range_max = componentwise_min(block_node_max, pos_max);

		v3s16 pos;
		pos.Y = range_min.Y;
		for (pos.Z = range_min.Z; pos.Z <= range_max.Z; ++pos.Z)
		for (pos.X = range_min.X; pos.X <= range_max.X; ++pos.X) {
			v3s16 inblock_pos = pos - block_node_min;
			const MinimapPixel &in_pixel =
				block.data[inblock_pos.Z * MAP_BLOCKSIZE + inblock_pos.X];

			v3s16 inmap_pos = pos - pos_min;
			MinimapPixel &out_pixel =
				data->minimap_scan[inmap_pos.X + inmap_pos.Z * size];

			out_pixel.air_count += in_pixel.air_count;
			if (in_pixel.n.param0 != CONTENT_AIR) {
				out_pixel.n = in_pixel.n;
				out_pixel.height = inmap_pos.Y + in_pixel.height;
			}
		}
	}
}

////
//// Mapper
////

Minimap::Minimap(Client *client)
{
	this->client    = client;
	this->driver    = RenderingEngine::get_video_driver();
	this->m_tsrc    = client->getTextureSource();
	this->m_shdrsrc = client->getShaderSource();
	this->m_ndef    = client->getNodeDefManager();

	m_angle = 0.f;

	// Initialize static settings
	m_enable_shaders = g_settings->getBool("enable_shaders");
	m_surface_mode_scan_height =
		g_settings->getBool("minimap_double_scan_height") ? 256 : 128;

	// Initialize minimap data
	data = new MinimapData;
	data->mode              = MINIMAP_MODE_OFF;
	data->is_radar          = false;
	data->map_invalidated   = true;
	data->texture           = NULL;
	data->heightmap_texture = NULL;
	data->minimap_shape_round = g_settings->getBool("minimap_shape_round");

	// Get round minimap textures
	data->minimap_mask_round = driver->createImage(
		m_tsrc->getTexture("minimap_mask_round.png"),
		core::position2d<s32>(0, 0),
		core::dimension2d<u32>(MINIMAP_MAX_SX, MINIMAP_MAX_SY));
	data->minimap_overlay_round = m_tsrc->getTexture("minimap_overlay_round.png");

	// Get square minimap textures
	data->minimap_mask_square = driver->createImage(
		m_tsrc->getTexture("minimap_mask_square.png"),
		core::position2d<s32>(0, 0),
		core::dimension2d<u32>(MINIMAP_MAX_SX, MINIMAP_MAX_SY));
	data->minimap_overlay_square = m_tsrc->getTexture("minimap_overlay_square.png");

	// Create player marker texture
	data->player_marker = m_tsrc->getTexture("player_marker.png");
	// Create object marker texture
	data->object_marker_red = m_tsrc->getTexture("object_marker_red.png");

	// Create mesh buffer for minimap
	m_meshbuffer = getMinimapMeshBuffer();

	// Initialize and start thread
	m_minimap_update_thread = new MinimapUpdateThread();
	m_minimap_update_thread->data = data;
	m_minimap_update_thread->start();
}

Minimap::~Minimap()
{
	m_minimap_update_thread->stop();
	m_minimap_update_thread->wait();

	m_meshbuffer->drop();

	data->minimap_mask_round->drop();
	data->minimap_mask_square->drop();

	driver->removeTexture(data->texture);
	driver->removeTexture(data->heightmap_texture);
	driver->removeTexture(data->minimap_overlay_round);
	driver->removeTexture(data->minimap_overlay_square);
	driver->removeTexture(data->object_marker_red);

	delete data;
	delete m_minimap_update_thread;
}

void Minimap::addBlock(v3s16 pos, MinimapMapblock *data)
{
	m_minimap_update_thread->enqueueBlock(pos, data);
}

void Minimap::toggleMinimapShape()
{
	MutexAutoLock lock(m_mutex);

	data->minimap_shape_round = !data->minimap_shape_round;
	g_settings->setBool("minimap_shape_round", data->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] = {
		{false, 0, 0},
		{false, m_surface_mode_scan_height, 256},
		{false, m_surface_mode_scan_height, 128},
		{false, m_surface_mode_scan_height, 64},
		{true, 32, 128},
		{true, 32, 64},
		{true, 32, 32}
	};

	if (mode >= MINIMAP_MODE_COUNT)
		return;

	MutexAutoLock lock(m_mutex);

	data->is_radar    = modedefs[mode].is_radar;
	data->scan_height = modedefs[mode].scan_height;
	data->map_size    = modedefs[mode].map_size;
	data->mode        = mode;

	m_minimap_update_thread->deferUpdate();
}

void Minimap::setPos(v3s16 pos)
{
	bool do_update = false;

	{
		MutexAutoLock lock(m_mutex);

		if (pos != data->old_pos) {
			data->old_pos = data->pos;
			data->pos = pos;
			do_update = true;
		}
	}

	if (do_update)
		m_minimap_update_thread->deferUpdate();
}

void Minimap::setAngle(f32 angle)
{
	m_angle = angle;
}

void Minimap::blitMinimapPixelsToImageRadar(video::IImage *map_image)
{
	video::SColor c(240, 0, 0, 0);
	for (s16 x = 0; x < data->map_size; x++)
	for (s16 z = 0; z < data->map_size; z++) {
		MinimapPixel *mmpixel = &data->minimap_scan[x + z * data->map_size];

		if (mmpixel->air_count > 0)
			c.setGreen(core::clamp(core::round32(32 + mmpixel->air_count * 8), 0, 255));
		else
			c.setGreen(0);

		map_image->setPixel(x, data->map_size - z - 1, c);
	}
}

void Minimap::blitMinimapPixelsToImageSurface(
	video::IImage *map_image, video::IImage *heightmap_image)
{
	// This variable creation/destruction has a 1% cost on rendering minimap
	video::SColor tilecolor;
	for (s16 x = 0; x < data->map_size; x++)
	for (s16 z = 0; z < data->map_size; z++) {
		MinimapPixel *mmpixel = &data->minimap_scan[x + z * data->map_size];

		const ContentFeatures &f = m_ndef->get(mmpixel->n);
		const TileDef *tile = &f.tiledef[0];

		// Color of the 0th tile (mostly this is the topmost)
		if(tile->has_color)
			tilecolor = tile->color;
		else
			mmpixel->n.getColor(f, &tilecolor);

		tilecolor.setRed(tilecolor.getRed() * f.minimap_color.getRed() / 255);
		tilecolor.setGreen(tilecolor.getGreen() * f.minimap_color.getGreen() / 255);
		tilecolor.setBlue(tilecolor.getBlue() * f.minimap_color.getBlue() / 255);
		tilecolor.setAlpha(240);

		map_image->setPixel(x, data->map_size - z - 1, tilecolor);

		u32 h = mmpixel->height;
		heightmap_image->setPixel(x,data->map_size - z - 1,
			video::SColor(255, h, h, h));
	}
}

video::ITexture *Minimap::getMinimapTexture()
{
	// update minimap textures when new scan is ready
	if (data->map_invalidated)
		return data->texture;

	// create minimap and heightmap images in memory
	core::dimension2d<u32> dim(data->map_size, data->map_size);
	video::IImage *map_image       = driver->createImage(video::ECF_A8R8G8B8, dim);
	video::IImage *heightmap_image = driver->createImage(video::ECF_A8R8G8B8, dim);
	video::IImage *minimap_image   = driver->createImage(video::ECF_A8R8G8B8,
		core::dimension2d<u32>(MINIMAP_MAX_SX, MINIMAP_MAX_SY));

	// Blit MinimapPixels to images
	if (data->is_radar)
		blitMinimapPixelsToImageRadar(map_image);
	else
		blitMinimapPixelsToImageSurface(map_image, heightmap_image);

	map_image->copyToScaling(minimap_image);
	map_image->drop();

	video::IImage *minimap_mask = data->minimap_shape_round ?
		data->minimap_mask_round : data->minimap_mask_square;

	if (minimap_mask) {
		for (s16 y = 0; y < MINIMAP_MAX_SY; y++)
		for (s16 x = 0; x < MINIMAP_MAX_SX; x++) {
			const video::SColor &mask_col = minimap_mask->getPixel(x, y);
			if (!mask_col.getAlpha())
				minimap_image->setPixel(x, y, video::SColor(0,0,0,0));
		}
	}

	if (data->texture)
		driver->removeTexture(data->texture);
	if (data->heightmap_texture)
		driver->removeTexture(data->heightmap_texture);

	data->texture = driver->addTexture("minimap__", minimap_image);
	data->heightmap_texture =
		driver->addTexture("minimap_heightmap__", heightmap_image);
	minimap_image->drop();
	heightmap_image->drop();

	data->map_invalidated = true;

	return data->texture;
}

v3f Minimap::getYawVec()
{
	if (data->minimap_shape_round) {
		return v3f(
			std::cos(m_angle * core::DEGTORAD),