diff --git a/include/osgVolume/VolumeScene b/include/osgVolume/VolumeScene index 9f32ff35e..8e3e64199 100644 --- a/include/osgVolume/VolumeScene +++ b/include/osgVolume/VolumeScene @@ -44,16 +44,28 @@ class OSGVOLUME_EXPORT VolumeScene : public osg::Group struct TileData : public osg::Referenced { + TileData() : active(false) {} + + bool active; + osg::NodePath nodePath; osg::ref_ptr projectionMatrix; osg::ref_ptr modelviewMatrix; + + osg::ref_ptr depthTexture; + osg::ref_ptr rttCamera; + osg::ref_ptr stateset; }; - typedef std::list< osg::ref_ptr > Tiles; + typedef std::map< VolumeTile*, osg::ref_ptr > Tiles; class ViewData : public osg::Referenced { public: ViewData(); + + void clearTiles(); + void visitTile(VolumeTile* tile); + osg::ref_ptr _depthTexture; osg::ref_ptr _colorTexture; osg::ref_ptr _rttCamera; diff --git a/src/osgVolume/VolumeScene.cpp b/src/osgVolume/VolumeScene.cpp index 56bd29c45..afdb8515a 100644 --- a/src/osgVolume/VolumeScene.cpp +++ b/src/osgVolume/VolumeScene.cpp @@ -53,6 +53,19 @@ VolumeScene::ViewData::ViewData() { } +void VolumeScene::ViewData::clearTiles() +{ + for(Tiles::iterator itr = _tiles.begin(); + itr != _tiles.end(); + ++itr) + { + if (itr->second.valid()) itr->second->active = false; + } +} + +void VolumeScene::ViewData::visitTile(VolumeTile* tile) +{ +} VolumeScene::VolumeScene() { @@ -82,11 +95,12 @@ void VolumeScene::tileVisited(osg::NodeVisitor* nv, osgVolume::VolumeTile* tile) if (viewData.valid()) { - osg::ref_ptr tileData = new TileData; + osg::ref_ptr& tileData = viewData->_tiles[tile]; + if (!tileData) tileData = new TileData; + tileData->active = true; tileData->nodePath = cv->getNodePath(); tileData->projectionMatrix = cv->getProjectionMatrix(); tileData->modelviewMatrix = cv->getModelViewMatrix(); - viewData->_tiles.push_back(tileData.get()); } osg::BoundingBox bb(0.0f,0.0f,0.0f,1.0f,1.0f,1.0f); @@ -262,7 +276,7 @@ void VolumeScene::traverse(osg::NodeVisitor& nv) // new frame so need to clear last frames log of VolumeTiles - viewData->_tiles.clear(); + viewData->clearTiles(); osg::Viewport* viewport = cv->getCurrentRenderStage()->getViewport(); if (viewport) @@ -357,7 +371,15 @@ void VolumeScene::traverse(osg::NodeVisitor& nv) itr != tiles.end(); ++itr) { - TileData* tileData = itr->get(); + TileData* tileData = itr->second.get(); + if (!tileData || !(tileData->active)) + { + OSG_NOTICE<<"Skipping TileData that is inactive : "<projectionMatrix.get()<<", "<modelviewMatrix.get()<