aboutsummaryrefslogtreecommitdiff
path: root/games/devtest/mods/unittests/textures/default_dirt.png
blob: 58670305d007716c3fee12b45e8acf301cbd4c5a (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 10 00 00 00 10 08 02 00 00 00 90 91 68 .PNG........IHDR...............h
0020 36 00 00 02 dd 49 44 41 54 78 01 0d d0 83 82 c3 66 00 00 e0 e4 ff cb a8 c6 5d 52 9b b3 6d db de 6....IDATx......f........]R..m..
0040 de 6a c6 43 cc b6 55 23 e7 6b ea 24 cd 15 71 b6 ef 11 3e f4 c9 7b 23 76 3b 3a 13 8c 68 66 ee e0 .j.C..U#.k.$..q...>..{#v;:..hf..
0060 98 9d 6e a4 e2 97 77 4e 3e 8e 25 af c3 bd 67 40 62 7c 09 57 b3 39 34 66 18 aa 1d ee 90 20 bc e1 ..n...wN>.%...g@b|.W.94f........
0080 ca 1c 34 f9 1c 85 7a b5 32 16 ef 91 24 65 ae f8 00 ad f9 c9 8a 32 23 4e 47 ac cb 1f 64 52 57 68 ..4...z.2...$e.......2#NG...dRWh
00a0 72 f7 0f ce aa 14 31 70 66 5b ac 67 d6 ca 08 51 74 d3 e3 7e f1 e4 9c 27 52 37 d8 9c f7 7c 32 f8 r.....1pf[.g...Qt..~...'R7...|2.
00c0 c9 e9 df 9c ee 04 dc 87 6f 4f 59 4c 71 5f 5d bc 4c 03 1b e0 66 f5 31 aa 3a d7 d2 86 4c 48 a3 af ........oOYLq_].L...f.1.:...LH..
00e0 b3 b5 eb d7 eb 75 a8 c0 dc c5 68 93 c9 f8 a9 bb 6a d3 c6 c9 3e 41 4d a6 56 2e 8e 1e b3 00 66 8b .....u....h.....j...>AM.V.....f.
0100 6b ba ba df 1d 6c 3c 36 4c 6a 4f 8a 89 c8 8e ff eb cf 4f 7e 9f e8 8e 1e b2 fc fd a3 0b a2 52 73 k....l<6LjO.......O~..........Rs
0120 7b b8 4a b9 f0 f1 1f bf a4 e7 00 26 e9 3c 62 7a 1f 79 fc b5 f9 29 ef bb 6c c8 89 14 a4 81 03 a1 {.J........&.<bz.y...)..l.......
0140 63 99 8c 3a 51 19 3f 28 27 d0 37 3e e8 2b d3 d5 5d 77 3e ff 8f dc 80 af 3c 7a 83 2c 36 96 ba 05 c..:Q.?('.7>.+..]w>.....<z.,6...
0160 2f 7e fd e7 d0 7e ae ef f4 81 3a 18 49 9d 3e 27 88 4a 34 4f cc a5 8d dd 30 6f b9 eb be 91 f0 1d /~...~....:.I.>'.J4O....0o......
0180 1d 0d c1 72 20 b2 46 8c af 7f 1e de 75 f9 d5 5f f7 8f b3 3a e5 74 42 11 5e 54 19 2c e4 45 2c 23 ...r..F.....u.._...:.tB.^T.,.E,#
01a0 1e 54 85 bd 9b af 46 85 df 97 53 e1 db ef 87 70 df be 6d 71 67 34 15 f8 a9 71 f0 c0 dd b5 0d 26 .T....F...S....p..mqg4...q.....&
01c0 e2 49 f7 65 d0 8e 07 b4 05 ef 69 b5 47 cf df 71 f9 e4 ec 37 af bd ae b0 0b 18 d1 e1 cd 97 25 11 .I.e......i.G..q...7..........%.
01e0 cf d6 47 05 d7 96 d0 fc 7b 83 07 c1 ff e1 61 27 79 be 06 58 75 ff 66 97 ed dd 46 a3 10 cb e8 2e ..G.....{.....a'y..Xu.f...F.....
0200 e7 12 74 73 81 cb 61 25 1e 0a 50 40 9c 01 bf 0d 10 1e 91 30 e5 bc 3f 32 40 ce a5 ad 8e 73 5b 56 ..ts..a%..P@.......0..?2@....s[V
0220 11 6b d7 07 dd 4b 30 5d 4d ca a1 32 37 3d 82 91 8c 99 c5 98 54 da ee 08 0a 31 90 60 fc 59 f3 58 .k...K0]M..27=......T....1.`.Y.X
0240 66 aa d9 0d af 5f 7d f3 d5 d2 70 48 b9 d6 74 ed ba 0b c4 3a 3e e7 b6 9c 02 5f b8 b5 f4 ef 88 fd f...._}...pH..t....:>...._......
0260 7e b8 b8 11 32 68 ca 21 7a c9 64 25 22 7d 7e 94 c8 cf d1 b9 46 54 31 37 42 19 9a 5e c2 43 9d d6 ~...2h.!z.d%"}~.....FT17B..^.C..
0280 9a 25 64 78 6d c6 cd 9e c0 02 1d 36 10 79 24 71 7c df 68 9e ff 92 bf fc 0a dd e1 30 1c f2 94 05 .%dxm......6.y$q|.h........0....
02a0 ee cc 65 9d 3e db 89 ea b2 38 49 fa 76 f0 aa 2c 25 1c 4d af bb 3b 85 f8 ed 7b 6a 0e 71 b7 ed 0e ..e.>....8I.v..,%.M..;...{j.q...
02c0 10 b6 54 51 5c 39 af b8 4c e5 c7 d3 b3 be 35 73 1c 75 e4 c4 75 51 8c 4f c2 fa e5 09 3a 1e da 69 ..TQ\9..L.....5s.u..uQ.O....:..i
02e0 9c 4b 71 fe 76 cc 13 86 b9 85 a4 a9 05 12 e9 d4 e2 cc 01 37 1d 45 59 23 98 0b b3 87 c0 0c 21 d4 .Kq.v..............7.EY#......!.
0300 d5 7f 1a 78 72 6b e1 ce 9a 4b 00 00 00 00 49 45 4e 44 ae 42 60 82 ...xrk...K....IEND.B`.
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 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
/*
Minetest
Copyright (C) 2010-2013 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 "clientmap.h"
#include "client.h"
#include "mapblock_mesh.h"
#include <IMaterialRenderer.h>
#include <matrix4.h>
#include "mapsector.h"
#include "mapblock.h"
#include "profiler.h"
#include "settings.h"
#include "camera.h"               // CameraModes
#include "util/basic_macros.h"
#include <algorithm>
#include "client/renderingengine.h"

ClientMap::ClientMap(
		Client *client,
		MapDrawControl &control,
		s32 id
):
	Map(dout_client, client),
	scene::ISceneNode(RenderingEngine::get_scene_manager()->getRootSceneNode(),
		RenderingEngine::get_scene_manager(), id),
	m_client(client),
	m_control(control)
{
	m_box = aabb3f(-BS*1000000,-BS*1000000,-BS*1000000,
			BS*1000000,BS*1000000,BS*1000000);

	/* TODO: Add a callback function so these can be updated when a setting
	 *       changes.  At this point in time it doesn't matter (e.g. /set
	 *       is documented to change server settings only)
	 *
	 * TODO: Local caching of settings is not optimal and should at some stage
	 *       be updated to use a global settings object for getting thse values
	 *       (as opposed to the this local caching). This can be addressed in
	 *       a later release.
	 */
	m_cache_trilinear_filter  = g_settings->getBool("trilinear_filter");
	m_cache_bilinear_filter   = g_settings->getBool("bilinear_filter");
	m_cache_anistropic_filter = g_settings->getBool("anisotropic_filter");

}

MapSector * ClientMap::emergeSector(v2s16 p2d)
{
	// Check that it doesn't exist already
	MapSector *sector = getSectorNoGenerate(p2d);

	// Create it if it does not exist yet
	if (!sector) {
		sector = new MapSector(this, p2d, m_gamedef);
		m_sectors[p2d] = sector;
	}

	return sector;
}

void ClientMap::OnRegisterSceneNode()
{
	if(IsVisible)
	{
		SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID);
		SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT);
	}

	ISceneNode::OnRegisterSceneNode();
}

