Refactored the handling of use of the osgDB::ObjectCache in the DatabasePager to use a local thread specific ObjectCache to handle new additions and
then have these additions merged with the main Registry ObjectCache during the main loop. git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14474 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -311,8 +311,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
_timestampLastRequest(0.0),
|
||||
_priorityLastRequest(0.0f),
|
||||
_numOfRequests(0),
|
||||
_groupExpired(false),
|
||||
_insertLoadedSubgraphIntoObjectCache(false)
|
||||
_groupExpired(false)
|
||||
{}
|
||||
|
||||
void invalidate();
|
||||
@@ -324,26 +323,25 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
return _valid && (frameNumber - _frameNumberLastRequest <= 1);
|
||||
}
|
||||
|
||||
bool _valid;
|
||||
std::string _fileName;
|
||||
unsigned int _frameNumberFirstRequest;
|
||||
double _timestampFirstRequest;
|
||||
float _priorityFirstRequest;
|
||||
unsigned int _frameNumberLastRequest;
|
||||
double _timestampLastRequest;
|
||||
float _priorityLastRequest;
|
||||
unsigned int _numOfRequests;
|
||||
bool _valid;
|
||||
std::string _fileName;
|
||||
unsigned int _frameNumberFirstRequest;
|
||||
double _timestampFirstRequest;
|
||||
float _priorityFirstRequest;
|
||||
unsigned int _frameNumberLastRequest;
|
||||
double _timestampLastRequest;
|
||||
float _priorityLastRequest;
|
||||
unsigned int _numOfRequests;
|
||||
|
||||
osg::observer_ptr<osg::Node> _terrain;
|
||||
osg::observer_ptr<osg::Group> _group;
|
||||
|
||||
osg::ref_ptr<osg::Node> _loadedModel;
|
||||
osg::ref_ptr<Options> _loadOptions;
|
||||
osg::ref_ptr<ObjectCache> _objectCache;
|
||||
|
||||
osg::observer_ptr<osgUtil::IncrementalCompileOperation::CompileSet> _compileSet;
|
||||
bool _groupExpired; // flag used only in update thread
|
||||
|
||||
bool _insertLoadedSubgraphIntoObjectCache;
|
||||
bool _groupExpired; // flag used only in update thread
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -46,6 +46,9 @@ class OSGDB_EXPORT ObjectCache : public osg::Referenced
|
||||
/** Remove all objects in the cache regardless of having external references or expiry times.*/
|
||||
void clear();
|
||||
|
||||
/** Add contents of specified ObjectCache to this object cache.*/
|
||||
void addObjectCache(ObjectCache* object);
|
||||
|
||||
/** Add a filename,object,timestamp triple to the Registry::ObjectCache.*/
|
||||
void addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define OSGDB_OPTIONS 1
|
||||
|
||||
#include <osgDB/Callbacks>
|
||||
#include <osgDB/ObjectCache>
|
||||
#include <osg/ObserverNodePath>
|
||||
|
||||
#include <deque>
|
||||
@@ -138,6 +139,13 @@ class OSGDB_EXPORT Options : public osg::Object
|
||||
/** Get whether the Registry::ObjectCache should be used by default.*/
|
||||
CacheHintOptions getObjectCacheHint() const { return _objectCacheHint; }
|
||||
|
||||
/** Set the ObjectCache that is used to cache previously loaded data.*/
|
||||
void setObjectCache(ObjectCache* objectCache) { _objectCache = objectCache; }
|
||||
|
||||
/** Get the ObjectCache that is used to cache previously loaded data.*/
|
||||
ObjectCache* getObjectCache() const { return _objectCache.get(); }
|
||||
|
||||
|
||||
/** Set which geometry attributes plugins should import at double precision. */
|
||||
void setPrecisionHint(PrecisionHint hint) { _precisionHint = hint; }
|
||||
|
||||
@@ -248,7 +256,10 @@ class OSGDB_EXPORT Options : public osg::Object
|
||||
|
||||
std::string _str;
|
||||
FilePathList _databasePaths;
|
||||
|
||||
CacheHintOptions _objectCacheHint;
|
||||
osg::ref_ptr<ObjectCache> _objectCache;
|
||||
|
||||
PrecisionHint _precisionHint;
|
||||
BuildKdTreesHint _buildKdTreesHint;
|
||||
osg::ref_ptr<AuthenticationMap> _authenticationMap;
|
||||
|
||||
Reference in New Issue
Block a user