本文整理汇总了C++中MapBlock::resetUsageTimer方法的典型用法代码示例。如果您正苦于以下问题:C++ MapBlock::resetUsageTimer方法的具体用法?C++ MapBlock::resetUsageTimer怎么用?C++ MapBlock::resetUsageTimer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapBlock
的用法示例。
在下文中一共展示了MapBlock::resetUsageTimer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: step
//.........这里部分代码省略.........
/*dstream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z
<<") became active"<<std::endl;*/
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
if(block==NULL)
continue;
activateBlock(block);
}
}
/*
Mess around in active blocks
*/
if(m_active_blocks_nodemetadata_interval.step(dtime, 1.0))
{
float dtime = 1.0;
for(core::map<v3s16, bool>::Iterator
i = m_active_blocks.m_list.getIterator();
i.atEnd()==false; i++)
{
v3s16 p = i.getNode()->getKey();
/*dstream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z
<<") being handled"<<std::endl;*/
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
if(block==NULL)
continue;
// Reset block usage timer
block->resetUsageTimer();
// Set current time as timestamp
block->setTimestampNoChangedFlag(m_game_time);
// Run node metadata
bool changed = block->m_node_metadata.step(dtime);
if(changed)
{
MapEditEvent event;
event.type = MEET_BLOCK_NODE_METADATA_CHANGED;
event.p = p;
m_map->dispatchEvent(&event);
block->setChangedFlag();
}
}
}
if(m_active_blocks_test_interval.step(dtime, 10.0))
{
//float dtime = 10.0;
for(core::map<v3s16, bool>::Iterator
i = m_active_blocks.m_list.getIterator();
i.atEnd()==false; i++)
{
v3s16 p = i.getNode()->getKey();
/*dstream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z
<<") being handled"<<std::endl;*/
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
if(block==NULL)
示例2: 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);
}
示例3: GetNextBlocks
//.........这里部分代码省略.........
// If this is true, inexistent block will be made from scratch
bool generate = d <= d_max_gen;
/*
Don't generate or send if not in sight
FIXME This only works if the client uses a small enough
FOV setting. The default of 72 degrees is fine.
*/
f32 dist;
if (!isBlockInSight(p, camera_pos, camera_dir, camera_fov, d_blocks_in_sight, &dist)) {
continue;
}
/*
Don't send already sent blocks
*/
{
if(m_blocks_sent.find(p) != m_blocks_sent.end())
{
continue;
}
}
/*
Check if map has this block
*/
MapBlock *block = env->getMap().getBlockNoCreateNoEx(p);
bool surely_not_found_on_disk = false;
bool block_is_invalid = false;
if (block) {
// Reset usage timer, this block will be of use in the future.
block->resetUsageTimer();
// Block is dummy if data doesn't exist.
// It means it has been not found from disk and not generated
if (block->isDummy()) {
surely_not_found_on_disk = true;
}
if (!block->isGenerated())
block_is_invalid = true;
/*
If block is not close, don't send it unless it is near
ground level.
Block is near ground level if night-time mesh
differs from day-time mesh.
*/
if (d >= d_opt) {
if (!block->getDayNightDiff())
continue;
}
if (occ_cull && !block_is_invalid &&
env->getMap().isBlockOccluded(block, cam_pos_nodes)) {
continue;
}
}
/*
If block has been marked to not exist on disk (dummy)
and generating new ones is not wanted, skip block.
*/
示例4: 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);
}
示例5: GetNextBlocks
//.........这里部分代码省略.........
FOV setting. The default of 72 degrees is fine.
*/
float camera_fov = (80.0*M_PI/180) * 4./3.;
if(can_skip && isBlockInSight(p, camera_pos, camera_dir, camera_fov, 10000*BS) == false)
{
continue;
}
/*
Don't send already sent blocks
*/
{
if(m_blocks_sent.find(p) != m_blocks_sent.end() && m_blocks_sent[p] > 0 && m_blocks_sent[p] + (d <= 2 ? 1 : d*d*d) > m_uptime) {
continue;
}
}
/*
Check if map has this block
*/
MapBlock *block = env->getMap().getBlockNoCreateNoEx(p);
bool surely_not_found_on_disk = false;
bool block_is_invalid = false;
if(block != NULL)
{
if (m_blocks_sent[p] > 0 && m_blocks_sent[p] >= block->m_changed_timestamp) {
continue;
}
// Reset usage timer, this block will be of use in the future.
block->resetUsageTimer();
// Block is dummy if data doesn't exist.
// It means it has been not found from disk and not generated
if(block->isDummy())
{
surely_not_found_on_disk = true;
}
if (block->getLightingExpired()) {
continue;
}
// Block is valid if lighting is up-to-date and data exists
if(block->isValid() == false)
{
block_is_invalid = true;
}
if(block->isGenerated() == false)
{
continue;
}
/*
If block is not close, don't send it unless it is near
ground level.
Block is near ground level if night-time mesh
differs from day-time mesh.
*/
/*
if(d >= 4)
{
示例6: renderMap
//.........这里部分代码省略.........
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;
// Mesh animation
{
//JMutexAutoLock lock(block->mesh_mutex);
MapBlockMesh *mapBlockMesh = block->mesh;
// Pretty random but this should work somewhat nicely
bool faraway = d >= BS*50;
//bool faraway = d >= m_control.wanted_range * BS;
if(mapBlockMesh->isAnimationForced() ||
!faraway ||
mesh_animate_count_far < (m_control.range_all ? 200 : 50))
{
bool animated = mapBlockMesh->animate(
faraway,
animation_time,
crack,
daynight_ratio);
if(animated)
mesh_animate_count++;
if(animated && faraway)
mesh_animate_count_far++;
}
else
{
mapBlockMesh->decreaseAnimationForceTimer();
示例7: GetNextBlocks
//.........这里部分代码省略.........
auto lock = env->getServerMap().m_nothread_locker.lock_shared_rec();
#endif
//VERY BAD COPYPASTE FROM clientmap.cpp!
if( d >= 1 &&
occlusion_culling_enabled &&
isOccluded(&env->getMap(), spn, cpn + v3POS(0,0,0),
step, stepfac, startoff, endoff, needed_count, nodemgr, occlude_cache) &&
isOccluded(&env->getMap(), spn, cpn + v3POS(bs2,bs2,bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr, occlude_cache) &&
isOccluded(&env->getMap(), spn, cpn + v3POS(bs2,bs2,-bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr, occlude_cache) &&
isOccluded(&env->getMap(), spn, cpn + v3POS(bs2,-bs2,bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr, occlude_cache) &&
isOccluded(&env->getMap(), spn, cpn + v3POS(bs2,-bs2,-bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr, occlude_cache) &&
isOccluded(&env->getMap(), spn, cpn + v3POS(-bs2,bs2,bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr, occlude_cache) &&
isOccluded(&env->getMap(), spn, cpn + v3POS(-bs2,bs2,-bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr, occlude_cache) &&
isOccluded(&env->getMap(), spn, cpn + v3POS(-bs2,-bs2,bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr, occlude_cache) &&
isOccluded(&env->getMap(), spn, cpn + v3POS(-bs2,-bs2,-bs2),
step, stepfac, startoff, endoff, needed_count, nodemgr, occlude_cache)
)
{
//infostream<<" occlusion player="<<cam_pos_nodes<<" d="<<d<<" block="<<cpn<<" total="<<blocks_occlusion_culled<<"/"<<num_blocks_selected<<std::endl;
g_profiler->add("SMap: Occlusion skip", 1);
blocks_occlusion_culled++;
continue;
}
}
// Reset usage timer, this block will be of use in the future.
block->resetUsageTimer();
if (block->getLightingExpired()) {
//env->getServerMap().lighting_modified_blocks.set(p, nullptr);
env->getServerMap().lighting_modified_add(p, d);
}
if (block->lighting_broken > 0 && (block_sent || d > 0))
continue;
// Block is valid if lighting is up-to-date and data exists
if(block->isValid() == false)
{
block_is_invalid = true;
}
if(block->isGenerated() == false)
{
continue;
}
/*
If block is not close, don't send it unless it is near
ground level.
Block is near ground level if night-time mesh
differs from day-time mesh.
*/
/*
if(d >= 4)
{
if(block->getDayNightDiff() == false)
continue;
示例8: 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);
}