コード例 #1
0
//-------------------------------------------------------------------------
PagingLandScapeTile* PagingLandScapePageManager::getTilePage(unsigned int& posx, unsigned int& posz, unsigned int pagex, unsigned int pagez)
{
  const Real tSize = mOptions->TileSize - 1;
  const Real inv_tSize = 1.0f / tSize;
  const int tilex = static_cast<int>(posx * inv_tSize);
  const int tilez = static_cast<int>(posz * inv_tSize);

  const int pSize = mOptions->PageSize - 1;
  const int tilesPerPage = static_cast<int>(mOptions->NumTiles - 1);

  unsigned int x;
  if (tilex > tilesPerPage) {
    x = static_cast<unsigned int>(tilesPerPage);
  } else if (tilex < 0) {
    x = 0;
  } else {
    x = static_cast<unsigned int>(tilex);
  }

  unsigned int z;
  if (tilez > tilesPerPage) {
    z = static_cast<unsigned int>(tilesPerPage);
  } else if (tilez < 0) {
    z = 0;
  } else {
    z = static_cast<unsigned int>(tilez);
  }
  posx = posx - static_cast<unsigned int>(x * tSize);
  posz = posz - static_cast<unsigned int>(z * tSize);
  PagingLandScapePage *p = getPage(pagex, pagez);
  if (p)
    return p->getTile(x, z);
  return 0;
}
        //-----------------------------------------------------------------------
		// Update using page local tile coordinates.
		void UpdateTile( int tileX, int tileZ )
		{
			PagingLandScapeTile* tile = page_->getTile( tileX, tileZ );
			if( tile != tile_ )
			{
				tile_ = tile;
				bool tileLoaded = tile_ && tile_->isLoaded() && tile_->getRenderable();
				renderLevel_.SetRenderLevel( (tileLoaded) ? tile_->getRenderable()->getRenderLevel() : 0 );
			}
        }