Refactored the way that the DatabasePager passes the Terrain decorator node onto the TerrainTile.
The DatabasePager now passes the Terrain pointer into the ReaderWriter's via osgDB::Options object, rather than pushing a NodePath containing the Terrain onto NodeVisitor. This change means that the DatabasePager nolonger needs to observer the whole NodePath and will be lighter and quicker for it. The change also means that ReadFileCallback can now run custom NodeVisitor's on the scene graph without having to worry about TerrainTile's constructing scene graphs prior to the Terrain being assigned. Also changed is the NodeVisitor::DatabaseRequestHandler which now requires a NodePath to the node that you wish to add to rather than just the pointer to the node you wish to add to. This is more robust when handling scenes with multiple parental paths, whereas previously errors could have occurred due to the default of picking the first available parental path. This change means that subclasses of DatabasePager will need to be updated to use this new function entry point.
This commit is contained in:
parent
762f8d5360
commit
f61a6aa4e7
@ -59,14 +59,14 @@ public:
|
|||||||
if ( pagedLOD->getDatabasePath().empty() )
|
if ( pagedLOD->getDatabasePath().empty() )
|
||||||
{
|
{
|
||||||
nv->getDatabaseRequestHandler()->requestNodeFile(
|
nv->getDatabaseRequestHandler()->requestNodeFile(
|
||||||
pagedLOD->getFileName(numChildren), pagedLOD,
|
pagedLOD->getFileName(numChildren), nv->getNodePath(),
|
||||||
1.0, nv->getFrameStamp(),
|
1.0, nv->getFrameStamp(),
|
||||||
pagedLOD->getDatabaseRequest(numChildren), pagedLOD->getDatabaseOptions() );
|
pagedLOD->getDatabaseRequest(numChildren), pagedLOD->getDatabaseOptions() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nv->getDatabaseRequestHandler()->requestNodeFile(
|
nv->getDatabaseRequestHandler()->requestNodeFile(
|
||||||
pagedLOD->getDatabasePath()+pagedLOD->getFileName(numChildren), pagedLOD,
|
pagedLOD->getDatabasePath()+pagedLOD->getFileName(numChildren), nv->getNodePath(),
|
||||||
1.0, nv->getFrameStamp(),
|
1.0, nv->getFrameStamp(),
|
||||||
pagedLOD->getDatabaseRequest(numChildren), pagedLOD->getDatabaseOptions() );
|
pagedLOD->getDatabaseRequest(numChildren), pagedLOD->getDatabaseOptions() );
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,15 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
// forward declare osgTerrrain::Terrain to enable declaration of asTerrain() method.
|
||||||
|
namespace osgTerrain {
|
||||||
|
class Terrain;
|
||||||
|
}
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
|
// forcing declare classes to enable declaration of as*() methods.
|
||||||
class NodeVisitor;
|
class NodeVisitor;
|
||||||
class Group;
|
class Group;
|
||||||
class Transform;
|
class Transform;
|
||||||
@ -114,6 +121,15 @@ class OSG_EXPORT Node : public Object
|
|||||||
* Equivalent to dynamic_cast<const Geode*>(this).*/
|
* Equivalent to dynamic_cast<const Geode*>(this).*/
|
||||||
virtual const Geode* asGeode() const { return 0; }
|
virtual const Geode* asGeode() const { return 0; }
|
||||||
|
|
||||||
|
/** Convert 'this' into a Transform pointer if Node is a Terrain, otherwise return 0.
|
||||||
|
* Equivalent to dynamic_cast<Terrrain*>(this).*/
|
||||||
|
virtual osgTerrain::Terrain* asTerrain() { return 0; }
|
||||||
|
|
||||||
|
/** convert 'const this' into a const Terrain pointer if Node is a Terrain, otherwise return 0.
|
||||||
|
* Equivalent to dynamic_cast<const Terrain*>(this).*/
|
||||||
|
virtual const osgTerrain::Terrain* asTerrain() const { return 0; }
|
||||||
|
|
||||||
|
|
||||||
/** Visitor Pattern : calls the apply method of a NodeVisitor with this node's type.*/
|
/** Visitor Pattern : calls the apply method of a NodeVisitor with this node's type.*/
|
||||||
virtual void accept(NodeVisitor& nv);
|
virtual void accept(NodeVisitor& nv);
|
||||||
/** Traverse upwards : calls parents' accept method with NodeVisitor.*/
|
/** Traverse upwards : calls parents' accept method with NodeVisitor.*/
|
||||||
|
@ -280,7 +280,7 @@ class OSG_EXPORT NodeVisitor : public virtual Referenced
|
|||||||
DatabaseRequestHandler():
|
DatabaseRequestHandler():
|
||||||
Referenced(true) {}
|
Referenced(true) {}
|
||||||
|
|
||||||
virtual void requestNodeFile(const std::string& fileName,osg::Group* group, float priority, const FrameStamp* framestamp, osg::ref_ptr<osg::Referenced>& databaseRequest, const osg::Referenced* options=0) = 0;
|
virtual void requestNodeFile(const std::string& fileName, osg::NodePath& nodePath, float priority, const FrameStamp* framestamp, osg::ref_ptr<osg::Referenced>& databaseRequest, const osg::Referenced* options=0) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~DatabaseRequestHandler() {}
|
virtual ~DatabaseRequestHandler() {}
|
||||||
|
@ -70,7 +70,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
|||||||
|
|
||||||
|
|
||||||
/** Add a request to load a node file to end the the database request list.*/
|
/** Add a request to load a node file to end the the database request list.*/
|
||||||
virtual void requestNodeFile(const std::string& fileName,osg::Group* group,
|
virtual void requestNodeFile(const std::string& fileName, osg::NodePath& nodePath,
|
||||||
float priority, const osg::FrameStamp* framestamp,
|
float priority, const osg::FrameStamp* framestamp,
|
||||||
osg::ref_ptr<osg::Referenced>& databaseRequest,
|
osg::ref_ptr<osg::Referenced>& databaseRequest,
|
||||||
const osg::Referenced* options);
|
const osg::Referenced* options);
|
||||||
@ -316,7 +316,10 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
|||||||
double _timestampLastRequest;
|
double _timestampLastRequest;
|
||||||
float _priorityLastRequest;
|
float _priorityLastRequest;
|
||||||
unsigned int _numOfRequests;
|
unsigned int _numOfRequests;
|
||||||
osg::ObserverNodePath _observerNodePath;
|
|
||||||
|
osg::observer_ptr<osg::Node> _terrain;
|
||||||
|
osg::observer_ptr<osg::Group> _group;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> _loadedModel;
|
osg::ref_ptr<osg::Node> _loadedModel;
|
||||||
osg::ref_ptr<Options> _loadOptions;
|
osg::ref_ptr<Options> _loadOptions;
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <osg/PrimitiveSet>
|
#include <osg/PrimitiveSet>
|
||||||
#include <osgDB/ReaderWriter>
|
#include <osgDB/ReaderWriter>
|
||||||
#include <osgDB/StreamOperator>
|
#include <osgDB/StreamOperator>
|
||||||
|
#include <osgDB/Options>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#define OSGDB_OPTIONS 1
|
#define OSGDB_OPTIONS 1
|
||||||
|
|
||||||
#include <osgDB/Callbacks>
|
#include <osgDB/Callbacks>
|
||||||
|
#include <osg/ObserverNodePath>
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <list>
|
#include <list>
|
||||||
@ -227,7 +228,6 @@ class OSGDB_EXPORT Options : public osg::Object
|
|||||||
/** Get the callback to use inform the DatabasePager whether a file is located on local or remote file system.*/
|
/** Get the callback to use inform the DatabasePager whether a file is located on local or remote file system.*/
|
||||||
FileLocationCallback* getFileLocationCallback() const { return _fileLocationCallback.get(); }
|
FileLocationCallback* getFileLocationCallback() const { return _fileLocationCallback.get(); }
|
||||||
|
|
||||||
|
|
||||||
/** Set the FileCache that is used to manage local storage of files downloaded from the internet.*/
|
/** Set the FileCache that is used to manage local storage of files downloaded from the internet.*/
|
||||||
void setFileCache(FileCache* fileCache) { _fileCache = fileCache; }
|
void setFileCache(FileCache* fileCache) { _fileCache = fileCache; }
|
||||||
|
|
||||||
@ -235,6 +235,13 @@ class OSGDB_EXPORT Options : public osg::Object
|
|||||||
FileCache* getFileCache() const { return _fileCache.get(); }
|
FileCache* getFileCache() const { return _fileCache.get(); }
|
||||||
|
|
||||||
|
|
||||||
|
/** Set the terrain observer_ptr, use to decorate any osgTerrain subgraphs.*/
|
||||||
|
void setTerrain(osg::observer_ptr<osg::Node>& terrain) { _terrain = terrain; }
|
||||||
|
|
||||||
|
/** Get the terrain observer_ptr, use to decorate any osgTerrain subgraphs.*/
|
||||||
|
const osg::observer_ptr<osg::Node>& getTerrain() const { return _terrain; }
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual ~Options() {}
|
virtual ~Options() {}
|
||||||
@ -257,6 +264,8 @@ class OSGDB_EXPORT Options : public osg::Object
|
|||||||
osg::ref_ptr<FileLocationCallback> _fileLocationCallback;
|
osg::ref_ptr<FileLocationCallback> _fileLocationCallback;
|
||||||
|
|
||||||
osg::ref_ptr<FileCache> _fileCache;
|
osg::ref_ptr<FileCache> _fileCache;
|
||||||
|
|
||||||
|
osg::observer_ptr<osg::Node> _terrain;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,10 @@ class OSGTERRAIN_EXPORT Terrain : public osg::CoordinateSystemNode
|
|||||||
|
|
||||||
virtual void traverse(osg::NodeVisitor& nv);
|
virtual void traverse(osg::NodeVisitor& nv);
|
||||||
|
|
||||||
|
virtual osgTerrain::Terrain* asTerrain() { return this; }
|
||||||
|
virtual const osgTerrain::Terrain* asTerrain() const { return this; }
|
||||||
|
|
||||||
|
|
||||||
/** Set the sample ratio hint that TerrainTile should use when building geometry.
|
/** Set the sample ratio hint that TerrainTile should use when building geometry.
|
||||||
* Defaults to 1.0, which means use all original sample points.*/
|
* Defaults to 1.0, which means use all original sample points.*/
|
||||||
void setSampleRatio(float ratio);
|
void setSampleRatio(float ratio);
|
||||||
|
@ -218,12 +218,12 @@ void PagedLOD::traverse(NodeVisitor& nv)
|
|||||||
|
|
||||||
if (_databasePath.empty())
|
if (_databasePath.empty())
|
||||||
{
|
{
|
||||||
nv.getDatabaseRequestHandler()->requestNodeFile(_perRangeDataList[numChildren]._filename,this,priority,nv.getFrameStamp(), _perRangeDataList[numChildren]._databaseRequest, _databaseOptions.get());
|
nv.getDatabaseRequestHandler()->requestNodeFile(_perRangeDataList[numChildren]._filename,nv.getNodePath(),priority,nv.getFrameStamp(), _perRangeDataList[numChildren]._databaseRequest, _databaseOptions.get());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// prepend the databasePath to the child's filename.
|
// prepend the databasePath to the child's filename.
|
||||||
nv.getDatabaseRequestHandler()->requestNodeFile(_databasePath+_perRangeDataList[numChildren]._filename,this,priority,nv.getFrameStamp(), _perRangeDataList[numChildren]._databaseRequest, _databaseOptions.get());
|
nv.getDatabaseRequestHandler()->requestNodeFile(_databasePath+_perRangeDataList[numChildren]._filename,nv.getNodePath(),priority,nv.getFrameStamp(), _perRangeDataList[numChildren]._databaseRequest, _databaseOptions.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ void ProxyNode::traverse(NodeVisitor& nv)
|
|||||||
{
|
{
|
||||||
for(unsigned int i=_children.size(); i<_filenameList.size(); ++i)
|
for(unsigned int i=_children.size(); i<_filenameList.size(); ++i)
|
||||||
{
|
{
|
||||||
nv.getDatabaseRequestHandler()->requestNodeFile(_databasePath+_filenameList[i].first, this, 1.0f, nv.getFrameStamp(), _filenameList[i].second, _databaseOptions.get());
|
nv.getDatabaseRequestHandler()->requestNodeFile(_databasePath+_filenameList[i].first, nv.getNodePath(), 1.0f, nv.getFrameStamp(), _filenameList[i].second, _databaseOptions.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -799,7 +799,15 @@ void DatabasePager::DatabaseThread::run()
|
|||||||
{
|
{
|
||||||
if (dr_loadOptions->getFileCache()) fileCache = dr_loadOptions->getFileCache();
|
if (dr_loadOptions->getFileCache()) fileCache = dr_loadOptions->getFileCache();
|
||||||
if (dr_loadOptions->getFileLocationCallback()) fileLocationCallback = dr_loadOptions->getFileLocationCallback();
|
if (dr_loadOptions->getFileLocationCallback()) fileLocationCallback = dr_loadOptions->getFileLocationCallback();
|
||||||
|
|
||||||
|
dr_loadOptions = dr_loadOptions->cloneOptions();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dr_loadOptions = new osgDB::Options;
|
||||||
|
}
|
||||||
|
|
||||||
|
dr_loadOptions->setTerrain(databaseRequest->_terrain);
|
||||||
|
|
||||||
// disable the FileCache if the fileLocationCallback tells us that it isn't required for this request.
|
// disable the FileCache if the fileLocationCallback tells us that it isn't required for this request.
|
||||||
if (fileLocationCallback.valid() && !fileLocationCallback->useFileCache()) fileCache = 0;
|
if (fileLocationCallback.valid() && !fileLocationCallback->useFileCache()) fileCache = 0;
|
||||||
@ -893,7 +901,7 @@ void DatabasePager::DatabaseThread::run()
|
|||||||
{
|
{
|
||||||
fileCache->writeNode(*(loadedModel), fileName, dr_loadOptions.get());
|
fileCache->writeNode(*(loadedModel), fileName, dr_loadOptions.get());
|
||||||
}
|
}
|
||||||
osg::RefNodePath refNodePath;
|
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> drLock(_pager->_dr_mutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> drLock(_pager->_dr_mutex);
|
||||||
if ((_pager->_frameNumber-databaseRequest->_frameNumberLastRequest)>1)
|
if ((_pager->_frameNumber-databaseRequest->_frameNumberLastRequest)>1)
|
||||||
@ -901,16 +909,6 @@ void DatabasePager::DatabaseThread::run()
|
|||||||
OSG_INFO<<_name<<": Warning DatabaseRquest no longer required."<<std::endl;
|
OSG_INFO<<_name<<": Warning DatabaseRquest no longer required."<<std::endl;
|
||||||
loadedModel = 0;
|
loadedModel = 0;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// take a refNodePath to ensure that none of the nodes
|
|
||||||
// go out of scope while we are using them.
|
|
||||||
if (!databaseRequest->_observerNodePath.getRefNodePath(refNodePath))
|
|
||||||
{
|
|
||||||
OSG_INFO<<_name<<": Warning node in parental chain has been deleted, discarding load."<<std::endl;
|
|
||||||
loadedModel = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//OSG_NOTICE<<" node read in "<<osg::Timer::instance()->delta_m(before,osg::Timer::instance()->tick())<<" ms"<<std::endl;
|
//OSG_NOTICE<<" node read in "<<osg::Timer::instance()->delta_m(before,osg::Timer::instance()->tick())<<" ms"<<std::endl;
|
||||||
@ -925,17 +923,6 @@ void DatabasePager::DatabaseThread::run()
|
|||||||
_pager->_drawablePolicy,
|
_pager->_drawablePolicy,
|
||||||
_pager);
|
_pager);
|
||||||
|
|
||||||
// push the soon to be parent on the nodepath of the NodeVisitor so that
|
|
||||||
// during traversal one can test for where it'll be in the overall scene graph
|
|
||||||
// This is the benefit for osgTerrain::TerrainTile, so
|
|
||||||
// that it will find its Terrain node on its first traversal.
|
|
||||||
for(osg::RefNodePath::iterator rnp_itr = refNodePath.begin();
|
|
||||||
rnp_itr != refNodePath.end();
|
|
||||||
++rnp_itr)
|
|
||||||
{
|
|
||||||
frov.pushOntoNodePath(rnp_itr->get());
|
|
||||||
}
|
|
||||||
|
|
||||||
loadedModel->accept(frov);
|
loadedModel->accept(frov);
|
||||||
|
|
||||||
bool loadedObjectsNeedToBeCompiled = (_pager->_doPreCompile && frov.requiresCompilation() && _pager->_incrementalCompileOperation.valid());
|
bool loadedObjectsNeedToBeCompiled = (_pager->_doPreCompile && frov.requiresCompilation() && _pager->_incrementalCompileOperation.valid());
|
||||||
@ -1362,7 +1349,7 @@ bool DatabasePager::getRequestsInProgress() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* group,
|
void DatabasePager::requestNodeFile(const std::string& fileName, osg::NodePath& nodePath,
|
||||||
float priority, const osg::FrameStamp* framestamp,
|
float priority, const osg::FrameStamp* framestamp,
|
||||||
osg::ref_ptr<osg::Referenced>& databaseRequestRef,
|
osg::ref_ptr<osg::Referenced>& databaseRequestRef,
|
||||||
const osg::Referenced* options)
|
const osg::Referenced* options)
|
||||||
@ -1383,6 +1370,27 @@ void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* grou
|
|||||||
if (!_acceptNewRequests) return;
|
if (!_acceptNewRequests) return;
|
||||||
|
|
||||||
|
|
||||||
|
if (nodePath.empty())
|
||||||
|
{
|
||||||
|
OSG_NOTICE<<"Warning: DatabasePager::requestNodeFile(..) passed empty NodePath, so nowhere to attach new subgraph to."<<std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::Group* group = nodePath.back()->asGroup();
|
||||||
|
if (!group)
|
||||||
|
{
|
||||||
|
OSG_NOTICE<<"Warning: DatabasePager::requestNodeFile(..) passed NodePath without group as last node in path, so nowhere to attach new subgraph to."<<std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::Node* terrain = 0;
|
||||||
|
for(osg::NodePath::reverse_iterator itr = nodePath.rbegin();
|
||||||
|
itr != nodePath.rend();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
if ((*itr)->asTerrain()) terrain = *itr;
|
||||||
|
}
|
||||||
|
|
||||||
double timestamp = framestamp?framestamp->getReferenceTime():0.0;
|
double timestamp = framestamp?framestamp->getReferenceTime():0.0;
|
||||||
unsigned int frameNumber = framestamp?framestamp->getFrameNumber():static_cast<unsigned int>(_frameNumber);
|
unsigned int frameNumber = framestamp?framestamp->getFrameNumber():static_cast<unsigned int>(_frameNumber);
|
||||||
|
|
||||||
@ -1436,7 +1444,8 @@ void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* grou
|
|||||||
databaseRequest->_frameNumberLastRequest = frameNumber;
|
databaseRequest->_frameNumberLastRequest = frameNumber;
|
||||||
databaseRequest->_timestampLastRequest = timestamp;
|
databaseRequest->_timestampLastRequest = timestamp;
|
||||||
databaseRequest->_priorityLastRequest = priority;
|
databaseRequest->_priorityLastRequest = priority;
|
||||||
databaseRequest->_observerNodePath.setNodePathTo(group);
|
databaseRequest->_group = group;
|
||||||
|
databaseRequest->_terrain = terrain;
|
||||||
databaseRequest->_loadOptions = loadOptions;
|
databaseRequest->_loadOptions = loadOptions;
|
||||||
requeue = true;
|
requeue = true;
|
||||||
}
|
}
|
||||||
@ -1467,7 +1476,8 @@ void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* grou
|
|||||||
databaseRequest->_frameNumberLastRequest = frameNumber;
|
databaseRequest->_frameNumberLastRequest = frameNumber;
|
||||||
databaseRequest->_timestampLastRequest = timestamp;
|
databaseRequest->_timestampLastRequest = timestamp;
|
||||||
databaseRequest->_priorityLastRequest = priority;
|
databaseRequest->_priorityLastRequest = priority;
|
||||||
databaseRequest->_observerNodePath.setNodePathTo(group);
|
databaseRequest->_group = group;
|
||||||
|
databaseRequest->_terrain = terrain;
|
||||||
databaseRequest->_loadOptions = loadOptions;
|
databaseRequest->_loadOptions = loadOptions;
|
||||||
|
|
||||||
_fileRequestQueue->addNoLock(databaseRequest.get());
|
_fileRequestQueue->addNoLock(databaseRequest.get());
|
||||||
@ -1608,19 +1618,17 @@ void DatabasePager::addLoadedDataToSceneGraph(const osg::FrameStamp &frameStamp)
|
|||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
DatabaseRequest* databaseRequest = itr->get();
|
DatabaseRequest* databaseRequest = itr->get();
|
||||||
|
|
||||||
// No need to take _dr_mutex. The pager threads are done with
|
// No need to take _dr_mutex. The pager threads are done with
|
||||||
// the request; the cull traversal -- which might redispatch
|
// the request; the cull traversal -- which might redispatch
|
||||||
// the request -- can't run at the sametime as this update traversal.
|
// the request -- can't run at the sametime as this update traversal.
|
||||||
osg::RefNodePath refNodePath;
|
osg::ref_ptr<osg::Group> group;
|
||||||
if (databaseRequest->_observerNodePath.getRefNodePath(refNodePath))
|
if (databaseRequest->_group.lock(group))
|
||||||
{
|
{
|
||||||
// OSG_NOTICE<<"Merging "<<_frameNumber-(*itr)->_frameNumberLastRequest<<std::endl;
|
|
||||||
osg::Group* group = static_cast<osg::Group*>(refNodePath.back().get());
|
|
||||||
|
|
||||||
if (osgDB::Registry::instance()->getSharedStateManager())
|
if (osgDB::Registry::instance()->getSharedStateManager())
|
||||||
osgDB::Registry::instance()->getSharedStateManager()->share(databaseRequest->_loadedModel.get());
|
osgDB::Registry::instance()->getSharedStateManager()->share(databaseRequest->_loadedModel.get());
|
||||||
|
|
||||||
osg::PagedLOD* plod = dynamic_cast<osg::PagedLOD*>(group);
|
osg::PagedLOD* plod = dynamic_cast<osg::PagedLOD*>(group.get());
|
||||||
if (plod)
|
if (plod)
|
||||||
{
|
{
|
||||||
plod->setTimeStamp(plod->getNumChildren(), timeStamp);
|
plod->setTimeStamp(plod->getNumChildren(), timeStamp);
|
||||||
@ -1629,7 +1637,7 @@ void DatabasePager::addLoadedDataToSceneGraph(const osg::FrameStamp &frameStamp)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osg::ProxyNode* proxyNode = dynamic_cast<osg::ProxyNode*>(group);
|
osg::ProxyNode* proxyNode = dynamic_cast<osg::ProxyNode*>(group.get());
|
||||||
if (proxyNode)
|
if (proxyNode)
|
||||||
{
|
{
|
||||||
proxyNode->getDatabaseRequest(proxyNode->getNumChildren()) = 0;
|
proxyNode->getDatabaseRequest(proxyNode->getNumChildren()) = 0;
|
||||||
|
@ -29,7 +29,8 @@ Options::Options(const Options& options,const osg::CopyOp& copyop):
|
|||||||
_readFileCallback(options._readFileCallback),
|
_readFileCallback(options._readFileCallback),
|
||||||
_writeFileCallback(options._writeFileCallback),
|
_writeFileCallback(options._writeFileCallback),
|
||||||
_fileLocationCallback(options._fileLocationCallback),
|
_fileLocationCallback(options._fileLocationCallback),
|
||||||
_fileCache(options._fileCache) {}
|
_fileCache(options._fileCache),
|
||||||
|
_terrain(options._terrain) {}
|
||||||
|
|
||||||
void Options::parsePluginStringData(const std::string& str, char separator1, char separator2)
|
void Options::parsePluginStringData(const std::string& str, char separator1, char separator2)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,9 @@
|
|||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
|
|
||||||
|
#include <osgDB/Options>
|
||||||
#include <osgTerrain/GeometryTechnique>
|
#include <osgTerrain/GeometryTechnique>
|
||||||
|
#include <osgTerrain/Terrain>
|
||||||
|
|
||||||
using namespace ive;
|
using namespace ive;
|
||||||
|
|
||||||
@ -132,6 +134,15 @@ void TerrainTile::read(DataInputStream* in)
|
|||||||
|
|
||||||
setTerrainTechnique(readTerrainTechnique(in));
|
setTerrainTechnique(readTerrainTechnique(in));
|
||||||
|
|
||||||
|
if (in->getOptions())
|
||||||
|
{
|
||||||
|
osg::ref_ptr<osg::Node> node;
|
||||||
|
if (in->getOptions()->getTerrain().lock(node))
|
||||||
|
{
|
||||||
|
setTerrain(node->asTerrain());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (osgTerrain::TerrainTile::getTileLoadedCallback().valid())
|
if (osgTerrain::TerrainTile::getTileLoadedCallback().valid())
|
||||||
osgTerrain::TerrainTile::getTileLoadedCallback()->loaded(this, in->getOptions());
|
osgTerrain::TerrainTile::getTileLoadedCallback()->loaded(this, in->getOptions());
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ void TXPPagedLOD::traverse(osg::NodeVisitor& nv)
|
|||||||
|
|
||||||
//std::cout<<" requesting child "<<_fileNameList[numChildren]<<" priotity = "<<priority<<std::endl;
|
//std::cout<<" requesting child "<<_fileNameList[numChildren]<<" priotity = "<<priority<<std::endl;
|
||||||
nv.getDatabaseRequestHandler()->requestNodeFile(_perRangeDataList[numChildren]._filename,
|
nv.getDatabaseRequestHandler()->requestNodeFile(_perRangeDataList[numChildren]._filename,
|
||||||
this,
|
nv.getNodePath(),
|
||||||
priority,
|
priority,
|
||||||
nv.getFrameStamp(),
|
nv.getFrameStamp(),
|
||||||
_perRangeDataList[numChildren]._databaseRequest);
|
_perRangeDataList[numChildren]._databaseRequest);
|
||||||
|
@ -188,6 +188,14 @@ bool TerrainTile_readLocalData(osg::Object& obj, osgDB::Input &fr)
|
|||||||
itrAdvanced = true;
|
itrAdvanced = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fr.getOptions())
|
||||||
|
{
|
||||||
|
osg::ref_ptr<osg::Node> node;
|
||||||
|
if (fr.getOptions()->getTerrain().lock(node))
|
||||||
|
{
|
||||||
|
terrainTile.setTerrain(node->asTerrain());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (osgTerrain::TerrainTile::getTileLoadedCallback().valid())
|
if (osgTerrain::TerrainTile::getTileLoadedCallback().valid())
|
||||||
osgTerrain::TerrainTile::getTileLoadedCallback()->loaded(&terrainTile, fr.getOptions());
|
osgTerrain::TerrainTile::getTileLoadedCallback()->loaded(&terrainTile, fr.getOptions());
|
||||||
|
@ -65,6 +65,16 @@ struct TerrainTileFinishedObjectReadCallback : public osgDB::FinishedObjectReadC
|
|||||||
virtual void objectRead(osgDB::InputStream& is, osg::Object& obj)
|
virtual void objectRead(osgDB::InputStream& is, osg::Object& obj)
|
||||||
{
|
{
|
||||||
osgTerrain::TerrainTile& tile = static_cast<osgTerrain::TerrainTile&>(obj);
|
osgTerrain::TerrainTile& tile = static_cast<osgTerrain::TerrainTile&>(obj);
|
||||||
|
|
||||||
|
if (is.getOptions())
|
||||||
|
{
|
||||||
|
osg::ref_ptr<osg::Node> node;
|
||||||
|
if (is.getOptions()->getTerrain().lock(node))
|
||||||
|
{
|
||||||
|
tile.setTerrain(node->asTerrain());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( osgTerrain::TerrainTile::getTileLoadedCallback().valid() )
|
if ( osgTerrain::TerrainTile::getTileLoadedCallback().valid() )
|
||||||
osgTerrain::TerrainTile::getTileLoadedCallback()->loaded( &tile, is.getOptions() );
|
osgTerrain::TerrainTile::getTileLoadedCallback()->loaded( &tile, is.getOptions() );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user