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:
Robert Osfield
2004-01-06 21:18:36 +00:00
parent 3ea1bb6de7
commit 894537a016
6 changed files with 69 additions and 55 deletions

View File

@@ -94,10 +94,6 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
void signalEndFrame();
/** Add the loaded data to the scene graph.*/
void addLoadedDataToSceneGraph(double timeStamp);
/** Find all PagedLOD nodes in a subgraph and register them with
* the DatabasePager so it can keep track of expired nodes.
* note, should be only be called from the update thread. */
@@ -122,17 +118,27 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
* children which havn't been visited since specified expiryTime.
* note, should be only be called from the update thread. */
void removeExpiredSubgraphs(double currentFrameTime);
/** Add the loaded data to the scene graph.*/
void addLoadedDataToSceneGraph(double currentFrameTime);
/** Merge the changes to the scene graph by calling calling removeExpiredSubgraphs then addLoadedDataToSceneGraph*/
void updateSceneGraph(double currentFrameTime)
{
removeExpiredSubgraphs(currentFrameTime);
addLoadedDataToSceneGraph(currentFrameTime);
}
/** Turn the compilation of rendering objects for specfied graphics context on (true) or off(false).*/
void setCompileRenderingObjectsForContexID(unsigned int contextID, bool on);
void setCompileGLObjectsForContexID(unsigned int contextID, bool on);
/** Get whether the compilation of rendering objects for specfied graphics context on (true) or off(false).*/
bool getCompileRenderingObjectsForContexID(unsigned int contextID);
bool getCompileGLObjectsForContexID(unsigned int contextID);
/** Compile the rendering objects (display lists,texture objects, VBO's) on loaded subgraph.
* note, should only be called from the draw thread.*/
void compileRenderingObjects(osg::State& state,double& availableTime);
void compileGLObjects(osg::State& state,double& availableTime);
/** Helper class used internally to force the release of texture objects
* and displace lists.*/

View File

@@ -20,6 +20,7 @@
#include <osgDB/DynamicLibrary>
#include <osgDB/ReaderWriter>
#include <osgDB/DotOsgWrapper>
#include <osgDB/DatabasePager>
#include <vector>
#include <map>
@@ -209,6 +210,16 @@ class OSGDB_EXPORT Registry : public osg::Referenced
DynamicLibrary* getLibrary(const std::string& fileName);
typedef std::vector< osg::ref_ptr<ReaderWriter> > ReaderWriterList;
/** Set the DatabasePager.*/
void setDatabasePager(DatabasePager* databasePager) { _databasePager = databasePager; }
/** Get the DatabasePager, creating one if one is not already created.*/
DatabasePager* getOrCreateDatabasePager();
/** Get the DatabasePager. Return 0 if no DatabasePager has been assigned.*/
DatabasePager* getDatabasePager() { return _databasePager.get(); }
protected:
@@ -264,6 +275,8 @@ class OSGDB_EXPORT Registry : public osg::Referenced
bool _useObjectCacheHint;
ObjectCache _objectCache;
osg::ref_ptr<DatabasePager> _databasePager;
};

View File

@@ -26,8 +26,6 @@
#include <osg/DisplaySettings>
#include <osg/Matrixd>
#include <osgDB/DatabasePager>
#include <osgProducer/OsgSceneHandler>
namespace osgProducer {
@@ -115,13 +113,6 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
void setFusionDistance( osgUtil::SceneView::FusionDistanceMode mode,float value=1.0f);
void setDatabasePager( osgDB::DatabasePager* pager) { _databasePager = pager; }
osgDB::DatabasePager* getDatabasePager() { return _databasePager.get(); }
const osgDB::DatabasePager* getDatabasePager() const { return _databasePager.get(); }
/** RealizeCallback class one should override to provide an the implemention of realize callbacks.
* Note, this callback overrides the normal call to OsgSceneHandler::init() so it become the your
* responisibility to call this within your callback if required, it is a safe assumption to
@@ -197,8 +188,6 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
osg::Timer _timer;
osg::Timer_t _start_tick;
osg::ref_ptr<osg::FrameStamp> _frameStamp;
osg::ref_ptr<osgDB::DatabasePager> _databasePager;
void _init();
};