Remove GridElement

coverity_scan
scrawl 9 years ago
parent 596fe56bfd
commit 8aba74e6ee

@ -63,12 +63,6 @@ TerrainGrid::~TerrainGrid()
} }
} }
class GridElement
{
public:
osg::ref_ptr<osg::Node> mNode;
};
osg::ref_ptr<osg::Node> TerrainGrid::buildTerrain (osg::Group* parent, float chunkSize, const osg::Vec2f& chunkCenter) osg::ref_ptr<osg::Node> TerrainGrid::buildTerrain (osg::Group* parent, float chunkSize, const osg::Vec2f& chunkCenter)
{ {
if (chunkSize * mNumSplits > 1.f) if (chunkSize * mNumSplits > 1.f)
@ -208,11 +202,9 @@ void TerrainGrid::loadCell(int x, int y)
if (!terrainNode) if (!terrainNode)
return; // no terrain defined return; // no terrain defined
std::auto_ptr<GridElement> element (new GridElement); mTerrainRoot->addChild(terrainNode);
element->mNode = terrainNode;
mTerrainRoot->addChild(element->mNode);
mGrid[std::make_pair(x,y)] = element.release(); mGrid[std::make_pair(x,y)] = terrainNode;
} }
void TerrainGrid::unloadCell(int x, int y) void TerrainGrid::unloadCell(int x, int y)
@ -221,13 +213,11 @@ void TerrainGrid::unloadCell(int x, int y)
if (it == mGrid.end()) if (it == mGrid.end())
return; return;
GridElement* element = it->second; osg::Node* terrainNode = it->second;
mTerrainRoot->removeChild(element->mNode); mTerrainRoot->removeChild(terrainNode);
if (mUnrefQueue.get()) if (mUnrefQueue.get())
mUnrefQueue->push(element->mNode); mUnrefQueue->push(terrainNode);
delete element;
mGrid.erase(it); mGrid.erase(it);
} }

@ -14,8 +14,6 @@ namespace SceneUtil
namespace Terrain namespace Terrain
{ {
class GridElement;
/// @brief Simple terrain implementation that loads cells in a grid, with no LOD /// @brief Simple terrain implementation that loads cells in a grid, with no LOD
class TerrainGrid : public Terrain::World class TerrainGrid : public Terrain::World
{ {
@ -38,7 +36,7 @@ namespace Terrain
typedef std::map<std::string, osg::ref_ptr<osg::Texture2D> > TextureCache; typedef std::map<std::string, osg::ref_ptr<osg::Texture2D> > TextureCache;
TextureCache mTextureCache; TextureCache mTextureCache;
typedef std::map<std::pair<int, int>, GridElement*> Grid; typedef std::map<std::pair<int, int>, osg::ref_ptr<osg::Node> > Grid;
Grid mGrid; Grid mGrid;
osg::ref_ptr<SceneUtil::UnrefQueue> mUnrefQueue; osg::ref_ptr<SceneUtil::UnrefQueue> mUnrefQueue;

Loading…
Cancel
Save