Simplified the API for using the DatabasePager, by providing a single
DatabasePager::updateSceneGraph(..) method, and added a ref_ptr<> into osDB::Registry for managing a single DatabasePager in a centralised way.
This commit is contained in:
@@ -30,6 +30,7 @@ DatabasePager::DatabasePager()
|
||||
|
||||
DatabasePager::~DatabasePager()
|
||||
{
|
||||
//std::cout<<"DatabasePager::~DatabasePager()"<<std::endl;
|
||||
if( isRunning() )
|
||||
{
|
||||
// cancel the thread..
|
||||
@@ -44,6 +45,7 @@ DatabasePager::~DatabasePager()
|
||||
}
|
||||
|
||||
}
|
||||
std::cout<<"DatabasePager::~DatabasePager() stopped running"<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
@@ -175,10 +177,10 @@ void DatabasePager::signalEndFrame()
|
||||
_frameBlock->release();
|
||||
}
|
||||
|
||||
class FindCompileableRenderingObjectsVisitor : public osg::NodeVisitor
|
||||
class FindCompileableGLObjectsVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
FindCompileableRenderingObjectsVisitor(DatabasePager::DataToCompile& dataToCompile):
|
||||
FindCompileableGLObjectsVisitor(DatabasePager::DataToCompile& dataToCompile):
|
||||
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||
_dataToCompile(dataToCompile)
|
||||
{
|
||||
@@ -331,7 +333,7 @@ void DatabasePager::run()
|
||||
++itr;
|
||||
|
||||
// find all the compileable rendering objects
|
||||
FindCompileableRenderingObjectsVisitor frov(dtc);
|
||||
FindCompileableGLObjectsVisitor frov(dtc);
|
||||
databaseRequest->_loadedModel->accept(frov);
|
||||
|
||||
if (!dtc.first.empty() || !dtc.second.empty())
|
||||
@@ -569,7 +571,7 @@ void DatabasePager::registerPagedLODs(osg::Node* subgraph)
|
||||
if (subgraph) subgraph->accept(fplv);
|
||||
}
|
||||
|
||||
void DatabasePager::setCompileRenderingObjectsForContexID(unsigned int contextID, bool on)
|
||||
void DatabasePager::setCompileGLObjectsForContexID(unsigned int contextID, bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
@@ -581,13 +583,13 @@ void DatabasePager::setCompileRenderingObjectsForContexID(unsigned int contextID
|
||||
}
|
||||
}
|
||||
|
||||
bool DatabasePager::getCompileRenderingObjectsForContexID(unsigned int contextID)
|
||||
bool DatabasePager::getCompileGLObjectsForContexID(unsigned int contextID)
|
||||
{
|
||||
return _activeGraphicsContexts.count(contextID)!=0;
|
||||
}
|
||||
|
||||
|
||||
void DatabasePager::compileRenderingObjects(osg::State& state, double& availableTime)
|
||||
void DatabasePager::compileGLObjects(osg::State& state, double& availableTime)
|
||||
{
|
||||
|
||||
const osg::Timer& timer = *osg::Timer::instance();
|
||||
|
||||
@@ -197,6 +197,11 @@ Registry::Registry()
|
||||
|
||||
Registry::~Registry()
|
||||
{
|
||||
// switch off the pager and its associated thread before we clean up
|
||||
// rest of the Registry.
|
||||
_databasePager = 0;
|
||||
|
||||
// unload all the plugin before we finally destruct.
|
||||
closeAllLibraries();
|
||||
}
|
||||
|
||||
@@ -1835,3 +1840,10 @@ void Registry::clearObjectCache()
|
||||
{
|
||||
_objectCache.clear();
|
||||
}
|
||||
|
||||
DatabasePager* Registry::getOrCreateDatabasePager()
|
||||
{
|
||||
if (!_databasePager) _databasePager = new DatabasePager;
|
||||
|
||||
return _databasePager.get();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user