本文整理汇总了C++中CCopyEntity::Unlink方法的典型用法代码示例。如果您正苦于以下问题:C++ CCopyEntity::Unlink方法的具体用法?C++ CCopyEntity::Unlink怎么用?C++ CCopyEntity::Unlink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCopyEntity
的用法示例。
在下文中一共展示了CCopyEntity::Unlink方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeEntityTree
bool EntityManager::MakeEntityTree(BSPTree* pSrcBSPTree)
{
// Reset();
vector<EntityNode> entity_tree;
// allocate some memory in advance
// not doing this may cause error in Release build
entity_tree.reserve( 10000 );
// create the new entity tree on the temporary node buffer entity_tree
// - Do not copy the tree to m_paEntityTree until all the entities are unlinked
MakeEntityNode_r(0, pSrcBSPTree, &entity_tree);
if(entity_tree.size() == 0)
return false; // entity tree costruction failed
entity_tree[0].sParent = -1; // the root node has no parent
// unlink all the entities from the current entity tree
if( m_pEntityInUse )
{
for( CCopyEntity* pEntity = m_pEntityInUse.get();
pEntity != NULL;
pEntity = pEntity->m_pNextRawPtr )
{
pEntity->Unlink();
}
}
// Do this AFTER all the entities are unlinked from the entity nodes
SafeDeleteArray( m_paEntityTree );
// copy the new tree
m_NumEntityNodes = (int)entity_tree.size();
m_paEntityTree = new EntityNode [ m_NumEntityNodes ];
for(int i=0; i<m_NumEntityNodes; i++)
m_paEntityTree[i] = entity_tree[i];
entity_tree.clear();
// set stage and entity set
for(int i=0; i<m_NumEntityNodes; i++)
{
m_paEntityTree[i].m_pStage = m_pStage;
m_paEntityTree[i].m_pEntitySet = this;
}
// update entity tree of the render manager
m_pRenderManager->UpdateEntityTree( m_paEntityTree, m_NumEntityNodes );
WriteEntityTreeToFile( "debug/entity_tree - recreated the tree.txt" );
// re-link all the entities to the new tree nodes
if( m_pEntityInUse )
{
for( CCopyEntity* pEntity = m_pEntityInUse.get();
pEntity != NULL;
pEntity = pEntity->m_pNextRawPtr )
{
// added: 11:34 PM 5/25/2008
// Do not re-link an entity if it has already been marked as 'not in use'
// - Failure to do this leads to an invalid link in the entity tree node
// - Caused infinite loops in EntityNode::CheckPosition_r()
if( !IsValidEntity( pEntity ) )
continue;
Link( pEntity );
}
}
WriteEntityTreeToFile( "debug/entity_tree - re-linked entities to the tree.txt" );
// re-link all the light entities to the new tree nodes
// m_pLightEntityManager->RelinkLightEntities();
return true;
}