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"
35 #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
40 MapDrawControl &control,
41 scene::ISceneNode* parent,
42 scene::ISceneManager* mgr,
45 Map(dout_client, gamedef),
46 scene::ISceneNode(parent, mgr, id),
49 m_camera_position(0,0,0),
50 m_camera_direction(0,0,1),
53 m_box = core::aabbox3d<f32>(-BS*1000000,-BS*1000000,-BS*1000000,
54 BS*1000000,BS*1000000,BS*1000000);
56 /* TODO: Add a callback function so these can be updated when a setting
57 * changes. At this point in time it doesn't matter (e.g. /set
58 * is documented to change server settings only)
60 * TODO: Local caching of settings is not optimal and should at some stage
61 * be updated to use a global settings object for getting thse values
62 * (as opposed to the this local caching). This can be addressed in
65 m_cache_trilinear_filter = g_settings->getBool("trilinear_filter");
66 m_cache_bilinear_filter = g_settings->getBool("bilinear_filter");
67 m_cache_anistropic_filter = g_settings->getBool("anisotropic_filter");
71 ClientMap::~ClientMap()
73 /*JMutexAutoLock lock(mesh_mutex);
82 MapSector * ClientMap::emergeSector(v2s16 p2d)
84 DSTACK(__FUNCTION_NAME);
85 // Check that it doesn't exist already
87 return getSectorNoGenerate(p2d);
89 catch(InvalidPositionException &e)
94 ClientMapSector *sector = new ClientMapSector(this, p2d, m_gamedef);
97 //JMutexAutoLock lock(m_sector_mutex); // Bulk comment-out
98 m_sectors[p2d] = sector;
104 void ClientMap::OnRegisterSceneNode()
108 SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID);
109 SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT);
112 ISceneNode::OnRegisterSceneNode();
115 static bool isOccluded(Map *map, v3s16 p0, v3s16 p1, float step, float stepfac,
116 float start_off, float end_off, u32 needed_count, INodeDefManager *nodemgr)
118 float d0 = (float)BS * p0.getDistanceFrom(p1);
120 v3f uf = v3f(u0.X, u0.Y, u0.Z) * BS;
122 v3f p0f = v3f(p0.X, p0.Y, p0.Z) * BS;
124 for(float s=start_off; s<d0+end_off; s+=step){
125 v3f pf = p0f + uf * s;
126 v3s16 p = floatToInt(pf, BS);
127 MapNode n = map->getNodeNoEx(p);
128 bool is_transparent = false;
129 const ContentFeatures &f = nodemgr->get(n);
131 is_transparent = (f.visual_solidness != 2);
133 is_transparent = (f.solidness != 2);
135 if(count == needed_count)
144 void ClientMap::updateDrawList(video::IVideoDriver* driver)
146 ScopeProfiler sp(g_profiler, "CM::updateDrawList()", SPT_AVG);
147 g_profiler->add("CM::updateDrawList() count", 1);
149 INodeDefManager *nodemgr = m_gamedef->ndef();
151 for(std::map<v3s16, MapBlock*>::iterator
152 i = m_drawlist.begin();
153 i != m_drawlist.end(); ++i)
155 MapBlock *block = i->second;
160 m_camera_mutex.Lock();
161 v3f camera_position = m_camera_position;
162 v3f camera_direction = m_camera_direction;
163 f32 camera_fov = m_camera_fov;
164 //v3s16 camera_offset = m_camera_offset;
165 m_camera_mutex.Unlock();
167 // Use a higher fov to accomodate faster camera movements.
168 // Blocks are cropped better when they are drawn.
169 // Or maybe they aren't? Well whatever.
172 v3s16 cam_pos_nodes = floatToInt(camera_position, BS);
173 v3s16 box_nodes_d = m_control.wanted_range * v3s16(1,1,1);
174 v3s16 p_nodes_min = cam_pos_nodes - box_nodes_d;
175 v3s16 p_nodes_max = cam_pos_nodes + box_nodes_d;
176 // Take a fair amount as we will be dropping more out later
177 // Umm... these additions are a bit strange but they are needed.
179 p_nodes_min.X / MAP_BLOCKSIZE - 3,
180 p_nodes_min.Y / MAP_BLOCKSIZE - 3,
181 p_nodes_min.Z / MAP_BLOCKSIZE - 3);
183 p_nodes_max.X / MAP_BLOCKSIZE + 1,
184 p_nodes_max.Y / MAP_BLOCKSIZE + 1,
185 p_nodes_max.Z / MAP_BLOCKSIZE + 1);
187 // Number of blocks in rendering range
188 u32 blocks_in_range = 0;
189 // Number of blocks occlusion culled
190 u32 blocks_occlusion_culled = 0;
191 // Number of blocks in rendering range but don't have a mesh
192 u32 blocks_in_range_without_mesh = 0;
193 // Blocks that had mesh that would have been drawn according to
194 // rendering range (if max blocks limit didn't kick in)
195 u32 blocks_would_have_drawn = 0;
196 // Blocks that were drawn and had a mesh
197 u32 blocks_drawn = 0;
198 // Blocks which had a corresponding meshbuffer for this pass
199 //u32 blocks_had_pass_meshbuf = 0;
200 // Blocks from which stuff was actually drawn
201 //u32 blocks_without_stuff = 0;
202 // Distance to farthest drawn block
203 float farthest_drawn = 0;
205 for(std::map<v2s16, MapSector*>::iterator
206 si = m_sectors.begin();
207 si != m_sectors.end(); ++si)
209 MapSector *sector = si->second;
210 v2s16 sp = sector->getPos();
212 if(m_control.range_all == false)
214 if(sp.X < p_blocks_min.X
215 || sp.X > p_blocks_max.X
216 || sp.Y < p_blocks_min.Z
217 || sp.Y > p_blocks_max.Z)
221 MapBlockVect sectorblocks;
222 sector->getBlocks(sectorblocks);
225 Loop through blocks in sector
228 u32 sector_blocks_drawn = 0;
230 for(MapBlockVect::iterator i = sectorblocks.begin();
231 i != sectorblocks.end(); i++)
233 MapBlock *block = *i;
236 Compare block position to camera position, skip
237 if not seen on display
240 if (block->mesh != NULL)
241 block->mesh->updateCameraOffset(m_camera_offset);
243 float range = 100000 * BS;
244 if(m_control.range_all == false)
245 range = m_control.wanted_range * BS;
248 if(isBlockInSight(block->getPos(), camera_position,
249 camera_direction, camera_fov,
255 // This is ugly (spherical distance limit?)
256 /*if(m_control.range_all == false &&
257 d - 0.5*BS*MAP_BLOCKSIZE > range)
263 Ignore if mesh doesn't exist
266 //JMutexAutoLock lock(block->mesh_mutex);
268 if(block->mesh == NULL){
269 blocks_in_range_without_mesh++;
278 // No occlusion culling when free_move is on and camera is
280 bool occlusion_culling_enabled = true;
281 if(g_settings->getBool("free_move")){
282 MapNode n = getNodeNoEx(cam_pos_nodes);
283 if(n.getContent() == CONTENT_IGNORE ||
284 nodemgr->get(n).solidness == 2)
285 occlusion_culling_enabled = false;
288 v3s16 cpn = block->getPos() * MAP_BLOCKSIZE;
289 cpn += v3s16(MAP_BLOCKSIZE/2, MAP_BLOCKSIZE/2, MAP_BLOCKSIZE/2);
292 float startoff = BS*1;
293 float endoff = -BS*MAP_BLOCKSIZE*1.42*1.42;
294 v3s16 spn = cam_pos_nodes + v3s16(0,0,0);
295 s16 bs2 = MAP_BLOCKSIZE/2 + 1;
296 u32 needed_count = 1;
298 occlusion_culling_enabled &&
299 isOccluded(this, spn, cpn + v3s16(0,0,0),
300 step, stepfac, startoff, endoff, 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)
319 blocks_occlusion_culled++;
323 // This block is in range. Reset usage timer.
324 block->resetUsageTimer();
326 // Limit block count in case of a sudden increase
327 blocks_would_have_drawn++;
328 if(blocks_drawn >= m_control.wanted_max_blocks
329 && m_control.range_all == false
330 && d > m_control.wanted_min_range * BS)
335 m_drawlist[block->getPos()] = block;
337 sector_blocks_drawn++;
339 if(d/BS > farthest_drawn)
340 farthest_drawn = d/BS;
342 } // foreach sectorblocks
344 if(sector_blocks_drawn != 0)
345 m_last_drawn_sectors.insert(sp);
348 m_control.blocks_would_have_drawn = blocks_would_have_drawn;
349 m_control.blocks_drawn = blocks_drawn;
350 m_control.farthest_drawn = farthest_drawn;
352 g_profiler->avg("CM: blocks in range", blocks_in_range);
353 g_profiler->avg("CM: blocks occlusion culled", blocks_occlusion_culled);
354 if(blocks_in_range != 0)
355 g_profiler->avg("CM: blocks in range without mesh (frac)",
356 (float)blocks_in_range_without_mesh/blocks_in_range);
357 g_profiler->avg("CM: blocks drawn", blocks_drawn);
358 g_profiler->avg("CM: farthest drawn", farthest_drawn);
359 g_profiler->avg("CM: wanted max blocks", m_control.wanted_max_blocks);
365 std::vector<scene::IMeshBuffer*> bufs;
368 struct MeshBufListList
370 std::vector<MeshBufList> lists;
377 void add(scene::IMeshBuffer *buf)
379 for(std::vector<MeshBufList>::iterator i = lists.begin();
380 i != lists.end(); ++i){
382 video::SMaterial &m = buf->getMaterial();
384 // comparing a full material is quite expensive so we don't do it if
385 // not even first texture is equal
386 if (l.m.TextureLayer[0].Texture != m.TextureLayer[0].Texture)
390 l.bufs.push_back(buf);
395 l.m = buf->getMaterial();
396 l.bufs.push_back(buf);
401 void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
403 DSTACK(__FUNCTION_NAME);
405 bool is_transparent_pass = pass == scene::ESNRP_TRANSPARENT;
408 if(pass == scene::ESNRP_SOLID)
409 prefix = "CM: solid: ";
411 prefix = "CM: transparent: ";
414 This is called two times per frame, reset on the non-transparent one
416 if(pass == scene::ESNRP_SOLID)
418 m_last_drawn_sectors.clear();
422 Get time for measuring timeout.
424 Measuring time is very useful for long delays when the
425 machine is swapping a lot.
430 Get animation parameters
432 float animation_time = m_client->getAnimationTime();
433 int crack = m_client->getCrackLevel();
434 u32 daynight_ratio = m_client->getEnv().getDayNightRatio();
436 m_camera_mutex.Lock();
437 v3f camera_position = m_camera_position;
438 v3f camera_direction = m_camera_direction;
439 f32 camera_fov = m_camera_fov;
440 m_camera_mutex.Unlock();
443 Get all blocks and draw all visible ones
446 v3s16 cam_pos_nodes = floatToInt(camera_position, BS);
448 v3s16 box_nodes_d = m_control.wanted_range * v3s16(1,1,1);
450 v3s16 p_nodes_min = cam_pos_nodes - box_nodes_d;
451 v3s16 p_nodes_max = cam_pos_nodes + box_nodes_d;
453 // Take a fair amount as we will be dropping more out later
454 // Umm... these additions are a bit strange but they are needed.
456 p_nodes_min.X / MAP_BLOCKSIZE - 3,
457 p_nodes_min.Y / MAP_BLOCKSIZE - 3,
458 p_nodes_min.Z / MAP_BLOCKSIZE - 3);
460 p_nodes_max.X / MAP_BLOCKSIZE + 1,
461 p_nodes_max.Y / MAP_BLOCKSIZE + 1,
462 p_nodes_max.Z / MAP_BLOCKSIZE + 1);
464 u32 vertex_count = 0;
465 u32 meshbuffer_count = 0;
467 // For limiting number of mesh animations per frame
468 u32 mesh_animate_count = 0;
469 u32 mesh_animate_count_far = 0;
471 // Blocks that were drawn and had a mesh
472 u32 blocks_drawn = 0;
473 // Blocks which had a corresponding meshbuffer for this pass
474 u32 blocks_had_pass_meshbuf = 0;
475 // Blocks from which stuff was actually drawn
476 u32 blocks_without_stuff = 0;
479 Draw the selected MapBlocks
483 ScopeProfiler sp(g_profiler, prefix+"drawing blocks", SPT_AVG);
485 MeshBufListList drawbufs;
487 for(std::map<v3s16, MapBlock*>::iterator
488 i = m_drawlist.begin();
489 i != m_drawlist.end(); ++i)
491 MapBlock *block = i->second;
493 // If the mesh of the block happened to get deleted, ignore it
494 if(block->mesh == NULL)
498 if(isBlockInSight(block->getPos(), camera_position,
499 camera_direction, camera_fov,
500 100000*BS, &d) == false)
507 //JMutexAutoLock lock(block->mesh_mutex);
508 MapBlockMesh *mapBlockMesh = block->mesh;
509 assert(mapBlockMesh);
510 // Pretty random but this should work somewhat nicely
511 bool faraway = d >= BS*50;
512 //bool faraway = d >= m_control.wanted_range * BS;
513 if(mapBlockMesh->isAnimationForced() ||
515 mesh_animate_count_far < (m_control.range_all ? 200 : 50))
517 bool animated = mapBlockMesh->animate(
523 mesh_animate_count++;
524 if(animated && faraway)
525 mesh_animate_count_far++;
529 mapBlockMesh->decreaseAnimationForceTimer();
534 Get the meshbuffers of the block
537 //JMutexAutoLock lock(block->mesh_mutex);
539 MapBlockMesh *mapBlockMesh = block->mesh;
540 assert(mapBlockMesh);
542 scene::IMesh *mesh = mapBlockMesh->getMesh();
545 u32 c = mesh->getMeshBufferCount();
546 for(u32 i=0; i<c; i++)
548 scene::IMeshBuffer *buf = mesh->getMeshBuffer(i);
550 buf->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, m_cache_trilinear_filter);
551 buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, m_cache_bilinear_filter);
552 buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, m_cache_anistropic_filter);
554 const video::SMaterial& material = buf->getMaterial();
555 video::IMaterialRenderer* rnd =
556 driver->getMaterialRenderer(material.MaterialType);
557 bool transparent = (rnd && rnd->isTransparent());
558 if(transparent == is_transparent_pass)
560 if(buf->getVertexCount() == 0)
561 errorstream<<"Block ["<<analyze_block(block)
562 <<"] contains an empty meshbuf"<<std::endl;
569 std::vector<MeshBufList> &lists = drawbufs.lists;
571 int timecheck_counter = 0;
572 for(std::vector<MeshBufList>::iterator i = lists.begin();
573 i != lists.end(); ++i) {
575 if(timecheck_counter > 50) {
576 timecheck_counter = 0;
578 if(time2 > time1 + 4) {
579 infostream << "ClientMap::renderMap(): "
580 "Rendering takes ages, returning."
586 MeshBufList &list = *i;
588 driver->setMaterial(list.m);
590 for(std::vector<scene::IMeshBuffer*>::iterator j = list.bufs.begin();
591 j != list.bufs.end(); ++j) {
592 scene::IMeshBuffer *buf = *j;
593 driver->drawMeshBuffer(buf);
594 vertex_count += buf->getVertexCount();
601 // Log only on solid pass because values are the same
602 if(pass == scene::ESNRP_SOLID){
603 g_profiler->avg("CM: animated meshes", mesh_animate_count);
604 g_profiler->avg("CM: animated meshes (far)", mesh_animate_count_far);
607 g_profiler->avg(prefix+"vertices drawn", vertex_count);
608 if(blocks_had_pass_meshbuf != 0)
609 g_profiler->avg(prefix+"meshbuffers per block",
610 (float)meshbuffer_count / (float)blocks_had_pass_meshbuf);
611 if(blocks_drawn != 0)
612 g_profiler->avg(prefix+"empty blocks (frac)",
613 (float)blocks_without_stuff / blocks_drawn);
615 /*infostream<<"renderMap(): is_transparent_pass="<<is_transparent_pass
616 <<", rendered "<<vertex_count<<" vertices."<<std::endl;*/
619 static bool getVisibleBrightness(Map *map, v3f p0, v3f dir, float step,
620 float step_multiplier, float start_distance, float end_distance,
621 INodeDefManager *ndef, u32 daylight_factor, float sunlight_min_d,
622 int *result, bool *sunlight_seen)
624 int brightness_sum = 0;
625 int brightness_count = 0;
626 float distance = start_distance;
629 pf += dir * distance;
631 bool nonlight_seen = false;
632 bool allow_allowing_non_sunlight_propagates = false;
633 bool allow_non_sunlight_propagates = false;
634 // Check content nearly at camera position
636 v3s16 p = floatToInt(p0 /*+ dir * 3*BS*/, BS);
637 MapNode n = map->getNodeNoEx(p);
638 if(ndef->get(n).param_type == CPT_LIGHT &&
639 !ndef->get(n).sunlight_propagates)
640 allow_allowing_non_sunlight_propagates = true;
642 // If would start at CONTENT_IGNORE, start closer
644 v3s16 p = floatToInt(pf, BS);
645 MapNode n = map->getNodeNoEx(p);
646 if(n.getContent() == CONTENT_IGNORE){
648 pf = p0 + dir * 2*newd;
653 for(int i=0; distance < end_distance; i++){
656 step *= step_multiplier;
658 v3s16 p = floatToInt(pf, BS);
659 MapNode n = map->getNodeNoEx(p);
660 if(allow_allowing_non_sunlight_propagates && i == 0 &&
661 ndef->get(n).param_type == CPT_LIGHT &&
662 !ndef->get(n).sunlight_propagates){
663 allow_non_sunlight_propagates = true;
665 if(ndef->get(n).param_type != CPT_LIGHT ||
666 (!ndef->get(n).sunlight_propagates &&
667 !allow_non_sunlight_propagates)){
668 nonlight_seen = true;
674 if(distance >= sunlight_min_d && *sunlight_seen == false
675 && nonlight_seen == false)
676 if(n.getLight(LIGHTBANK_DAY, ndef) == LIGHT_SUN)
677 *sunlight_seen = true;
679 brightness_sum += decode_light(n.getLightBlend(daylight_factor, ndef));
683 if(brightness_count == 0)
685 *result = brightness_sum / brightness_count;
686 /*std::cerr<<"Sampled "<<brightness_count<<" points; result="
687 <<(*result)<<std::endl;*/
691 int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor,
692 int oldvalue, bool *sunlight_seen_result)
694 const bool debugprint = false;
695 INodeDefManager *ndef = m_gamedef->ndef();
696 static v3f z_directions[50] = {
699 static f32 z_offsets[sizeof(z_directions)/sizeof(*z_directions)] = {
702 if(z_directions[0].X < -99){
703 for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){
704 z_directions[i] = v3f(
705 0.01 * myrand_range(-100, 100),
707 0.01 * myrand_range(-100, 100)
709 z_offsets[i] = 0.01 * myrand_range(0,100);
713 std::cerr<<"In goes "<<PP(m_camera_direction)<<", out comes ";
714 int sunlight_seen_count = 0;
715 float sunlight_min_d = max_d*0.8;
716 if(sunlight_min_d > 35*BS)
717 sunlight_min_d = 35*BS;
718 std::vector<int> values;
719 for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){
720 v3f z_dir = z_directions[i];
722 core::CMatrix4<f32> a;
723 a.buildRotateFromTo(v3f(0,1,0), z_dir);
724 v3f dir = m_camera_direction;
729 step = max_d / 35 * 1.5;
730 float off = step * z_offsets[i];
731 bool sunlight_seen_now = false;
732 bool ok = getVisibleBrightness(this, m_camera_position, dir,
733 step, 1.0, max_d*0.6+off, max_d, ndef, daylight_factor,
735 &br, &sunlight_seen_now);
736 if(sunlight_seen_now)
737 sunlight_seen_count++;
740 values.push_back(br);
741 // Don't try too much if being in the sun is clear
742 if(sunlight_seen_count >= 20)
745 int brightness_sum = 0;
746 int brightness_count = 0;
747 std::sort(values.begin(), values.end());
748 u32 num_values_to_use = values.size();
749 if(num_values_to_use >= 10)
750 num_values_to_use -= num_values_to_use/2;
751 else if(num_values_to_use >= 7)
752 num_values_to_use -= num_values_to_use/3;
753 u32 first_value_i = (values.size() - num_values_to_use) / 2;
755 for(u32 i=0; i < first_value_i; i++)
756 std::cerr<<values[i]<<" ";
759 for(u32 i=first_value_i; i < first_value_i+num_values_to_use; i++){
761 std::cerr<<values[i]<<" ";
762 brightness_sum += values[i];
767 for(u32 i=first_value_i+num_values_to_use; i < values.size(); i++)
768 std::cerr<<values[i]<<" ";
771 if(brightness_count == 0){
772 MapNode n = getNodeNoEx(floatToInt(m_camera_position, BS));
773 if(ndef->get(n).param_type == CPT_LIGHT){
774 ret = decode_light(n.getLightBlend(daylight_factor, ndef));
779 /*float pre = (float)brightness_sum / (float)brightness_count;
785 ret = MYMAX(0, MYMIN(255, preint));*/
786 ret = brightness_sum / brightness_count;
789 std::cerr<<"Result: "<<ret<<" sunlight_seen_count="
790 <<sunlight_seen_count<<std::endl;
791 *sunlight_seen_result = (sunlight_seen_count > 0);
795 void ClientMap::renderPostFx(CameraMode cam_mode)
797 INodeDefManager *nodemgr = m_gamedef->ndef();
799 // Sadly ISceneManager has no "post effects" render pass, in that case we
800 // could just register for that and handle it in renderMap().
802 m_camera_mutex.Lock();
803 v3f camera_position = m_camera_position;
804 m_camera_mutex.Unlock();
806 MapNode n = getNodeNoEx(floatToInt(camera_position, BS));
808 // - If the player is in a solid node, make everything black.
809 // - If the player is in liquid, draw a semi-transparent overlay.
810 // - Do not if player is in third person mode
811 const ContentFeatures& features = nodemgr->get(n);
812 video::SColor post_effect_color = features.post_effect_color;
813 if(features.solidness == 2 && !(g_settings->getBool("noclip") &&
814 m_gamedef->checkLocalPrivilege("noclip")) &&
815 cam_mode == CAMERA_MODE_FIRST)
817 post_effect_color = video::SColor(255, 0, 0, 0);
819 if (post_effect_color.getAlpha() != 0)
821 // Draw a full-screen rectangle
822 video::IVideoDriver* driver = SceneManager->getVideoDriver();
823 v2u32 ss = driver->getScreenSize();
824 core::rect<s32> rect(0,0, ss.X, ss.Y);
825 driver->draw2DRectangle(post_effect_color, rect);
829 void ClientMap::PrintInfo(std::ostream &out)