#include "profiler.h"
#include "settings.h"
#include "util/mathconstants.h"
+#include <algorithm>
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
m_camera_direction(0,0,1),
m_camera_fov(M_PI)
{
- m_camera_mutex.Init();
- assert(m_camera_mutex.IsInitialized());
-
m_box = core::aabbox3d<f32>(-BS*1000000,-BS*1000000,-BS*1000000,
BS*1000000,BS*1000000,BS*1000000);
}
{
//JMutexAutoLock lock(m_sector_mutex); // Bulk comment-out
- m_sectors.insert(p2d, sector);
+ m_sectors[p2d] = sector;
}
return sector;
INodeDefManager *nodemgr = m_gamedef->ndef();
- for(core::map<v3s16, MapBlock*>::Iterator
- i = m_drawlist.getIterator();
- i.atEnd() == false; i++)
+ for(std::map<v3s16, MapBlock*>::iterator
+ i = m_drawlist.begin();
+ i != m_drawlist.end(); ++i)
{
- MapBlock *block = i.getNode()->getValue();
+ MapBlock *block = i->second;
block->refDrop();
}
m_drawlist.clear();
//u32 blocks_had_pass_meshbuf = 0;
// Blocks from which stuff was actually drawn
//u32 blocks_without_stuff = 0;
+ // Distance to farthest drawn block
+ float farthest_drawn = 0;
- for(core::map<v2s16, MapSector*>::Iterator
- si = m_sectors.getIterator();
- si.atEnd() == false; si++)
+ for(std::map<v2s16, MapSector*>::iterator
+ si = m_sectors.begin();
+ si != m_sectors.end(); ++si)
{
- MapSector *sector = si.getNode()->getValue();
+ MapSector *sector = si->second;
v2s16 sp = sector->getPos();
if(m_control.range_all == false)
continue;
}
- core::list< MapBlock * > sectorblocks;
+ std::list< MapBlock * > sectorblocks;
sector->getBlocks(sectorblocks);
/*
u32 sector_blocks_drawn = 0;
- core::list< MapBlock * >::Iterator i;
+ std::list< MapBlock * >::iterator i;
for(i=sectorblocks.begin(); i!=sectorblocks.end(); i++)
{
MapBlock *block = *i;
sector_blocks_drawn++;
blocks_drawn++;
+ if(d/BS > farthest_drawn)
+ farthest_drawn = d/BS;
} // foreach sectorblocks
if(sector_blocks_drawn != 0)
- m_last_drawn_sectors[sp] = true;
+ m_last_drawn_sectors.insert(sp);
}
m_control.blocks_would_have_drawn = blocks_would_have_drawn;
m_control.blocks_drawn = blocks_drawn;
+ m_control.farthest_drawn = farthest_drawn;
g_profiler->avg("CM: blocks in range", blocks_in_range);
g_profiler->avg("CM: blocks occlusion culled", blocks_occlusion_culled);
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: farthest drawn", farthest_drawn);
g_profiler->avg("CM: wanted max blocks", m_control.wanted_max_blocks);
}
struct MeshBufList
{
video::SMaterial m;
- core::list<scene::IMeshBuffer*> bufs;
+ std::list<scene::IMeshBuffer*> bufs;
};
struct MeshBufListList
{
- core::list<MeshBufList> lists;
+ std::list<MeshBufList> lists;
void clear()
{
void add(scene::IMeshBuffer *buf)
{
- for(core::list<MeshBufList>::Iterator i = lists.begin();
- i != lists.end(); i++){
+ for(std::list<MeshBufList>::iterator i = lists.begin();
+ i != lists.end(); ++i){
MeshBufList &l = *i;
if(l.m == buf->getMaterial()){
l.bufs.push_back(buf);
MeshBufListList drawbufs;
- for(core::map<v3s16, MapBlock*>::Iterator
- i = m_drawlist.getIterator();
- i.atEnd() == false; i++)
+ for(std::map<v3s16, MapBlock*>::iterator
+ i = m_drawlist.begin();
+ i != m_drawlist.end(); ++i)
{
- MapBlock *block = i.getNode()->getValue();
+ MapBlock *block = i->second;
// If the mesh of the block happened to get deleted, ignore it
if(block->mesh == NULL)
}
}
- core::list<MeshBufList> &lists = drawbufs.lists;
+ std::list<MeshBufList> &lists = drawbufs.lists;
int timecheck_counter = 0;
- for(core::list<MeshBufList>::Iterator i = lists.begin();
- i != lists.end(); i++)
+ for(std::list<MeshBufList>::iterator i = lists.begin();
+ i != lists.end(); ++i)
{
{
timecheck_counter++;
driver->setMaterial(list.m);
- for(core::list<scene::IMeshBuffer*>::Iterator j = list.bufs.begin();
- j != list.bufs.end(); j++)
+ for(std::list<scene::IMeshBuffer*>::iterator j = list.bufs.begin();
+ j != list.bufs.end(); ++j)
{
scene::IMeshBuffer *buf = *j;
driver->drawMeshBuffer(buf);
float sunlight_min_d = max_d*0.8;
if(sunlight_min_d > 35*BS)
sunlight_min_d = 35*BS;
- core::array<int> values;
+ std::vector<int> values;
for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){
v3f z_dir = z_directions[i];
z_dir.normalize();
}
int brightness_sum = 0;
int brightness_count = 0;
- values.sort();
+ std::sort(values.begin(), values.end());
u32 num_values_to_use = values.size();
if(num_values_to_use >= 10)
num_values_to_use -= num_values_to_use/2;