コード例 #1
0
//-----------------------------------------------------------------------
void PagingLandScapePageManager::queuePageNeighbors()
{
  // Queue the rest				
  // Loading  must be done one by one to avoid FPS drop, so they are queued.
  // We must load the next visible LandScape pages, 
  // check the LandScape boundaries	

  for (unsigned int i = mCurrentcam->mPreIniX; i <= mCurrentcam->mPreFinX; i++) {
    for (unsigned int j = mCurrentcam->mPreIniZ; j <= mCurrentcam->mPreFinZ; j++) {
      // pages in this zone around camera, must be at
      // least preloading.  that means they can be
      // loaded too.
      PagingLandScapePage* p = getPage(i, j, true);

      if (!(p->isInLoadQueue() || p->isLoaded())) {
        if ((j >= mCurrentcam->mIniZ) && (j <= mCurrentcam->mFinZ) && (i >= mCurrentcam->mIniX) && (i <= mCurrentcam->mFinX)) {
          // pages in this tighter zone
          // around camera must be Loading
          // or Loaded as they may be
          // below camera very soon.
          removeFromQueues(p);
          mPageLoadQueue.push(p);
          p->setInQueue(PagingLandScapePage::QUEUE_LOAD);
        } else {
          // must be at least preloading
          p->preloadInBackground();
        }
      }

      p->touch();
    }
  }
}
コード例 #2
0
//-----------------------------------------------------------------------
void PagingLandScapePageManager::processUnloadQueues()
{
  // Check for pages that need to be unloaded.
  // if touched, that means they didn't have been touch by any cameras
  // for several frames and thus need to be unloaded.

  // LIST CHECKS
  for (PagingLandScapePageList::iterator itl = mLoadedPages.begin(); itl != mLoadedPages.end();) {
    if ((*itl)->unloadUntouched()) {
      releasePage(*itl);
      itl = mLoadedPages.erase(itl);
    } else {
      ++itl;
    }
  }

  // QUEUES CHECKS
  // check queues for page that need to be excluded from queues
  PagingLandScapePage* p = 0;
  for (PagingLandScapeQueue<PagingLandScapePage>::MsgQueType::iterator itq = mPageLoadQueue.begin(); itq != mPageLoadQueue.end();) {
    assert(!(*itq)->isLoaded());
    assert((*itq)->isInLoadQueue());
    if ((*itq)->unloadUntouched()) {
      p = *itq;
      // remove from queue
      p->setInQueue(PagingLandScapePage::QUEUE_NONE);
      itq = mPageLoadQueue.erase(itq);
      // remove from active pages 
      //(must be removed from queue first)				 
      releasePage(p);
    } else {
      ++itq;
    }
  }
}
コード例 #3
0
//-----------------------------------------------------------------------
void PagingLandScapePageManager::LoadFirstPage(PagingLandScapeCamera* cam)
{

  const Vector3 CamPos = cam->getDerivedPosition();
  //gets page indices (if outside Terrain gets nearest page)
  unsigned int i, j;
  getPageIndices(CamPos.x, CamPos.z, i, j, true);
  // update the camera page position
  // does modify mIniX, mFinX, mIniZ, mFinZ

  PagingLandScapePage* p = getPage(i, j, false);
  if (p) {
    mPageLoadQueue.push(p);
    p->setInQueue(PagingLandScapePage::QUEUE_LOAD);
  }
}