void ClientMap::getBlocksInViewRange(v3s16 cam_pos_nodes,
		v3s16 *p_blocks_min, v3s16 *p_blocks_max)
{
	v3s16 box_nodes_d = m_control.wanted_range * v3s16(1, 1, 1);
	// Define p_nodes_min/max as v3s32 because 'cam_pos_nodes -/+ box_nodes_d'
	// can exceed the range of v3s16 when a large view range is used near the
	// world edges.
	v3s32 p_nodes_min(
		cam_pos_nodes.X - box_nodes_d.X,
		cam_pos_nodes.Y - box_nodes_d.Y,
		cam_pos_nodes.Z - box_nodes_d.Z);
	v3s32 p_nodes_max(
		cam_pos_nodes.X + box_nodes_d.X,
		cam_pos_nodes.Y + box_nodes_d.Y,
		cam_pos_nodes.Z + box_nodes_d.Z);
	// Take a fair amount as we will be dropping more out later
	// Umm... these additions are a bit strange but they are needed.
	*p_blocks_min = v3s16(
			p_nodes_min.X / MAP_BLOCKSIZE - 3,
			p_nodes_min.Y / MAP_BLOCKSIZE - 3,
			p_nodes_min.Z / MAP_BLOCKSIZE - 3);
	*p_blocks_max = v3s16(
			p_nodes_max.X / MAP_BLOCKSIZE + 1,
			p_nodes_max.Y / MAP_BLOCKSIZE + 1,
			p_nodes_max.Z / MAP_BLOCKSIZE + 1);
}

void ClientMap::updateDrawList()
{
	ScopeProfiler sp(g_profiler, "CM::updateDrawList()", SPT_AVG);

	for (auto &i : m_drawlist) {
		MapBlock *block = i.second;
		block->refDrop();
	}
	m_drawlist.clear();

	v3f camera_position = m_camera_position;
	v3f camera_direction = m_camera_direction;
	f32 camera_fov = m_camera_fov;

	// Use a higher fov to accomodate faster camera movements.
	// Blocks are cropped better when they are drawn.
	// Or maybe they aren't? Well whatever.
	camera_fov *= 1.2;

	v3s16 cam_pos_nodes = floatToInt(camera_position, BS);
	v3s16 p_blocks_min;
	v3s16 p_blocks_max;
	getBlocksInViewRange(cam_pos_nodes, &p_blocks_min, &p_blocks_max);

	// Number of blocks with mesh in rendering range
	u32 blocks_in_range_with_mesh = 0;
	// Number of blocks occlusion culled
	u32 blocks_occlusion_culled = 0;

	// No occlusion culling when free_move is on and camera is
	// inside ground
	bool occlusion_culling_enabled = true;
	if (g_settings->getBool("free_move") && g_settings->getBool("noclip")) {
		MapNode n = getNode(cam_pos_nodes);
		if (n.getContent() == CONTENT_IGNORE ||