#include "mapsector.h"
#include "mapblock.h"
#include "main.h"
+#ifndef SERVER
#include "client.h"
+#endif
#include "filesys.h"
#include "utility.h"
#include "voxel.h"
#endif
#include "settings.h"
#include "log.h"
+#include "profiler.h"
+
+#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
/*
SQLite format specification:
v3s16 blockpos = getNodeBlockPos(p);
v3s16 p_rel = p - blockpos*MAP_BLOCKSIZE;
MapBlock *block = getBlockNoCreateNoEx(blockpos);
- if(block == NULL)
+ if(!block){
+ infostream<<"Map::getNodeMetadata(): Need to emerge "
+ <<PP(blockpos)<<std::endl;
+ block = emergeBlock(blockpos, false);
+ }
+ if(!block)
{
- infostream<<"WARNING: Map::setNodeMetadata(): Block not found"
+ infostream<<"WARNING: Map::getNodeMetadata(): Block not found"
<<std::endl;
return NULL;
}
v3s16 blockpos = getNodeBlockPos(p);
v3s16 p_rel = p - blockpos*MAP_BLOCKSIZE;
MapBlock *block = getBlockNoCreateNoEx(blockpos);
- if(block == NULL)
+ if(!block){
+ infostream<<"Map::setNodeMetadata(): Need to emerge "
+ <<PP(blockpos)<<std::endl;
+ block = emergeBlock(blockpos, false);
+ }
+ if(!block)
{
infostream<<"WARNING: Map::setNodeMetadata(): Block not found"
<<std::endl;
return NULL;
}
-#if 0
- /*
- Do not generate over-limit
- */
- if(p.X < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
- || p.X > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
- || p.Y < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
- || p.Y > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
- || p.Z < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
- || p.Z > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE)
- throw InvalidPositionException("emergeBlock(): pos. over limit");
-
- v2s16 p2d(p.X, p.Z);
- s16 block_y = p.Y;
- /*
- This will create or load a sector if not found in memory.
- If block exists on disk, it will be loaded.
- */
- ServerMapSector *sector;
- try{
- sector = createSector(p2d);
- //sector = emergeSector(p2d, changed_blocks);
- }
- catch(InvalidPositionException &e)
- {
- infostream<<"emergeBlock: createSector() failed: "
- <<e.what()<<std::endl;
- infostream<<"Path to failed sector: "<<getSectorDir(p2d)
- <<std::endl
- <<"You could try to delete it."<<std::endl;
- throw e;
- }
- catch(VersionMismatchException &e)
- {
- infostream<<"emergeBlock: createSector() failed: "
- <<e.what()<<std::endl;
- infostream<<"Path to failed sector: "<<getSectorDir(p2d)
- <<std::endl
- <<"You could try to delete it."<<std::endl;
- throw e;
- }
-
- /*
- Try to get a block from the sector
- */
-
- bool does_not_exist = false;
- bool lighting_expired = false;
- MapBlock *block = sector->getBlockNoCreateNoEx(block_y);
-
- // If not found, try loading from disk
- if(block == NULL)
- {
- block = loadBlock(p);
- }
-
- // Handle result
- if(block == NULL)
- {
- does_not_exist = true;
- }
- else if(block->isDummy() == true)
- {
- does_not_exist = true;
- }
- else if(block->getLightingExpired())
- {
- lighting_expired = true;
- }
- else
- {
- // Valid block
- //infostream<<"emergeBlock(): Returning already valid block"<<std::endl;
- return block;
- }
-
- /*
- If block was not found on disk and not going to generate a
- new one, make sure there is a dummy block in place.
- */
- if(only_from_disk && (does_not_exist || lighting_expired))
- {
- //infostream<<"emergeBlock(): Was not on disk but not generating"<<std::endl;
-
- if(block == NULL)
- {
- // Create dummy block
- block = new MapBlock(this, p, true);
-
- // Add block to sector
- sector->insertBlock(block);
- }
- // Done.
- return block;
- }
-
- //infostream<<"Not found on disk, generating."<<std::endl;
- // 0ms
- //TimeTaker("emergeBlock() generate");
-
- //infostream<<"emergeBlock(): Didn't find valid block -> making one"<<std::endl;
-
- /*
- If the block doesn't exist, generate the block.
- */
- if(does_not_exist)
- {
- block = generateBlock(p, block, sector, changed_blocks,
- lighting_invalidated_blocks);
- }
-
- if(lighting_expired)
- {
- lighting_invalidated_blocks.insert(p, block);
- }
-
-#if 0
- /*
- Initially update sunlight
- */
- {
- core::map<v3s16, bool> light_sources;
- bool black_air_left = false;
- bool bottom_invalid =
- block->propagateSunlight(light_sources, true,
- &black_air_left);
-
- // If sunlight didn't reach everywhere and part of block is
- // above ground, lighting has to be properly updated
- //if(black_air_left && some_part_underground)
- if(black_air_left)
- {
- lighting_invalidated_blocks[block->getPos()] = block;
- }
-
- if(bottom_invalid)
- {
- lighting_invalidated_blocks[block->getPos()] = block;
- }
- }
-#endif
-
- return block;
-}
-#endif
-
s16 ServerMap::findGroundLevel(v2s16 p2d)
{
#if 0
return;
{
- std::string dbp = m_savedir + "/map.sqlite";
+ std::string dbp = m_savedir + DIR_DELIM + "map.sqlite";
bool needs_create = false;
int d;
throw FileNotGoodException("Cannot prepare write statement");
}
+ d = sqlite3_prepare(m_database, "SELECT `pos` FROM `blocks`", -1, &m_database_list, NULL);
+ if(d != SQLITE_OK) {
+ infostream<<"WARNING: Database list statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
+ throw FileNotGoodException("Cannot prepare read statement");
+ }
+
infostream<<"Server: Database opened"<<std::endl;
}
}
bool ServerMap::loadFromFolders() {
- if(!m_database && !fs::PathExists(m_savedir + "/map.sqlite"))
+ if(!m_database && !fs::PathExists(m_savedir + DIR_DELIM + "map.sqlite"))
return true;
return false;
}
(unsigned int)pos.X&0xffff,
(unsigned int)pos.Y&0xffff);
- return m_savedir + "/sectors/" + cc;
+ return m_savedir + DIR_DELIM + "sectors" + DIR_DELIM + cc;
case 2:
- snprintf(cc, 9, "%.3x/%.3x",
+ snprintf(cc, 9, "%.3x" DIR_DELIM "%.3x",
(unsigned int)pos.X&0xfff,
(unsigned int)pos.Y&0xfff);
- return m_savedir + "/sectors2/" + cc;
+ return m_savedir + DIR_DELIM + "sectors2" + DIR_DELIM + cc;
default:
assert(false);
}
{
unsigned int x, y;
int r;
- size_t spos = dirname.rfind('/') + 1;
+ size_t spos = dirname.rfind(DIR_DELIM_C) + 1;
assert(spos != std::string::npos);
if(dirname.size() - spos == 8)
{
else if(dirname.size() - spos == 3)
{
// New layout
- r = sscanf(dirname.substr(spos-4).c_str(), "%3x/%3x", &x, &y);
+ r = sscanf(dirname.substr(spos-4).c_str(), "%3x" DIR_DELIM "%3x", &x, &y);
// Sign-extend the 12 bit values up to 16 bits...
if(x&0x800) x|=0xF000;
if(y&0x800) y|=0xF000;
}
}
+static s32 unsignedToSigned(s32 i, s32 max_positive)
+{
+ if(i < max_positive)
+ return i;
+ else
+ return i - 2*max_positive;
+}
+
+// modulo of a negative number does not work consistently in C
+static sqlite3_int64 pythonmodulo(sqlite3_int64 i, sqlite3_int64 mod)
+{
+ if(i >= 0)
+ return i % mod;
+ return mod - ((-i) % mod);
+}
+
+v3s16 ServerMap::getIntegerAsBlock(sqlite3_int64 i)
+{
+ s32 x = unsignedToSigned(pythonmodulo(i, 4096), 2048);
+ i = (i - x) / 4096;
+ s32 y = unsignedToSigned(pythonmodulo(i, 4096), 2048);
+ i = (i - y) / 4096;
+ s32 z = unsignedToSigned(pythonmodulo(i, 4096), 2048);
+ return v3s16(x,y,z);
+}
+
+void ServerMap::listAllLoadableBlocks(core::list<v3s16> &dst)
+{
+ if(loadFromFolders()){
+ errorstream<<"Map::listAllLoadableBlocks(): Result will be missing "
+ <<"all blocks that are stored in flat files"<<std::endl;
+ }
+
+ {
+ verifyDatabase();
+
+ while(sqlite3_step(m_database_list) == SQLITE_ROW)
+ {
+ sqlite3_int64 block_i = sqlite3_column_int64(m_database_list, 0);
+ v3s16 p = getIntegerAsBlock(block_i);
+ //dstream<<"block_i="<<block_i<<" p="<<PP(p)<<std::endl;
+ dst.push_back(p);
+ }
+ }
+}
+
void ServerMap::saveMapMeta()
{
DSTACK(__FUNCTION_NAME);
createDirs(m_savedir);
- std::string fullpath = m_savedir + "/map_meta.txt";
+ std::string fullpath = m_savedir + DIR_DELIM + "map_meta.txt";
std::ofstream os(fullpath.c_str(), std::ios_base::binary);
if(os.good() == false)
{
infostream<<"ServerMap::loadMapMeta(): Loading map metadata"
<<std::endl;
- std::string fullpath = m_savedir + "/map_meta.txt";
+ std::string fullpath = m_savedir + DIR_DELIM + "map_meta.txt";
std::ifstream is(fullpath.c_str(), std::ios_base::binary);
if(is.good() == false)
{
std::string dir = getSectorDir(pos);
createDirs(dir);
- std::string fullpath = dir + "/meta";
+ std::string fullpath = dir + DIR_DELIM + "meta";
std::ofstream o(fullpath.c_str(), std::ios_base::binary);
if(o.good() == false)
throw FileNotGoodException("Cannot open sector metafile");
ServerMapSector *sector = NULL;
- std::string fullpath = sectordir + "/meta";
+ std::string fullpath = sectordir + DIR_DELIM + "meta";
std::ifstream is(fullpath.c_str(), std::ios_base::binary);
if(is.good() == false)
{
createDirs(sectordir);
- std::string fullpath = sectordir+"/"+getBlockFilename(p3d);
+ std::string fullpath = sectordir+DIR_DELIM+getBlockFilename(p3d);
std::ofstream o(fullpath.c_str(), std::ios_base::binary);
if(o.good() == false)
throw FileNotGoodException("Cannot open block data");
{
DSTACK(__FUNCTION_NAME);
- std::string fullpath = sectordir+"/"+blockfile;
+ std::string fullpath = sectordir+DIR_DELIM+blockfile;
try{
std::ifstream is(fullpath.c_str(), std::ios_base::binary);
*/
std::string blockfilename = getBlockFilename(blockpos);
- if(fs::PathExists(sectordir+"/"+blockfilename) == false)
+ if(fs::PathExists(sectordir+DIR_DELIM+blockfilename) == false)
return NULL;
/*
ISceneNode::OnRegisterSceneNode();
}
+static bool isOccluded(Map *map, v3s16 p0, v3s16 p1, float step, float stepfac,
+ float start_off, float end_off, u32 needed_count)
+{
+ float d0 = (float)BS * p0.getDistanceFrom(p1);
+ v3s16 u0 = p1 - p0;
+ v3f uf = v3f(u0.X, u0.Y, u0.Z) * BS;
+ uf.normalize();
+ v3f p0f = v3f(p0.X, p0.Y, p0.Z) * BS;
+ u32 count = 0;
+ for(float s=start_off; s<d0+end_off; s+=step){
+ v3f pf = p0f + uf * s;
+ v3s16 p = floatToInt(pf, BS);
+ MapNode n = map->getNodeNoEx(p);
+ bool is_transparent = false;
+ ContentFeatures &f = content_features(n);
+ if(f.solidness == 0)
+ is_transparent = (f.visual_solidness != 2);
+ else
+ is_transparent = (f.solidness != 2);
+ if(!is_transparent){
+ count++;
+ if(count >= needed_count)
+ return true;
+ }
+ step *= stepfac;
+ }
+ return false;
+}
+
void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
{
//m_dout<<DTIME<<"Rendering map..."<<std::endl;
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
*/
Get all blocks and draw all visible ones
*/
- v3s16 cam_pos_nodes(
- camera_position.X / BS,
- camera_position.Y / BS,
- camera_position.Z / BS);
-
+ v3s16 cam_pos_nodes = floatToInt(camera_position, BS);
+
v3s16 box_nodes_d = m_control.wanted_range * v3s16(1,1,1);
v3s16 p_nodes_min = cam_pos_nodes - box_nodes_d;
v3s16 p_nodes_max = cam_pos_nodes + box_nodes_d;
// Take a fair amount as we will be dropping more out later
+ // Umm... these additions are a bit strange but they are needed.
v3s16 p_blocks_min(
- p_nodes_min.X / MAP_BLOCKSIZE - 2,
- p_nodes_min.Y / MAP_BLOCKSIZE - 2,
- p_nodes_min.Z / MAP_BLOCKSIZE - 2);
+ p_nodes_min.X / MAP_BLOCKSIZE - 3,
+ p_nodes_min.Y / MAP_BLOCKSIZE - 3,
+ p_nodes_min.Z / MAP_BLOCKSIZE - 3);
v3s16 p_blocks_max(
p_nodes_max.X / MAP_BLOCKSIZE + 1,
p_nodes_max.Y / MAP_BLOCKSIZE + 1,
p_nodes_max.Z / MAP_BLOCKSIZE + 1);
u32 vertex_count = 0;
+ u32 meshbuffer_count = 0;
// For limiting number of mesh updates per frame
u32 mesh_update_count = 0;
+ // Number of blocks in rendering range
+ u32 blocks_in_range = 0;
+ // Number of blocks occlusion culled
+ u32 blocks_occlusion_culled = 0;
+ // Number of blocks in rendering range but don't have a mesh
+ u32 blocks_in_range_without_mesh = 0;
+ // Blocks that had mesh that would have been drawn according to
+ // rendering range (if max blocks limit didn't kick in)
u32 blocks_would_have_drawn = 0;
+ // Blocks that were drawn and had a mesh
u32 blocks_drawn = 0;
+ // Blocks which had a corresponding meshbuffer for this pass
+ u32 blocks_had_pass_meshbuf = 0;
+ // Blocks from which stuff was actually drawn
+ u32 blocks_without_stuff = 0;
+
+ /*
+ Collect a set of blocks for drawing
+ */
+
+ core::map<v3s16, MapBlock*> drawset;
- int timecheck_counter = 0;
- core::map<v2s16, MapSector*>::Iterator si;
- si = m_sectors.getIterator();
- for(; si.atEnd() == false; si++)
{
- {
- timecheck_counter++;
- if(timecheck_counter > 50)
- {
- timecheck_counter = 0;
- int time2 = time(0);
- if(time2 > time1 + 4)
- {
- infostream<<"ClientMap::renderMap(): "
- "Rendering takes ages, returning."
- <<std::endl;
- return;
- }
- }
- }
+ ScopeProfiler sp(g_profiler, prefix+"collecting blocks for drawing", SPT_AVG);
+ for(core::map<v2s16, MapSector*>::Iterator
+ si = m_sectors.getIterator();
+ si.atEnd() == false; si++)
+ {
MapSector *sector = si.getNode()->getValue();
v2s16 sp = sector->getPos();
sector->getBlocks(sectorblocks);
/*
- Draw blocks
+ Loop through blocks in sector
*/
-
- u32 sector_blocks_drawn = 0;
+ u32 sector_blocks_drawn = 0;
+
core::list< MapBlock * >::Iterator i;
for(i=sectorblocks.begin(); i!=sectorblocks.end(); i++)
{
float range = 100000 * BS;
if(m_control.range_all == false)
range = m_control.wanted_range * BS;
-
+
float d = 0.0;
if(isBlockInSight(block->getPos(), camera_position,
camera_direction, camera_fov,
continue;
}
- // Okay, this block will be drawn. Reset usage timer.
- block->resetUsageTimer();
-
// This is ugly (spherical distance limit?)
/*if(m_control.range_all == false &&
d - 0.5*BS*MAP_BLOCKSIZE > range)
continue;*/
+ blocks_in_range++;
+
+ // This block is in range. Reset usage timer.
+ block->resetUsageTimer();
+
#if 1
/*
Update expired mesh (used for day/night change)
// Mesh has not been expired and there is no mesh:
// block has no content
- if(block->mesh == NULL && mesh_expired == false)
+ if(block->mesh == NULL && mesh_expired == false){
+ blocks_in_range_without_mesh++;
continue;
+ }
}
f32 faraway = BS*50;
mesh_expired = false;
}
-
#endif
+
/*
- Draw the faces of the block
+ Occlusion culling
+ */
+
+ v3s16 cpn = block->getPos() * MAP_BLOCKSIZE;
+ cpn += v3s16(MAP_BLOCKSIZE/2, MAP_BLOCKSIZE/2, MAP_BLOCKSIZE/2);
+ float step = BS*1;
+ float stepfac = 1.1;
+ float startoff = BS*1;
+ float endoff = -BS*MAP_BLOCKSIZE*1.42*1.42;
+ v3s16 spn = cam_pos_nodes + v3s16(0,0,0);
+ s16 bs2 = MAP_BLOCKSIZE/2 + 1;
+ u32 needed_count = 1;
+ if(
+ isOccluded(this, spn, cpn + v3s16(0,0,0),
+ step, stepfac, startoff, endoff, needed_count) &&
+ isOccluded(this, spn, cpn + v3s16(bs2,bs2,bs2),
+ step, stepfac, startoff, endoff, needed_count) &&
+ isOccluded(this, spn, cpn + v3s16(bs2,bs2,-bs2),
+ step, stepfac, startoff, endoff, needed_count) &&
+ isOccluded(this, spn, cpn + v3s16(bs2,-bs2,bs2),
+ step, stepfac, startoff, endoff, needed_count) &&
+ isOccluded(this, spn, cpn + v3s16(bs2,-bs2,-bs2),
+ step, stepfac, startoff, endoff, needed_count) &&
+ isOccluded(this, spn, cpn + v3s16(-bs2,bs2,bs2),
+ step, stepfac, startoff, endoff, needed_count) &&
+ isOccluded(this, spn, cpn + v3s16(-bs2,bs2,-bs2),
+ step, stepfac, startoff, endoff, needed_count) &&
+ isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,bs2),
+ step, stepfac, startoff, endoff, needed_count) &&
+ isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,-bs2),
+ step, stepfac, startoff, endoff, needed_count)
+ )
+ {
+ blocks_occlusion_culled++;
+ continue;
+ }
+
+ /*
+ Ignore if mesh doesn't exist
*/
{
JMutexAutoLock lock(block->mesh_mutex);
scene::SMesh *mesh = block->mesh;
-
- if(mesh == NULL)
- continue;
- blocks_would_have_drawn++;
- if(blocks_drawn >= m_control.wanted_max_blocks
- && m_control.range_all == false
- && d > m_control.wanted_min_range * BS)
+ if(mesh == NULL){
+ blocks_in_range_without_mesh++;
continue;
+ }
+ }
+
+ // Limit block count in case of a sudden increase
+ blocks_would_have_drawn++;
+ if(blocks_drawn >= m_control.wanted_max_blocks
+ && m_control.range_all == false
+ && d > m_control.wanted_min_range * BS)
+ continue;
+
+ // Add to set
+ drawset[block->getPos()] = block;
+
+ sector_blocks_drawn++;
+ blocks_drawn++;
- blocks_drawn++;
- sector_blocks_drawn++;
+ } // foreach sectorblocks
+
+ if(sector_blocks_drawn != 0)
+ m_last_drawn_sectors[sp] = true;
+ }
+ } // ScopeProfiler
+
+ /*
+ Draw the selected MapBlocks
+ */
- u32 c = mesh->getMeshBufferCount();
+ {
+ ScopeProfiler sp(g_profiler, prefix+"drawing blocks", SPT_AVG);
- for(u32 i=0; i<c; i++)
+ int timecheck_counter = 0;
+ for(core::map<v3s16, MapBlock*>::Iterator
+ i = drawset.getIterator();
+ i.atEnd() == false; i++)
+ {
+ {
+ timecheck_counter++;
+ if(timecheck_counter > 50)
+ {
+ timecheck_counter = 0;
+ int time2 = time(0);
+ if(time2 > time1 + 4)
{
- scene::IMeshBuffer *buf = mesh->getMeshBuffer(i);
- const video::SMaterial& material = buf->getMaterial();
- video::IMaterialRenderer* rnd =
- driver->getMaterialRenderer(material.MaterialType);
- bool transparent = (rnd && rnd->isTransparent());
- // Render transparent on transparent pass and likewise.
- if(transparent == is_transparent_pass)
- {
- /*
- This *shouldn't* hurt too much because Irrlicht
- doesn't change opengl textures if the old
- material is set again.
- */
- driver->setMaterial(buf->getMaterial());
- driver->drawMeshBuffer(buf);
- vertex_count += buf->getVertexCount();
- }
+ infostream<<"ClientMap::renderMap(): "
+ "Rendering takes ages, returning."
+ <<std::endl;
+ return;
}
}
- } // foreach sectorblocks
+ }
+
+ MapBlock *block = i.getNode()->getValue();
- if(sector_blocks_drawn != 0)
+ /*
+ Draw the faces of the block
+ */
{
- m_last_drawn_sectors[sp] = true;
+ JMutexAutoLock lock(block->mesh_mutex);
+
+ scene::SMesh *mesh = block->mesh;
+ assert(mesh);
+
+ u32 c = mesh->getMeshBufferCount();
+ bool stuff_actually_drawn = false;
+ for(u32 i=0; i<c; i++)
+ {
+ scene::IMeshBuffer *buf = mesh->getMeshBuffer(i);
+ const video::SMaterial& material = buf->getMaterial();
+ video::IMaterialRenderer* rnd =
+ driver->getMaterialRenderer(material.MaterialType);
+ bool transparent = (rnd && rnd->isTransparent());
+ // Render transparent on transparent pass and likewise.
+ if(transparent == is_transparent_pass)
+ {
+ if(buf->getVertexCount() == 0)
+ errorstream<<"Block ["<<analyze_block(block)
+ <<"] contains an empty meshbuf"<<std::endl;
+ /*
+ This *shouldn't* hurt too much because Irrlicht
+ doesn't change opengl textures if the old
+ material has the same texture.
+ */
+ driver->setMaterial(buf->getMaterial());
+ driver->drawMeshBuffer(buf);
+ vertex_count += buf->getVertexCount();
+ meshbuffer_count++;
+ stuff_actually_drawn = true;
+ }
+ }
+ if(stuff_actually_drawn)
+ blocks_had_pass_meshbuf++;
+ else
+ blocks_without_stuff++;
}
}
+ } // ScopeProfiler
+ // Log only on solid pass because values are the same
+ if(pass == scene::ESNRP_SOLID){
+ 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(prefix+"vertices drawn", vertex_count);
+ if(blocks_had_pass_meshbuf != 0)
+ g_profiler->avg(prefix+"meshbuffers per block",
+ (float)meshbuffer_count / (float)blocks_had_pass_meshbuf);
+ if(blocks_drawn != 0)
+ g_profiler->avg(prefix+"empty blocks (frac)",
+ (float)blocks_without_stuff / blocks_drawn);
+
m_control.blocks_drawn = blocks_drawn;
m_control.blocks_would_have_drawn = blocks_would_have_drawn;