本文整理汇总了C++中MapBlock::refGrab方法的典型用法代码示例。如果您正苦于以下问题:C++ MapBlock::refGrab方法的具体用法?C++ MapBlock::refGrab怎么用?C++ MapBlock::refGrab使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapBlock
的用法示例。
在下文中一共展示了MapBlock::refGrab方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateDrawList
//.........这里部分代码省略.........
d - 0.5*BS*MAP_BLOCKSIZE > range)
continue;*/
blocks_in_range++;
/*
Ignore if mesh doesn't exist
*/
{
//JMutexAutoLock lock(block->mesh_mutex);
if(block->mesh == NULL){
blocks_in_range_without_mesh++;
continue;
}
}
/*
Occlusion culling
*/
// No occlusion culling when free_move is on and camera is
// inside ground
bool occlusion_culling_enabled = true;
if(g_settings->getBool("free_move")){
MapNode n = getNodeNoEx(cam_pos_nodes);
if(n.getContent() == CONTENT_IGNORE ||
nodemgr->get(n).solidness == 2)
occlusion_culling_enabled = false;
}
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(
occlusion_culling_enabled &&
isOccluded(this, spn, cpn + v3s16(0,0,0),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(bs2,bs2,bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(bs2,bs2,-bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(bs2,-bs2,bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(bs2,-bs2,-bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(-bs2,bs2,bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(-bs2,bs2,-bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,-bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr)
)
{
blocks_occlusion_culled++;
continue;
}
// This block is in range. Reset usage timer.
block->resetUsageTimer();
// 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
block->refGrab();
m_drawlist[block->getPos()] = block;
sector_blocks_drawn++;
blocks_drawn++;
} // foreach sectorblocks
if(sector_blocks_drawn != 0)
m_last_drawn_sectors.insert(sp);
}
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);
}
示例2: updateDrawList
//.........这里部分代码省略.........
occlusion_culling_enabled = false;
}
for (std::map<v2s16, MapSector*>::iterator si = m_sectors.begin();
si != m_sectors.end(); ++si) {
MapSector *sector = si->second;
v2s16 sp = sector->getPos();
if (m_control.range_all == false) {
if (sp.X < p_blocks_min.X || sp.X > p_blocks_max.X ||
sp.Y < p_blocks_min.Z || sp.Y > p_blocks_max.Z)
continue;
}
MapBlockVect sectorblocks;
sector->getBlocks(sectorblocks);
/*
Loop through blocks in sector
*/
u32 sector_blocks_drawn = 0;
for (MapBlockVect::iterator i = sectorblocks.begin();
i != sectorblocks.end(); ++i) {
MapBlock *block = *i;
/*
Compare block position to camera position, skip
if not seen on display
*/
if (block->mesh)
block->mesh->updateCameraOffset(m_camera_offset);
float range = 100000 * BS;
if (!m_control.range_all)
range = m_control.wanted_range * BS;
float d = 0.0;
if (!isBlockInSight(block->getPos(), camera_position,
camera_direction, camera_fov, range, &d))
continue;
blocks_in_range++;
/*
Ignore if mesh doesn't exist
*/
if (!block->mesh) {
blocks_in_range_without_mesh++;
continue;
}
/*
Occlusion culling
*/
if (occlusion_culling_enabled && isBlockOccluded(block, cam_pos_nodes)) {
blocks_occlusion_culled++;
continue;
}
// This block is in range. Reset usage timer.
block->resetUsageTimer();
// 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 &&
d > m_control.wanted_range * BS)
continue;
// Add to set
block->refGrab();
m_drawlist[block->getPos()] = block;
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.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);
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: farthest drawn", farthest_drawn);
g_profiler->avg("CM: wanted max blocks", m_control.wanted_max_blocks);
}
示例3: updateDrawList
//.........这里部分代码省略.........
// inside ground
bool occlusion_culling_enabled = true;
if(g_settings->getBool("free_move")){
MapNode n = getNodeNoEx(cam_pos_nodes);
if(n.getContent() == CONTENT_IGNORE ||
nodemgr->get(n).solidness == 2)
occlusion_culling_enabled = false;
}
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(
occlusion_culling_enabled &&
isOccluded(this, spn, cpn + v3s16(0,0,0),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(bs2,bs2,bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(bs2,bs2,-bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(bs2,-bs2,bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(bs2,-bs2,-bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(-bs2,bs2,bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(-bs2,bs2,-bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr) &&
isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,-bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr)
)
{
blocks_occlusion_culled++;
continue;
}
// This block is in range. Reset usage timer.
block->resetUsageTimer();
// 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;
if (m_control.farmesh && mesh_step != block->getMesh(mesh_step)->step) { //&& !block->mesh->transparent
m_client->addUpdateMeshTask(block->getPos(), false, mesh_step == 1);
}
block->getMesh(mesh_step)->incrementUsageTimer(dtime);
// Add to set
block->refGrab();
drawlist[block->getPos()] = block;
blocks_drawn++;
if(d/BS > farthest_drawn)
farthest_drawn = d/BS;
if (porting::getTimeMs() > end_ms) {
m_drawlist_last = n;
break;
}
}
}
if (!calls)
m_drawlist_last = 0;
if (m_drawlist_last)
return;
for (auto & ir : *m_drawlist)
ir.second->refDrop();
m_drawlist->clear();
m_drawlist = m_drawlist_current ? &m_drawlist_1 : &m_drawlist_0;
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);
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: farthest drawn", farthest_drawn);
g_profiler->avg("CM: wanted max blocks", m_control.wanted_max_blocks);
}