+
+ m_control.blocks_would_have_drawn = blocks_would_have_drawn;
+ m_control.blocks_drawn = blocks_drawn;
+
+ g_profiler->avg("CM: blocks in range", blocks_in_range);
+ g_profiler->avg("CM: blocks occlusion culled", blocks_occlusion_culled);
+ if(blocks_in_range != 0)
+ g_profiler->avg("CM: blocks in range without mesh (frac)",
+ (float)blocks_in_range_without_mesh/blocks_in_range);
+ g_profiler->avg("CM: blocks drawn", blocks_drawn);
+ g_profiler->avg("CM: wanted max blocks", m_control.wanted_max_blocks);
+}
+
+struct MeshBufList
+{
+ video::SMaterial m;
+ core::list<scene::IMeshBuffer*> bufs;
+};
+
+struct MeshBufListList
+{
+ core::list<MeshBufList> lists;
+
+ void clear()
+ {
+ lists.clear();
+ }
+
+ void add(scene::IMeshBuffer *buf)
+ {
+ for(core::list<MeshBufList>::Iterator i = lists.begin();
+ i != lists.end(); i++){
+ MeshBufList &l = *i;
+ if(l.m == buf->getMaterial()){
+ l.bufs.push_back(buf);
+ return;
+ }
+ }
+ MeshBufList l;
+ l.m = buf->getMaterial();
+ l.bufs.push_back(buf);
+ lists.push_back(l);
+ }
+};
+
+void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
+{
+ DSTACK(__FUNCTION_NAME);
+
+ bool is_transparent_pass = pass == scene::ESNRP_TRANSPARENT;
+
+ std::string prefix;
+ if(pass == scene::ESNRP_SOLID)
+ prefix = "CM: solid: ";
+ else
+ prefix = "CM: transparent: ";
+
+ /*
+ This is called two times per frame, reset on the non-transparent one
+ */
+ if(pass == scene::ESNRP_SOLID)
+ {
+ m_last_drawn_sectors.clear();
+ }
+
+ bool use_trilinear_filter = g_settings->getBool("trilinear_filter");
+ bool use_bilinear_filter = g_settings->getBool("bilinear_filter");
+ bool use_anisotropic_filter = g_settings->getBool("anisotropic_filter");
+
+ /*
+ Get time for measuring timeout.
+
+ Measuring time is very useful for long delays when the
+ machine is swapping a lot.
+ */
+ int time1 = time(0);
+
+ /*
+ Get animation parameters
+ */
+ float animation_time = m_client->getAnimationTime();
+ int crack = m_client->getCrackLevel();
+ u32 daynight_ratio = m_client->getEnv().getDayNightRatio();
+
+ m_camera_mutex.Lock();
+ v3f camera_position = m_camera_position;
+ v3f camera_direction = m_camera_direction;
+ f32 camera_fov = m_camera_fov;
+ m_camera_mutex.Unlock();
+
+ /*
+ Get all blocks and draw all visible ones
+ */
+
+ v3s16 cam_pos_nodes = floatToInt(camera_position, BS);