Further updates to the DatabasePager.
This commit is contained in:
parent
5aa47a77c2
commit
809168d5f8
@ -17,12 +17,15 @@
|
|||||||
#include <osg/NodeVisitor>
|
#include <osg/NodeVisitor>
|
||||||
#include <osg/Group>
|
#include <osg/Group>
|
||||||
#include <osg/PagedLOD>
|
#include <osg/PagedLOD>
|
||||||
|
#include <osg/Drawable>
|
||||||
|
|
||||||
#include <Producer/Thread>
|
#include <Producer/Thread>
|
||||||
#include <Producer/Mutex>
|
#include <Producer/Mutex>
|
||||||
|
|
||||||
#include <osgProducer/Export>
|
#include <osgProducer/Export>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
namespace osgProducer {
|
namespace osgProducer {
|
||||||
|
|
||||||
/** Database paging class which manages the loading of files in a background thread,
|
/** 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.*/
|
* note, should only be called from the draw thread.*/
|
||||||
void compileRenderingObjects(osg::State& state);
|
void compileRenderingObjects(osg::State& state);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
typedef std::vector< osg::ref_ptr<osg::PagedLOD> > PagedLODList;
|
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
|
|
||||||
virtual ~DatabasePager() {}
|
virtual ~DatabasePager() {}
|
||||||
|
|
||||||
|
// make friends with helper classes defined in DatabasePager.cpp.
|
||||||
|
class FindRenderingObjectsVisitor;
|
||||||
|
class FindPagedLODsVisitor;
|
||||||
|
|
||||||
|
typedef std::vector< osg::ref_ptr<osg::PagedLOD> > PagedLODList;
|
||||||
|
|
||||||
typedef std::vector< osg::ref_ptr<osg::StateSet> > StateSetList;
|
typedef std::vector< osg::ref_ptr<osg::StateSet> > StateSetList;
|
||||||
typedef std::vector< osg::ref_ptr<osg::Drawable> > DrawableList;
|
typedef std::vector< osg::ref_ptr<osg::Drawable> > DrawableList;
|
||||||
|
typedef std::pair<StateSetList,DrawableList> DataToCompile;
|
||||||
|
typedef std::map< unsigned int, DataToCompile > DataToCompileMap;
|
||||||
|
|
||||||
struct DatabaseRequest : public osg::Referenced
|
struct DatabaseRequest : public osg::Referenced
|
||||||
{
|
{
|
||||||
@ -101,6 +109,8 @@ class OSGPRODUCER_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseReques
|
|||||||
unsigned int _numOfRequests;
|
unsigned int _numOfRequests;
|
||||||
osg::ref_ptr<osg::Group> _groupForAddingLoadedSubgraph;
|
osg::ref_ptr<osg::Group> _groupForAddingLoadedSubgraph;
|
||||||
osg::ref_ptr<osg::Node> _loadedModel;
|
osg::ref_ptr<osg::Node> _loadedModel;
|
||||||
|
DataToCompileMap _dataToCompileMap;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector< osg::ref_ptr<DatabaseRequest> > DatabaseRequestList;
|
typedef std::vector< osg::ref_ptr<DatabaseRequest> > DatabaseRequestList;
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#include <osgProducer/DatabasePager>
|
#include <osgProducer/DatabasePager>
|
||||||
#include <osgDB/ReadFile>
|
#include <osgDB/ReadFile>
|
||||||
|
#include <osg/Geode>
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifdef WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#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;i<geode.getNumDrawables();++i)
|
||||||
|
{
|
||||||
|
apply(geode.getDrawable(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
traverse(geode);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void apply(osg::StateSet* stateset)
|
||||||
|
{
|
||||||
|
if (stateset)
|
||||||
|
{
|
||||||
|
_dataToCompile.first.push_back(stateset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void apply(osg::Drawable* drawable)
|
||||||
|
{
|
||||||
|
apply(drawable->getStateSet());
|
||||||
|
|
||||||
|
if (drawable->getUseDisplayList() || drawable->getUseVertexBufferObjects())
|
||||||
|
{
|
||||||
|
_dataToCompile.second.push_back(drawable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabasePager::DataToCompile& _dataToCompile;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void DatabasePager::run()
|
void DatabasePager::run()
|
||||||
{
|
{
|
||||||
std::cout<<"DatabasePager::run()"<<std::endl;
|
std::cout<<"DatabasePager::run()"<<std::endl;
|
||||||
@ -206,7 +259,7 @@ void DatabasePager::removeExpiredSubgraphs(double currentFrameTime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class FindPagedLODsVisitor : public osg::NodeVisitor
|
class DatabasePager::FindPagedLODsVisitor : public osg::NodeVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FindPagedLODsVisitor(DatabasePager::PagedLODList& pagedLODList):
|
FindPagedLODsVisitor(DatabasePager::PagedLODList& pagedLODList):
|
||||||
|
Loading…
Reference in New Issue
Block a user