📄 ogrepaginglandscapetilemanager.cpp
字号:
/***************************************************************************
OgrePagingLandScapeTileManager.cpp - description
-------------------
begin : Mon Jun 16 2003
copyright : (C) 2003 by Jose A. Milan
email : spoke2@supercable.es
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************/
#include "OgreVector3.h"
#include "OgreColourValue.h"
#include "OgreMovableObject.h"
#include "OgreAxisAlignedBox.h"
#include "OgreCamera.h"
#include "OgrePagingLandScapeOptions.h"
#include "OgrePagingLandScapeCamera.h"
#include "OgrePagingLandScapeTileManager.h"
#include "OgrePagingLandScapeTile.h"
namespace Ogre
{
//-----------------------------------------------------------------------
template<> PagingLandScapeTileManager* Singleton<PagingLandScapeTileManager>::ms_Singleton = 0;
PagingLandScapeTileManager* PagingLandScapeTileManager::getSingletonPtr(void)
{
return ms_Singleton;
}
PagingLandScapeTileManager& PagingLandScapeTileManager::getSingleton(void)
{
assert( ms_Singleton ); return ( *ms_Singleton );
}
//-----------------------------------------------------------------------
PagingLandScapeTileManager::PagingLandScapeTileManager( )
{
mNumTiles = 0;
// Add the requested initial number
_addBatch(PagingLandScapeOptions::getSingleton().num_tiles);
}
//-----------------------------------------------------------------------
PagingLandScapeTileManager::~PagingLandScapeTileManager( )
{
PagingLandScapeTileRow::iterator iend = mTiles.end();
for (PagingLandScapeTileRow::iterator i = mTiles.begin(); i != iend; ++i)
{
delete *i;
*i = 0;
}
// destroy de renderables
mTiles.clear();
}
//-----------------------------------------------------------------------
PagingLandScapeTile *PagingLandScapeTileManager::getTile( )
{
if ( mQueue.getSize() == 0 )
{
// We don磘 have more renderables, so we are going to add more
_addBatch(PagingLandScapeOptions::getSingleton().num_tiles_increment);
// Increment the next batch by a 10%
PagingLandScapeOptions::getSingleton().num_tiles_increment += uint (PagingLandScapeOptions::getSingleton().num_tiles_increment * 0.1f);
}
return mQueue.pop( );
}
//-----------------------------------------------------------------------
void PagingLandScapeTileManager::freeTile( PagingLandScapeTile *tile )
{
mQueue.push( tile );
}
//-----------------------------------------------------------------------
uint PagingLandScapeTileManager::numTiles( void ) const
{
return mNumTiles;
}
//-----------------------------------------------------------------------
int PagingLandScapeTileManager::numFree( ) const
{
return mQueue.getSize( );
}
//-----------------------------------------------------------------------
void PagingLandScapeTileManager::_addBatch(const uint num)
{
mNumTiles += num;
// mTiles.reserve (mNumTiles);
// mTiles.resize (mNumTiles);
for ( uint i = 0; i < num; i++ )
{
PagingLandScapeTile* tile = new PagingLandScapeTile( );
mTiles.push_back( tile );
mQueue.push( tile );
}
}
} //namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -