3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "clientmap.h"
22 #include "mapblock_mesh.h"
23 #include <IMaterialRenderer.h>
26 #include "mapsector.h"
31 #include "camera.h" // CameraModes
32 #include "util/mathconstants.h"
33 #include "util/basic_macros.h"
39 MapDrawControl &control,
40 scene::ISceneNode* parent,
41 scene::ISceneManager* mgr,
44 Map(dout_client, gamedef),
45 scene::ISceneNode(parent, mgr, id),
48 m_camera_position(0,0,0),
49 m_camera_direction(0,0,1),
52 m_box = aabb3f(-BS*1000000,-BS*1000000,-BS*1000000,
53 BS*1000000,BS*1000000,BS*1000000);
55 /* TODO: Add a callback function so these can be updated when a setting
56 * changes. At this point in time it doesn't matter (e.g. /set
57 * is documented to change server settings only)
59 * TODO: Local caching of settings is not optimal and should at some stage
60 * be updated to use a global settings object for getting thse values
61 * (as opposed to the this local caching). This can be addressed in
64 m_cache_trilinear_filter = g_settings->getBool("trilinear_filter");
65 m_cache_bilinear_filter = g_settings->getBool("bilinear_filter");
66 m_cache_anistropic_filter = g_settings->getBool("anisotropic_filter");
70 ClientMap::~ClientMap()
72 /*MutexAutoLock lock(mesh_mutex);
81 MapSector * ClientMap::emergeSector(v2s16 p2d)
83 DSTACK(FUNCTION_NAME);
84 // Check that it doesn't exist already
86 return getSectorNoGenerate(p2d);
88 catch(InvalidPositionException &e)
93 ClientMapSector *sector = new ClientMapSector(this, p2d, m_gamedef);
96 //MutexAutoLock lock(m_sector_mutex); // Bulk comment-out
97 m_sectors[p2d] = sector;
103 void ClientMap::OnRegisterSceneNode()
107 SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID);
108 SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT);
111 ISceneNode::OnRegisterSceneNode();
114 static bool isOccluded(Map *map, v3s16 p0, v3s16 p1, float step, float stepfac,
115 float start_off, float end_off, u32 needed_count, INodeDefManager *nodemgr)
117 float d0 = (float)BS * p0.getDistanceFrom(p1);
119 v3f uf = v3f(u0.X, u0.Y, u0.Z) * BS;
121 v3f p0f = v3f(p0.X, p0.Y, p0.Z) * BS;
123 for(float s=start_off; s<d0+end_off; s+=step){
124 v3f pf = p0f + uf * s;
125 v3s16 p = floatToInt(pf, BS);
126 MapNode n = map->getNodeNoEx(p);
127 bool is_transparent = false;
128 const ContentFeatures &f = nodemgr->get(n);
130 is_transparent = (f.visual_solidness != 2);
132 is_transparent = (f.solidness != 2);
135 if(count >= needed_count)
143 void ClientMap::getBlocksInViewRange(v3s16 cam_pos_nodes,
144 v3s16 *p_blocks_min, v3s16 *p_blocks_max)
146 v3s16 box_nodes_d = m_control.wanted_range * v3s16(1, 1, 1);
147 // Define p_nodes_min/max as v3s32 because 'cam_pos_nodes -/+ box_nodes_d'
148 // can exceed the range of v3s16 when a large view range is used near the
151 cam_pos_nodes.X - box_nodes_d.X,
152 cam_pos_nodes.Y - box_nodes_d.Y,
153 cam_pos_nodes.Z - box_nodes_d.Z);
155 cam_pos_nodes.X + box_nodes_d.X,
156 cam_pos_nodes.Y + box_nodes_d.Y,
157 cam_pos_nodes.Z + box_nodes_d.Z);
158 // Take a fair amount as we will be dropping more out later
159 // Umm... these additions are a bit strange but they are needed.
160 *p_blocks_min = v3s16(
161 p_nodes_min.X / MAP_BLOCKSIZE - 3,
162 p_nodes_min.Y / MAP_BLOCKSIZE - 3,
163 p_nodes_min.Z / MAP_BLOCKSIZE - 3);
164 *p_blocks_max = v3s16(
165 p_nodes_max.X / MAP_BLOCKSIZE + 1,
166 p_nodes_max.Y / MAP_BLOCKSIZE + 1,
167 p_nodes_max.Z / MAP_BLOCKSIZE + 1);
170 void ClientMap::updateDrawList(video::IVideoDriver* driver)
172 ScopeProfiler sp(g_profiler, "CM::updateDrawList()", SPT_AVG);
173 g_profiler->add("CM::updateDrawList() count", 1);
175 INodeDefManager *nodemgr = m_gamedef->ndef();
177 for (std::map<v3s16, MapBlock*>::iterator i = m_drawlist.begin();
178 i != m_drawlist.end(); ++i) {
179 MapBlock *block = i->second;
184 v3f camera_position = m_camera_position;
185 v3f camera_direction = m_camera_direction;
186 f32 camera_fov = m_camera_fov;
188 // Use a higher fov to accomodate faster camera movements.
189 // Blocks are cropped better when they are drawn.
190 // Or maybe they aren't? Well whatever.
193 v3s16 cam_pos_nodes = floatToInt(camera_position, BS);
196 getBlocksInViewRange(cam_pos_nodes, &p_blocks_min, &p_blocks_max);
198 // Number of blocks in rendering range
199 u32 blocks_in_range = 0;
200 // Number of blocks occlusion culled
201 u32 blocks_occlusion_culled = 0;
202 // Number of blocks in rendering range but don't have a mesh
203 u32 blocks_in_range_without_mesh = 0;
204 // Blocks that had mesh that would have been drawn according to
205 // rendering range (if max blocks limit didn't kick in)
206 u32 blocks_would_have_drawn = 0;
207 // Blocks that were drawn and had a mesh
208 u32 blocks_drawn = 0;
209 // Blocks which had a corresponding meshbuffer for this pass
210 //u32 blocks_had_pass_meshbuf = 0;
211 // Blocks from which stuff was actually drawn
212 //u32 blocks_without_stuff = 0;
213 // Distance to farthest drawn block
214 float farthest_drawn = 0;
216 // No occlusion culling when free_move is on and camera is
218 bool occlusion_culling_enabled = true;
219 if (g_settings->getBool("free_move")) {
220 MapNode n = getNodeNoEx(cam_pos_nodes);
221 if (n.getContent() == CONTENT_IGNORE ||
222 nodemgr->get(n).solidness == 2)
223 occlusion_culling_enabled = false;
226 for (std::map<v2s16, MapSector*>::iterator si = m_sectors.begin();
227 si != m_sectors.end(); ++si) {
228 MapSector *sector = si->second;
229 v2s16 sp = sector->getPos();
231 if (m_control.range_all == false) {
232 if (sp.X < p_blocks_min.X || sp.X > p_blocks_max.X ||
233 sp.Y < p_blocks_min.Z || sp.Y > p_blocks_max.Z)
237 MapBlockVect sectorblocks;
238 sector->getBlocks(sectorblocks);
241 Loop through blocks in sector
244 u32 sector_blocks_drawn = 0;
246 for (MapBlockVect::iterator i = sectorblocks.begin();
247 i != sectorblocks.end(); ++i) {
248 MapBlock *block = *i;
251 Compare block position to camera position, skip
252 if not seen on display
255 if (block->mesh != NULL)
256 block->mesh->updateCameraOffset(m_camera_offset);
258 float range = 100000 * BS;
259 if (m_control.range_all == false)
260 range = m_control.wanted_range * BS;
263 if (!isBlockInSight(block->getPos(), camera_position,
264 camera_direction, camera_fov, range, &d))
270 Ignore if mesh doesn't exist
272 if (block->mesh == NULL) {
273 blocks_in_range_without_mesh++;
280 v3s16 cpn = block->getPos() * MAP_BLOCKSIZE;
281 cpn += v3s16(MAP_BLOCKSIZE / 2, MAP_BLOCKSIZE / 2, MAP_BLOCKSIZE / 2);
284 float startoff = BS * 1;
285 // The occlusion search of 'isOccluded()' must stop short of the target
286 // point by distance 'endoff' (end offset) to not enter the target mapblock.
287 // For the 8 mapblock corners 'endoff' must therefore be the maximum diagonal
288 // of a mapblock, because we must consider all view angles.
289 // sqrt(1^2 + 1^2 + 1^2) = 1.732
290 float endoff = -BS * MAP_BLOCKSIZE * 1.732050807569;
291 v3s16 spn = cam_pos_nodes;
292 s16 bs2 = MAP_BLOCKSIZE / 2 + 1;
293 // to reduce the likelihood of falsely occluded blocks
294 // require at least two solid blocks
295 // this is a HACK, we should think of a more precise algorithm
296 u32 needed_count = 2;
297 if (occlusion_culling_enabled &&
298 // For the central point of the mapblock 'endoff' can be halved
299 isOccluded(this, spn, cpn,
300 step, stepfac, startoff, endoff / 2.0f, needed_count, nodemgr) &&
301 isOccluded(this, spn, cpn + v3s16(bs2,bs2,bs2),
302 step, stepfac, startoff, endoff, needed_count, nodemgr) &&
303 isOccluded(this, spn, cpn + v3s16(bs2,bs2,-bs2),
304 step, stepfac, startoff, endoff, needed_count, nodemgr) &&
305 isOccluded(this, spn, cpn + v3s16(bs2,-bs2,bs2),
306 step, stepfac, startoff, endoff, needed_count, nodemgr) &&
307 isOccluded(this, spn, cpn + v3s16(bs2,-bs2,-bs2),
308 step, stepfac, startoff, endoff, needed_count, nodemgr) &&
309 isOccluded(this, spn, cpn + v3s16(-bs2,bs2,bs2),
310 step, stepfac, startoff, endoff, needed_count, nodemgr) &&
311 isOccluded(this, spn, cpn + v3s16(-bs2,bs2,-bs2),
312 step, stepfac, startoff, endoff, needed_count, nodemgr) &&
313 isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,bs2),
314 step, stepfac, startoff, endoff, needed_count, nodemgr) &&
315 isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,-bs2),
316 step, stepfac, startoff, endoff, needed_count, nodemgr)) {
317 blocks_occlusion_culled++;
321 // This block is in range. Reset usage timer.
322 block->resetUsageTimer();
324 // Limit block count in case of a sudden increase
325 blocks_would_have_drawn++;
326 if (blocks_drawn >= m_control.wanted_max_blocks &&
327 !m_control.range_all &&
328 d > m_control.wanted_range * BS)
333 m_drawlist[block->getPos()] = block;
335 sector_blocks_drawn++;
337 if (d / BS > farthest_drawn)
338 farthest_drawn = d / BS;
340 } // foreach sectorblocks
342 if (sector_blocks_drawn != 0)
343 m_last_drawn_sectors.insert(sp);
346 m_control.blocks_would_have_drawn = blocks_would_have_drawn;
347 m_control.blocks_drawn = blocks_drawn;
348 m_control.farthest_drawn = farthest_drawn;
350 g_profiler->avg("CM: blocks in range", blocks_in_range);
351 g_profiler->avg("CM: blocks occlusion culled", blocks_occlusion_culled);
352 if (blocks_in_range != 0)
353 g_profiler->avg("CM: blocks in range without mesh (frac)",
354 (float)blocks_in_range_without_mesh / blocks_in_range);
355 g_profiler->avg("CM: blocks drawn", blocks_drawn);
356 g_profiler->avg("CM: farthest drawn", farthest_drawn);
357 g_profiler->avg("CM: wanted max blocks", m_control.wanted_max_blocks);
363 std::vector<scene::IMeshBuffer*> bufs;
366 struct MeshBufListList
368 std::vector<MeshBufList> lists;
375 void add(scene::IMeshBuffer *buf)
377 for(std::vector<MeshBufList>::iterator i = lists.begin();
378 i != lists.end(); ++i){
380 video::SMaterial &m = buf->getMaterial();
382 // comparing a full material is quite expensive so we don't do it if
383 // not even first texture is equal
384 if (l.m.TextureLayer[0].Texture != m.TextureLayer[0].Texture)
388 l.bufs.push_back(buf);
393 l.m = buf->getMaterial();
394 l.bufs.push_back(buf);
399 void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
401 DSTACK(FUNCTION_NAME);
403 bool is_transparent_pass = pass == scene::ESNRP_TRANSPARENT;
406 if (pass == scene::ESNRP_SOLID)
407 prefix = "CM: solid: ";
409 prefix = "CM: transparent: ";
412 This is called two times per frame, reset on the non-transparent one
414 if (pass == scene::ESNRP_SOLID)
415 m_last_drawn_sectors.clear();
418 Get time for measuring timeout.
420 Measuring time is very useful for long delays when the
421 machine is swapping a lot.
426 Get animation parameters
428 float animation_time = m_client->getAnimationTime();
429 int crack = m_client->getCrackLevel();
430 u32 daynight_ratio = m_client->getEnv().getDayNightRatio();
432 v3f camera_position = m_camera_position;
433 v3f camera_direction = m_camera_direction;
434 f32 camera_fov = m_camera_fov;
437 Get all blocks and draw all visible ones
440 u32 vertex_count = 0;
441 u32 meshbuffer_count = 0;
443 // For limiting number of mesh animations per frame
444 u32 mesh_animate_count = 0;
445 u32 mesh_animate_count_far = 0;
447 // Blocks that were drawn and had a mesh
448 u32 blocks_drawn = 0;
449 // Blocks which had a corresponding meshbuffer for this pass
450 u32 blocks_had_pass_meshbuf = 0;
451 // Blocks from which stuff was actually drawn
452 u32 blocks_without_stuff = 0;
455 Draw the selected MapBlocks
459 ScopeProfiler sp(g_profiler, prefix + "drawing blocks", SPT_AVG);
461 MeshBufListList drawbufs;
463 for (std::map<v3s16, MapBlock*>::iterator i = m_drawlist.begin();
464 i != m_drawlist.end(); ++i) {
465 MapBlock *block = i->second;
467 // If the mesh of the block happened to get deleted, ignore it
468 if (block->mesh == NULL)
472 if (!isBlockInSight(block->getPos(), camera_position,
473 camera_direction, camera_fov, 100000 * BS, &d))
478 //MutexAutoLock lock(block->mesh_mutex);
479 MapBlockMesh *mapBlockMesh = block->mesh;
480 assert(mapBlockMesh);
481 // Pretty random but this should work somewhat nicely
482 bool faraway = d >= BS * 50;
483 //bool faraway = d >= m_control.wanted_range * BS;
484 if (mapBlockMesh->isAnimationForced() || !faraway ||
485 mesh_animate_count_far < (m_control.range_all ? 200 : 50)) {
486 bool animated = mapBlockMesh->animate(faraway, animation_time,
487 crack, daynight_ratio);
489 mesh_animate_count++;
490 if (animated && faraway)
491 mesh_animate_count_far++;
493 mapBlockMesh->decreaseAnimationForceTimer();
498 Get the meshbuffers of the block
501 //MutexAutoLock lock(block->mesh_mutex);
503 MapBlockMesh *mapBlockMesh = block->mesh;
504 assert(mapBlockMesh);
506 scene::IMesh *mesh = mapBlockMesh->getMesh();
509 u32 c = mesh->getMeshBufferCount();
510 for (u32 i = 0; i < c; i++)
512 scene::IMeshBuffer *buf = mesh->getMeshBuffer(i);
514 buf->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, m_cache_trilinear_filter);
515 buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, m_cache_bilinear_filter);
516 buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, m_cache_anistropic_filter);
517 buf->getMaterial().setFlag(video::EMF_WIREFRAME, m_control.show_wireframe);
519 const video::SMaterial& material = buf->getMaterial();
520 video::IMaterialRenderer* rnd =
521 driver->getMaterialRenderer(material.MaterialType);
522 bool transparent = (rnd && rnd->isTransparent());
523 if (transparent == is_transparent_pass) {
524 if (buf->getVertexCount() == 0)
525 errorstream << "Block [" << analyze_block(block)
526 << "] contains an empty meshbuf" << std::endl;
533 std::vector<MeshBufList> &lists = drawbufs.lists;
535 int timecheck_counter = 0;
536 for (std::vector<MeshBufList>::iterator i = lists.begin();
537 i != lists.end(); ++i) {
539 if (timecheck_counter > 50) {
540 timecheck_counter = 0;
542 if (time2 > time1 + 4) {
543 infostream << "ClientMap::renderMap(): "
544 "Rendering takes ages, returning."
550 MeshBufList &list = *i;
552 driver->setMaterial(list.m);
554 for (std::vector<scene::IMeshBuffer*>::iterator j = list.bufs.begin();
555 j != list.bufs.end(); ++j) {
556 scene::IMeshBuffer *buf = *j;
557 driver->drawMeshBuffer(buf);
558 vertex_count += buf->getVertexCount();
565 // Log only on solid pass because values are the same
566 if (pass == scene::ESNRP_SOLID) {
567 g_profiler->avg("CM: animated meshes", mesh_animate_count);
568 g_profiler->avg("CM: animated meshes (far)", mesh_animate_count_far);
571 g_profiler->avg(prefix + "vertices drawn", vertex_count);
572 if (blocks_had_pass_meshbuf != 0)
573 g_profiler->avg(prefix + "meshbuffers per block",
574 (float)meshbuffer_count / (float)blocks_had_pass_meshbuf);
575 if (blocks_drawn != 0)
576 g_profiler->avg(prefix + "empty blocks (frac)",
577 (float)blocks_without_stuff / blocks_drawn);
579 /*infostream<<"renderMap(): is_transparent_pass="<<is_transparent_pass
580 <<", rendered "<<vertex_count<<" vertices."<<std::endl;*/
583 static bool getVisibleBrightness(Map *map, v3f p0, v3f dir, float step,
584 float step_multiplier, float start_distance, float end_distance,
585 INodeDefManager *ndef, u32 daylight_factor, float sunlight_min_d,
586 int *result, bool *sunlight_seen)
588 int brightness_sum = 0;
589 int brightness_count = 0;
590 float distance = start_distance;
593 pf += dir * distance;
595 bool nonlight_seen = false;
596 bool allow_allowing_non_sunlight_propagates = false;
597 bool allow_non_sunlight_propagates = false;
598 // Check content nearly at camera position
600 v3s16 p = floatToInt(p0 /*+ dir * 3*BS*/, BS);
601 MapNode n = map->getNodeNoEx(p);
602 if(ndef->get(n).param_type == CPT_LIGHT &&
603 !ndef->get(n).sunlight_propagates)
604 allow_allowing_non_sunlight_propagates = true;
606 // If would start at CONTENT_IGNORE, start closer
608 v3s16 p = floatToInt(pf, BS);
609 MapNode n = map->getNodeNoEx(p);
610 if(n.getContent() == CONTENT_IGNORE){
612 pf = p0 + dir * 2*newd;
617 for(int i=0; distance < end_distance; i++){
620 step *= step_multiplier;
622 v3s16 p = floatToInt(pf, BS);
623 MapNode n = map->getNodeNoEx(p);
624 if(allow_allowing_non_sunlight_propagates && i == 0 &&
625 ndef->get(n).param_type == CPT_LIGHT &&
626 !ndef->get(n).sunlight_propagates){
627 allow_non_sunlight_propagates = true;
629 if(ndef->get(n).param_type != CPT_LIGHT ||
630 (!ndef->get(n).sunlight_propagates &&
631 !allow_non_sunlight_propagates)){
632 nonlight_seen = true;
638 if(distance >= sunlight_min_d && *sunlight_seen == false
639 && nonlight_seen == false)
640 if(n.getLight(LIGHTBANK_DAY, ndef) == LIGHT_SUN)
641 *sunlight_seen = true;
643 brightness_sum += decode_light(n.getLightBlend(daylight_factor, ndef));
647 if(brightness_count == 0)
649 *result = brightness_sum / brightness_count;
650 /*std::cerr<<"Sampled "<<brightness_count<<" points; result="
651 <<(*result)<<std::endl;*/
655 int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor,
656 int oldvalue, bool *sunlight_seen_result)
658 const bool debugprint = false;
659 INodeDefManager *ndef = m_gamedef->ndef();
660 static v3f z_directions[50] = {
663 static f32 z_offsets[sizeof(z_directions)/sizeof(*z_directions)] = {
666 if(z_directions[0].X < -99){
667 for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){
668 z_directions[i] = v3f(
669 0.01 * myrand_range(-100, 100),
671 0.01 * myrand_range(-100, 100)
673 z_offsets[i] = 0.01 * myrand_range(0,100);
677 std::cerr<<"In goes "<<PP(m_camera_direction)<<", out comes ";
678 int sunlight_seen_count = 0;
679 float sunlight_min_d = max_d*0.8;
680 if(sunlight_min_d > 35*BS)
681 sunlight_min_d = 35*BS;
682 std::vector<int> values;
683 for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){
684 v3f z_dir = z_directions[i];
686 core::CMatrix4<f32> a;
687 a.buildRotateFromTo(v3f(0,1,0), z_dir);
688 v3f dir = m_camera_direction;
693 step = max_d / 35 * 1.5;
694 float off = step * z_offsets[i];
695 bool sunlight_seen_now = false;
696 bool ok = getVisibleBrightness(this, m_camera_position, dir,
697 step, 1.0, max_d*0.6+off, max_d, ndef, daylight_factor,
699 &br, &sunlight_seen_now);
700 if(sunlight_seen_now)
701 sunlight_seen_count++;
704 values.push_back(br);
705 // Don't try too much if being in the sun is clear
706 if(sunlight_seen_count >= 20)
709 int brightness_sum = 0;
710 int brightness_count = 0;
711 std::sort(values.begin(), values.end());
712 u32 num_values_to_use = values.size();
713 if(num_values_to_use >= 10)
714 num_values_to_use -= num_values_to_use/2;
715 else if(num_values_to_use >= 7)
716 num_values_to_use -= num_values_to_use/3;
717 u32 first_value_i = (values.size() - num_values_to_use) / 2;
719 for(u32 i=0; i < first_value_i; i++)
720 std::cerr<<values[i]<<" ";
723 for(u32 i=first_value_i; i < first_value_i+num_values_to_use; i++){
725 std::cerr<<values[i]<<" ";
726 brightness_sum += values[i];
731 for(u32 i=first_value_i+num_values_to_use; i < values.size(); i++)
732 std::cerr<<values[i]<<" ";
735 if(brightness_count == 0){
736 MapNode n = getNodeNoEx(floatToInt(m_camera_position, BS));
737 if(ndef->get(n).param_type == CPT_LIGHT){
738 ret = decode_light(n.getLightBlend(daylight_factor, ndef));
743 /*float pre = (float)brightness_sum / (float)brightness_count;
749 ret = MYMAX(0, MYMIN(255, preint));*/
750 ret = brightness_sum / brightness_count;
753 std::cerr<<"Result: "<<ret<<" sunlight_seen_count="
754 <<sunlight_seen_count<<std::endl;
755 *sunlight_seen_result = (sunlight_seen_count > 0);
759 void ClientMap::renderPostFx(CameraMode cam_mode)
761 INodeDefManager *nodemgr = m_gamedef->ndef();
763 // Sadly ISceneManager has no "post effects" render pass, in that case we
764 // could just register for that and handle it in renderMap().
766 MapNode n = getNodeNoEx(floatToInt(m_camera_position, BS));
768 // - If the player is in a solid node, make everything black.
769 // - If the player is in liquid, draw a semi-transparent overlay.
770 // - Do not if player is in third person mode
771 const ContentFeatures& features = nodemgr->get(n);
772 video::SColor post_effect_color = features.post_effect_color;
773 if(features.solidness == 2 && !(g_settings->getBool("noclip") &&
774 m_gamedef->checkLocalPrivilege("noclip")) &&
775 cam_mode == CAMERA_MODE_FIRST)
777 post_effect_color = video::SColor(255, 0, 0, 0);
779 if (post_effect_color.getAlpha() != 0)
781 // Draw a full-screen rectangle
782 video::IVideoDriver* driver = SceneManager->getVideoDriver();
783 v2u32 ss = driver->getScreenSize();
784 core::rect<s32> rect(0,0, ss.X, ss.Y);
785 driver->draw2DRectangle(post_effect_color, rect);
789 void ClientMap::PrintInfo(std::ostream &out)