Exemplo n.º 1
0
void CClientStreamer::AddToSortedList ( list < CClientStreamElement* > * pList, CClientStreamElement * pElement )
{
    // Make sure it's exp distance is updated
    float fDistance = pElement->GetDistanceToBoundingBoxSquared ( m_vecPosition );
    pElement->SetExpDistance ( fDistance );

    // Don't add if already in the list
    if ( ListContains ( *pList, pElement ) )
        return;

    // Search through our list. Add it behind the first item further away than this
    CClientStreamElement * pTemp = NULL;
    list < CClientStreamElement* > :: iterator iter = pList->begin ();
    for ( ; iter != pList->end (); iter++ )
    {
        pTemp = *iter;

        // Is it further than the one we add?
        if ( pTemp->GetDistanceToBoundingBoxSquared ( m_vecPosition ) > fDistance )
        {
            // Add it before here
            pList->insert ( iter, pElement );
            return;
        }
    }

    // We have no elements in the list, add it at the beginning
    pList->push_back ( pElement );
}
Exemplo n.º 2
0
void CClientStreamer::SetExpDistances ( list < CClientStreamElement * > * pList )
{
    // Run through our list setting distances to world center
    CClientStreamElement * pElement = NULL;
    list < CClientStreamElement* >:: iterator iter = pList->begin ();
    for ( ; iter != pList->end (); iter++ )
    {
        pElement = *iter;
        // Set its distance ^ 2
        pElement->SetExpDistance ( pElement->GetDistanceToBoundingBoxSquared ( m_vecPosition ) );
    }
}