///////////////////////////////////////////////////////////////
//
// CClientModelCacheManagerImpl::DoPulseVehicleModels
//
// Pulse caching system for vehicle models
//
///////////////////////////////////////////////////////////////
void CClientModelCacheManagerImpl::DoPulseVehicleModels(void)
{
    // Scale up query radius to compensate for the camera speed and possible vehicle speeds
    float fVehicleQueryRadius = VEHICLE_STREAM_IN_DISTANCE + STREAMER_STREAM_OUT_EXTRA_DISTANCE + m_fSmoothCameraSpeed * 2 + VEHICLE_MAX_VELOCITY * 2;

    // Get all entities within range
    CClientEntityResult result;
    GetClientSpatialDatabase()->SphereQuery(result, CSphere(m_vecCameraPos, fVehicleQueryRadius));

    std::vector<CClientVehicle*> vehicleList;

    // For each entity found
    for (CClientEntityResult::const_iterator iter = result.begin(); iter != result.end(); ++iter)
    {
        switch ((*iter)->GetType())
        {
            case CCLIENTVEHICLE:
                vehicleList.push_back((CClientVehicle*)*iter);
                break;
        }
    }

    // Compile a list of vehicle models which should be cached
    std::map<ushort, float> newNeedCacheList;
    ProcessVehicleList(newNeedCacheList, vehicleList, Square(VEHICLE_STREAM_IN_DISTANCE + STREAMER_STREAM_OUT_EXTRA_DISTANCE + m_fSmoothCameraSpeed * 2));

    // Apply desired caching
    m_pCoreModelCacheManager->UpdateVehicleModelCaching(newNeedCacheList);
}
Ejemplo n.º 2
0
bool CClientObjectManager::ObjectsAroundPointLoaded ( const CVector& vecPosition, float fRadius, unsigned short usDimension, SString* pstrStatus )
{
    // Get list of objects that may be intersecting the sphere
    CClientEntityResult result;
    GetClientSpatialDatabase()->SphereQuery ( result, CSphere ( vecPosition, fRadius ) );

    bool bResult = true;
    // Extract relevant types
    for ( CClientEntityResult::const_iterator it = result.begin () ; it != result.end (); ++it )
    {
        CClientEntity* pEntity = *it;
        if  ( pEntity->GetType () == CCLIENTOBJECT )
        {
            CClientObject* pObject = static_cast < CClientObject* > ( pEntity );
            if ( !pObject->GetGameObject () || !pObject->GetModelInfo ()->IsLoaded () || !pObject->IsStreamedIn () )
            {
                if ( pObject->GetDimension () == usDimension )
                {
                    // Final distance check
                    float fDistSquared = pObject->GetDistanceToBoundingBoxSquared ( vecPosition );
                    if ( fDistSquared < fRadius * fRadius )
                        bResult = false;

                    if ( pstrStatus )
                    {
                        // Debugging information
                        *pstrStatus += SString ( "ID:%05d  Dist:%4.1f  GetGameObject:%d  IsLoaded:%d  IsStreamedIn:%d\n"
                                                ,pObject->GetModel ()
                                                ,sqrtf ( fDistSquared )
                                                ,pObject->GetGameObject () ? 1 : 0
                                                ,pObject->GetModelInfo ()->IsLoaded () ? 1 : 0
                                                ,pObject->IsStreamedIn () ? 1 : 0
                                              );
                    }
                    else
                    if ( !bResult )
                        break;
                }
            }
        }
    }

    return bResult;
}