From Mike Connell, "Give ReadFileCallback access to parent location : These small changes to the database pager allow user code in the ReadFileCallback to safely determine where the file being loaded is destined to be inserted into the scenegraph.

"


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14899 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2015-06-08 11:18:24 +00:00
parent ceabbdb8d9
commit 4073910ce8
3 changed files with 9 additions and 1 deletions

View File

@@ -249,6 +249,11 @@ class OSGDB_EXPORT Options : public osg::Object
/** Get the terrain observer_ptr, use to decorate any osgTerrain subgraphs.*/
const osg::observer_ptr<osg::Node>& getTerrain() const { return _terrain; }
/** Set the parentGroup observer_ptr, where the loaded model is intended to be added */
void setParentGroup(osg::observer_ptr<osg::Group>& parentGroup) { _parentGroup= parentGroup; }
/** Get the parentGroup observer_ptr, where the loaded model is intended to be added */
const osg::observer_ptr<osg::Group>& getParentGroup() const { return _parentGroup; }
protected:
@@ -277,6 +282,7 @@ class OSGDB_EXPORT Options : public osg::Object
osg::ref_ptr<FileCache> _fileCache;
osg::observer_ptr<osg::Node> _terrain;
osg::observer_ptr<osg::Group> _parentGroup; // Set by the DatabasePager to the node where the requested file will be inserted. NOTE: observer since prent can be dettached whilst DB thread is loading the object
};
}

View File

@@ -769,6 +769,7 @@ void DatabasePager::DatabaseThread::run()
OpenThreads::ScopedLock<OpenThreads::Mutex> drLock(_pager->_dr_mutex);
dr_loadOptions = databaseRequest->_loadOptions.valid() ? databaseRequest->_loadOptions->cloneOptions() : new osgDB::Options;
dr_loadOptions->setTerrain(databaseRequest->_terrain);
dr_loadOptions->setParentGroup(databaseRequest->_group);
fileName = databaseRequest->_fileName;
frameNumberLastRequest = databaseRequest->_frameNumberLastRequest;
}

View File

@@ -31,7 +31,8 @@ Options::Options(const Options& options,const osg::CopyOp& copyop):
_writeFileCallback(options._writeFileCallback),
_fileLocationCallback(options._fileLocationCallback),
_fileCache(options._fileCache),
_terrain(options._terrain) {}
_terrain(options._terrain),
_parentGroup(options._parentGroup) {}
void Options::parsePluginStringData(const std::string& str, char separator1, char separator2)
{