コード例 #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::processLoadQueues()
{
  SceneManager::CameraIterator camIt = mSceneManager->getCameraIterator();
  while (camIt.hasMoreElements()) {
    const Camera* currentCamera = camIt.getNext();
    const Vector3& cameraPos = currentCamera->getDerivedPosition();
    if (!cameraPos.isNaN()) {
      const Vector3 pos(cameraPos.x, 127.0f, cameraPos.z);

      if (!mPageLoadQueue.empty()) {
        // We Load nearest page in non-empty queue
        PagingLandScapePage* p = mPageLoadQueue.find_nearest(pos);
        if (p) {
          assert(p && !p->isLoaded ());
          assert(p->isInLoadQueue());
          p->load();
        }

        // rest of processing after eventPageLoaded received
      }
    }
  }
}