//-----------------------------------------------------------------------
	void PagingLandScapeRenderableManager::processTileUnload()
	{
		if (mTilesLoadRenderableQueue.empty())
			return;

		PagingLandScapeTile *tile;
		for (PagingLandScapeQueue<PagingLandScapeTile>::MsgQueType::iterator itq = mTilesLoadRenderableQueue.begin(); 
			itq != mTilesLoadRenderableQueue.end();)
		{
			tile = *itq;
			assert (tile != 0);

			assert (tile->isLoading());
			assert (tile->getRenderable ());
			assert (tile->getRenderable ()->mQueued);

			assert (tile->isLoaded ());       
			assert (tile->getSceneNode());
			assert (!tile->getRenderable ()->isLoaded ()); 

			if (!tile->getRenderable ()->isInUse ())
            {
				tile->setLoading (false);
				tile->getRenderable ()->mQueued = false;
                tile->unload (); 
				itq = mTilesLoadRenderableQueue.erase (itq);
			}
			else
			{
				++itq;
			}
		}
	}
        //-----------------------------------------------------------------------
		// 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 );
			}
        }
Ejemplo n.º 3
0
	//-----------------------------------------------------------------------
	void PagingLandScapePage::updateTerrain()
	{
		const unsigned int size = mPageMgr.getOptions()->TileSize - 1;
		for (size_t i = 0; i < mTiles.size(); ++i) {
			for (size_t j = 0; j < mTiles[i].size(); ++j) {
				PagingLandScapeTile* tile = mTiles[i][j];
				// we need to adjust the deformation rectangle for the whole tile/renderable so to force a recalculation of the bounding box and the LOD calculation
				if (tile->getRenderable()) {
					tile->getRenderable()->adjustDeformationRectangle(0, 0);
					tile->getRenderable()->adjustDeformationRectangle(size, size);
					tile->updateTerrain();
				}
			}
		}
	}
//-----------------------------------------------------------------------
void PagingLandScapeTile::_linkRenderableNeighbor()
{
	PLSM2_ASSERT (mLoaded && mRenderable);
	PagingLandScapeRenderable *n;
	PagingLandScapeTile *t = mNeighbors[SOUTH];
	if (t && t->mLoaded)
	{
		n = t->getRenderable();
		PLSM2_ASSERT (n);
		mRenderable->_setNeighbor (SOUTH, n);
		n->_setNeighbor (NORTH, mRenderable); 
	}
	t = mNeighbors[NORTH];
	if (t && t->mLoaded)
	{
		n = t->getRenderable();
		PLSM2_ASSERT (n);
		mRenderable->_setNeighbor (NORTH, n);
		n->_setNeighbor (SOUTH, mRenderable);
	}
	t = mNeighbors[EAST];
	if (t && t->mLoaded)
	{
		n = t->getRenderable();
		PLSM2_ASSERT (n);
		mRenderable->_setNeighbor (EAST, n);
		n->_setNeighbor (WEST, mRenderable);
	}
	t = mNeighbors[WEST];
	if (t && t->mLoaded)
	{
		n = t->getRenderable();
		PLSM2_ASSERT (n);
		mRenderable->_setNeighbor (WEST, n); 
		n->_setNeighbor (EAST, mRenderable);
	}
}
    //-----------------------------------------------------------------------
    bool PagingLandScapeRenderableManager::executeRenderableLoading(void)
    {
        if (mTilesLoadQueue.empty())
            return true;	
        else
        { 
            const uint k = PagingLandScapeOptions::getSingleton ().num_renderables_loading;
            for (uint i = 0; i < k; i++ )
            {
                PagingLandScapeTile* tile = mTilesLoadQueue.pop ();

                // no more in queues.
                if (tile == 0)
                    return true;

                assert (tile->isLoaded ());           
                           
                PagingLandScapeRenderable* rend = tile->getRenderable();

                assert (!rend->isLoaded ());      
                SceneNode * tileSceneNode = tile->getTileNode ();

                assert (rend != 0 && tileSceneNode != 0);

                tileSceneNode->attachObject( rend );
                // renderables need to be attached (BBox compute)
                if (rend->load())
                {
                    tile->_linkRenderableNeighbor ();
                }
                else
                {
                    // renderable have been unloaded since.
                    tile->unload ();
                }
                tileSceneNode->needUpdate();
            }
        }
        return false;
    }
