本文整理汇总了C++中CClientEntity::GetWorldBoundingSphere方法的典型用法代码示例。如果您正苦于以下问题:C++ CClientEntity::GetWorldBoundingSphere方法的具体用法?C++ CClientEntity::GetWorldBoundingSphere怎么用?C++ CClientEntity::GetWorldBoundingSphere使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CClientEntity
的用法示例。
在下文中一共展示了CClientEntity::GetWorldBoundingSphere方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FlushUpdateQueue
///////////////////////////////////////////////////////////////
//
// CClientSpatialDatabaseImpl::FlushUpdateQueue
//
// Process all entities that have changed since the last call
//
///////////////////////////////////////////////////////////////
void CClientSpatialDatabaseImpl::FlushUpdateQueue ( void )
{
int iTotalToUpdate = m_UpdateQueue.size ();
int iTotalUpdated = 0;
for ( std::map < CClientEntity*, int >::iterator it = m_UpdateQueue.begin (); it != m_UpdateQueue.end (); ++it )
{
CClientEntity* pEntity = it->first;
// Get the new bounding box
SEntityInfo newInfo;
CSphere sphere = pEntity->GetWorldBoundingSphere ();
newInfo.box = CBox ( sphere.vecPosition, fabsf ( sphere.fRadius ) );
// Make everything 2D for now
newInfo.box.vecMin.fZ = SPATIAL_2D_Z;
newInfo.box.vecMax.fZ = SPATIAL_2D_Z;
// Get previous info
if ( SEntityInfo* pOldInfo = MapFind ( m_InfoMap, pEntity ) )
{
// Don't update if bounding box is the same
if ( pOldInfo->box == newInfo.box )
continue;
// Remove old bounding box from tree
m_Tree.Remove ( &pOldInfo->box.vecMin.fX, &pOldInfo->box.vecMax.fX, pEntity );
}
if ( !IsValidSphere ( sphere ) )
continue;
// Add new bounding box
m_Tree.Insert( &newInfo.box.vecMin.fX, &newInfo.box.vecMax.fX, pEntity );
// Update info map
MapSet ( m_InfoMap, pEntity, newInfo );
iTotalUpdated++;
#ifdef SPATIAL_DATABASE_DEBUG_OUTPUTA
OutputDebugLine ( SString ( "SpatialDatabase::UpdateEntity %08x %2.0f,%2.0f,%2.0f %2.0f,%2.0f,%2.0f"
,pEntity
,info.box.vecMin.fX
,info.box.vecMin.fY
,info.box.vecMin.fZ
,info.box.vecMax.fX
,info.box.vecMax.fY
,info.box.vecMax.fZ
) );
#endif
}
m_UpdateQueue.clear ();
#ifdef SPATIAL_DATABASE_DEBUG_OUTPUTB
if ( iTotalToUpdate )
OutputDebugLine ( SString ( "SpatialDatabase::FlushUpdateQueue TotalToUpdate: %d TotalUpdated: %d m_InfoMap: %d tree: %d ", iTotalToUpdate, iTotalUpdated, m_InfoMap.size (), m_Tree.Count () ) );
#endif
}
示例2: FlushUpdateQueue
///////////////////////////////////////////////////////////////
//
// CClientSpatialDatabaseImpl::FlushUpdateQueue
//
// Process all entities that have changed since the last call
//
///////////////////////////////////////////////////////////////
void CClientSpatialDatabaseImpl::FlushUpdateQueue ( void )
{
std::map < CClientEntity*, int > updateQueueCopy = m_UpdateQueue;
m_UpdateQueue.clear ();
for ( std::map < CClientEntity*, int >::iterator it = updateQueueCopy.begin (); it != updateQueueCopy.end (); ++it )
{
CClientEntity* pEntity = it->first;
// Get the new bounding box
SEntityInfo newInfo;
CSphere sphere = pEntity->GetWorldBoundingSphere ();
newInfo.box = CBox ( sphere.vecPosition, fabsf ( sphere.fRadius ) );
// Make everything 2D for now
newInfo.box.vecMin.fZ = SPATIAL_2D_Z;
newInfo.box.vecMax.fZ = SPATIAL_2D_Z;
// Get previous info
if ( SEntityInfo* pOldInfo = MapFind ( m_InfoMap, pEntity ) )
{
// Don't update if bounding box is the same
if ( pOldInfo->box == newInfo.box )
continue;
// Remove old bounding box from tree
m_Tree.Remove ( &pOldInfo->box.vecMin.fX, &pOldInfo->box.vecMax.fX, pEntity );
}
if ( !IsValidSphere ( sphere ) )
continue;
// Add new bounding box
m_Tree.Insert( &newInfo.box.vecMin.fX, &newInfo.box.vecMax.fX, pEntity );
// Update info map
MapSet ( m_InfoMap, pEntity, newInfo );
}
}