From 4073910ce8cc9cf5a8d3838ca4f931c84089d1d7 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 8 Jun 2015 11:18:24 +0000 Subject: [PATCH] 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 --- include/osgDB/Options | 6 ++++++ src/osgDB/DatabasePager.cpp | 1 + src/osgDB/Options.cpp | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/osgDB/Options b/include/osgDB/Options index d361b5d2e..972221686 100644 --- a/include/osgDB/Options +++ b/include/osgDB/Options @@ -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& getTerrain() const { return _terrain; } + /** Set the parentGroup observer_ptr, where the loaded model is intended to be added */ + void setParentGroup(osg::observer_ptr& parentGroup) { _parentGroup= parentGroup; } + + /** Get the parentGroup observer_ptr, where the loaded model is intended to be added */ + const osg::observer_ptr& getParentGroup() const { return _parentGroup; } protected: @@ -277,6 +282,7 @@ class OSGDB_EXPORT Options : public osg::Object osg::ref_ptr _fileCache; osg::observer_ptr _terrain; + osg::observer_ptr _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 }; } diff --git a/src/osgDB/DatabasePager.cpp b/src/osgDB/DatabasePager.cpp index 24f2dafc5..b96333295 100644 --- a/src/osgDB/DatabasePager.cpp +++ b/src/osgDB/DatabasePager.cpp @@ -769,6 +769,7 @@ void DatabasePager::DatabaseThread::run() OpenThreads::ScopedLock 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; } diff --git a/src/osgDB/Options.cpp b/src/osgDB/Options.cpp index 51ccb89b5..1b963b801 100644 --- a/src/osgDB/Options.cpp +++ b/src/osgDB/Options.cpp @@ -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) {