Ejemplo n.º 6
0
    //-----------------------------------------------------------------------
    bool PagingLandScapeData2D::setHeight( const uint x, const uint z,
                                           const uint Pos, const Real h )
    {
        if (mHeightData[Pos] != h)
        {
	        mHeightData[ Pos ] = h;    

		    uint tileposx = x;
		    uint tileposz = z;
		// Make position local to tiles.
		// and return a Tile.
	        PagingLandScapeTile *t = 
		    PagingLandScapePageManager::getSingleton().getTilePage(tileposx, tileposz, 
									mPageX, mPageZ);
	        if (t && t->isLoaded ())
	        { 
		        // tells what tile portion needs to be updated.
	            PagingLandScapeRenderable * const r = t->getRenderable ();                
		        r->adjustDeformationRectangle (tileposx, tileposz); 
        		
		        const uint tSize = PagingLandScapeOptions::getSingleton ().TileSize - 1;
		        const uint NumTiles = PagingLandScapeOptions::getSingleton ().NumTiles;

                const PagingLandScapeTileInfo * const info =  t->getInfo();
                const uint tX = info->tileX;
                const uint tZ = info->tileZ;

                // If we're on a page edge, we must duplicate the change on the 
                // neighbour tile (if it has one...)
                // could be a direct neighbour or a diagonal one (in a corner.)
                const bool left  = (tileposx == 0     && tX != 0);
                const bool right = (tileposx == tSize && tX != NumTiles - 1);
                const bool down  = (tileposz == 0     && tZ != 0);
                const bool up    = (tileposz == tSize && tZ != NumTiles - 1);


		        if (left)
		        { 
			        PagingLandScapeRenderable * const rn = r->_getNeighbor(WEST);
                    if (rn)
                    {
                        if (down)
                        {
                            PagingLandScapeRenderable * const rnUp = rn->_getNeighbor(NORTH);
                            if (rnUp && rnUp->isLoaded ())
	                        { 
                                rnUp->adjustDeformationRectangle (tSize, tSize); 
                            }
                        }
                        else  if (up)
                        {
                            PagingLandScapeRenderable * const rnDown = rn->_getNeighbor(SOUTH);
                            if (rnDown && rnDown->isLoaded ())
	                        { 
                                rnDown->adjustDeformationRectangle (tSize, 0); 
                            }
                        }
			            if (rn->isLoaded ())
			            { 
			                rn->adjustDeformationRectangle (tSize, tileposz); 
			            }
                    }
		        }
                else  if (right)
                {
                    PagingLandScapeRenderable * const rn = r->_getNeighbor(EAST);
                    if (rn)
	                { 
                        if (down)
                        {
                            PagingLandScapeRenderable * const rnUp = rn->_getNeighbor(NORTH);
                            if (rnUp && rnUp->isLoaded ())
	                        { 
                                rnUp->adjustDeformationRectangle (0, tSize); 
                            }
                        }
                        else  if (up)
                        {
                            PagingLandScapeRenderable * const rnDown = rn->_getNeighbor(SOUTH);
                            if (rnDown && rnDown->isLoaded ())
	                        { 
                                rnDown->adjustDeformationRectangle (0, 0); 
                            }
                        }
                        if (rn)
	                    { 
                            rn->adjustDeformationRectangle (0, tileposz); 
                        }
                    }
                }
                if (down)
                {
                    PagingLandScapeRenderable * const rn = r->_getNeighbor(NORTH);
                    if (rn && rn->isLoaded ())
	                { 
                        rn->adjustDeformationRectangle (tileposx, tSize); 
                    }
                }
                else  if (up)
                {
                    PagingLandScapeRenderable * const rn = r->_getNeighbor(SOUTH);
                    if (rn && rn->isLoaded ())
	                { 
                        rn->adjustDeformationRectangle (tileposx, 0); 
                    }
                }
	        }
    	
	        adjustDeformationRectangle (x, z);
            return true;
        }
       return false;
    }