From 809168d5f8d907bace2a555624ccc302c64ab7f9 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 9 Jul 2003 19:48:04 +0000 Subject: [PATCH] Further updates to the DatabasePager. --- include/osgProducer/DatabasePager | 16 +++++++-- src/osgProducer/DatabasePager.cpp | 57 +++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/include/osgProducer/DatabasePager b/include/osgProducer/DatabasePager index eec0a194a..4d4f95612 100644 --- a/include/osgProducer/DatabasePager +++ b/include/osgProducer/DatabasePager @@ -17,12 +17,15 @@ #include #include #include +#include #include #include #include +#include + namespace osgProducer { /** Database paging class which manages the loading of files in a background thread, @@ -80,16 +83,21 @@ class OSGPRODUCER_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseReques * note, should only be called from the draw thread.*/ void compileRenderingObjects(osg::State& state); - public: - - typedef std::vector< osg::ref_ptr > PagedLODList; protected : virtual ~DatabasePager() {} + // make friends with helper classes defined in DatabasePager.cpp. + class FindRenderingObjectsVisitor; + class FindPagedLODsVisitor; + + typedef std::vector< osg::ref_ptr > PagedLODList; + typedef std::vector< osg::ref_ptr > StateSetList; typedef std::vector< osg::ref_ptr > DrawableList; + typedef std::pair DataToCompile; + typedef std::map< unsigned int, DataToCompile > DataToCompileMap; struct DatabaseRequest : public osg::Referenced { @@ -101,6 +109,8 @@ class OSGPRODUCER_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseReques unsigned int _numOfRequests; osg::ref_ptr _groupForAddingLoadedSubgraph; osg::ref_ptr _loadedModel; + DataToCompileMap _dataToCompileMap; + }; typedef std::vector< osg::ref_ptr > DatabaseRequestList; diff --git a/src/osgProducer/DatabasePager.cpp b/src/osgProducer/DatabasePager.cpp index 61cd220a3..ce8e8e159 100644 --- a/src/osgProducer/DatabasePager.cpp +++ b/src/osgProducer/DatabasePager.cpp @@ -1,7 +1,10 @@ #include #include +#include -#ifndef WIN32 +#ifdef WIN32 +#include +#else #include #endif @@ -77,6 +80,56 @@ void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* grou } } +class DatabasePager::FindRenderingObjectsVisitor : public osg::NodeVisitor +{ +public: + FindRenderingObjectsVisitor(DatabasePager::DataToCompile& dataToCompile): + osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), + _dataToCompile(dataToCompile) + { + } + + virtual void apply(osg::Node& node) + { + apply(node.getStateSet()); + + traverse(node); + } + + virtual void apply(osg::Geode& geode) + { + apply(geode.getStateSet()); + + for(unsigned int i=0;igetStateSet()); + + if (drawable->getUseDisplayList() || drawable->getUseVertexBufferObjects()) + { + _dataToCompile.second.push_back(drawable); + } + } + + DatabasePager::DataToCompile& _dataToCompile; +}; + + void DatabasePager::run() { std::cout<<"DatabasePager::run()"<