本文整理汇总了C++中MapBlock::setMeshExpired方法的典型用法代码示例。如果您正苦于以下问题:C++ MapBlock::setMeshExpired方法的具体用法?C++ MapBlock::setMeshExpired怎么用?C++ MapBlock::setMeshExpired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapBlock
的用法示例。
在下文中一共展示了MapBlock::setMeshExpired方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addUpdateMeshTask
void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server)
{
/*infostream<<"Client::addUpdateMeshTask(): "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;*/
MapBlock *b = m_env.getMap().getBlockNoCreateNoEx(p);
if(b == NULL)
return;
/*
Create a task to update the mesh of the block
*/
MeshMakeData *data = new MeshMakeData;
{
//TimeTaker timer("data fill");
// Release: ~0ms
// Debug: 1-6ms, avg=2ms
data->fill(getDayNightRatio(), b);
}
// Debug wait
//while(m_mesh_update_thread.m_queue_in.size() > 0) sleep_ms(10);
// Add task to queue
m_mesh_update_thread.m_queue_in.addBlock(p, data, ack_to_server);
/*infostream<<"Mesh update input queue size is "
<<m_mesh_update_thread.m_queue_in.size()
<<std::endl;*/
#if 0
// Temporary test: make mesh directly in here
{
//TimeTaker timer("make mesh");
// 10ms
scene::SMesh *mesh_new = NULL;
mesh_new = makeMapBlockMesh(data);
b->replaceMesh(mesh_new);
delete data;
}
#endif
/*
Mark mesh as non-expired at this point so that it can already
be marked as expired again if the data changes
*/
b->setMeshExpired(false);
}
示例2: step
//.........这里部分代码省略.........
u16 damage = (u16)(damage_f+0.5);
if(lplayer->hp > damage)
lplayer->hp -= damage;
else
lplayer->hp = 0;
ClientEnvEvent event;
event.type = CEE_PLAYER_DAMAGE;
event.player_damage.amount = damage;
m_client_event_queue.push_back(event);
}
}
}
/*
Stuff that can be done in an arbitarily large dtime
*/
for(core::list<Player*>::Iterator i = m_players.begin();
i != m_players.end(); i++)
{
Player *player = *i;
v3f playerpos = player->getPosition();
/*
Handle non-local players
*/
if(player->isLocal() == false)
{
// Move
player->move(dtime, *m_map, 100*BS);
// Update lighting on remote players on client
u8 light = LIGHT_MAX;
try{
// Get node at head
v3s16 p = floatToInt(playerpos + v3f(0,BS+BS/2,0), BS);
MapNode n = m_map->getNode(p);
light = n.getLightBlend(getDayNightRatio());
}
catch(InvalidPositionException &e) {}
player->updateLight(light);
}
/*
Add footsteps to grass
*/
if(footprints)
{
// Get node that is at BS/4 under player
v3s16 bottompos = floatToInt(playerpos + v3f(0,-BS/4,0), BS);
try{
MapNode n = m_map->getNode(bottompos);
if(n.getContent() == CONTENT_GRASS)
{
n.setContent(CONTENT_GRASS_FOOTSTEPS);
m_map->setNode(bottompos, n);
// Update mesh on client
if(m_map->mapType() == MAPTYPE_CLIENT)
{
v3s16 p_blocks = getNodeBlockPos(bottompos);
MapBlock *b = m_map->getBlockNoCreate(p_blocks);
//b->updateMesh(getDayNightRatio());
b->setMeshExpired(true);
}
}
}
catch(InvalidPositionException &e)
{
}
}
}
/*
Step active objects and update lighting of them
*/
for(core::map<u16, ClientActiveObject*>::Iterator
i = m_active_objects.getIterator();
i.atEnd()==false; i++)
{
ClientActiveObject* obj = i.getNode()->getValue();
// Step object
obj->step(dtime, this);
if(m_active_object_light_update_interval.step(dtime, 0.21))
{
// Update lighting
//u8 light = LIGHT_MAX;
u8 light = 0;
try{
// Get node at head
v3s16 p = obj->getLightPosition();
MapNode n = m_map->getNode(p);
light = n.getLightBlend(getDayNightRatio());
}
catch(InvalidPositionException &e) {}
obj->updateLight(light);
}
}
}