From Maceij Krol, "I have implement frame based expiration of PagedLOD children.
New attribute DatabasePager::_expiryFrames sets number of frames a PagedLOD child is kept in memory. The attribute is set with DatabasePager::setExpiryFrames method or OSG_EXPIRY_FRAMES environmental variable. New attribute PagedLOD::PerRangeData::_ frameNumber contains frame number of last cull traversal. Children of PagedLOD are expired when time _AND_ number of frames since last cull traversal exceed OSG_EXPIRY_DELAY _AND_ OSG_EXPIRY_FRAMES respectively. By default OSG_EXPIRY_FRAMES = 1 which means that nodes from last cull/rendering traversal will not be expired even if last cull time exceeds OSG_EXPIRY_DELAY. Setting OSG_EXPIRY_FRAMES = 0 revokes previous behaviour of PagedLOD. Setting OSG_EXPIRY_FRAMES > 0 fixes problems of children reloading in lazy rendering applications. Required behaviour is achieved by manipulating OSG_EXPIRY_DELAY and OSG_EXPIRY_FRAMES together. Two interface changes are made: DatabasePager::updateSceneGraph(double currentFrameTime) is replaced by DatabasePager::updateSceneGraph(const osg::FrameStamp &frameStamp). The previous method is in #if 0 clause in the header file. Robert, decide if You want to include it. PagedLOD::removeExpiredChildren(double expiryTime, NodeList &removedChildren) is deprecated (warning is printed), when subclassing use PagedLOD::removeExpiredChildren(double expiryTime, int expiryFrame, NodeList &removedChildren) instead. "
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <osg/PagedLOD>
|
||||
#include <osg/Drawable>
|
||||
#include <osg/GraphicsThread>
|
||||
#include <osg/FrameStamp>
|
||||
|
||||
#include <OpenThreads/Thread>
|
||||
#include <OpenThreads/Mutex>
|
||||
@@ -207,6 +208,14 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
* before being removed.*/
|
||||
double getExpiryDelay() const { return _expiryDelay; }
|
||||
|
||||
/** Set the number of frames that a subgraph will be kept without being visited in the cull traversal
|
||||
* before being removed.*/
|
||||
void setExpiryFrames(int expiryFrames) { _expiryFrames = expiryFrames; }
|
||||
|
||||
/** Get the number of frames that a subgraph will be kept without being visited in the cull traversal
|
||||
* before being removed.*/
|
||||
int getExpiryFrames() const { return _expiryFrames; }
|
||||
|
||||
/** Set whether the removed subgraphs should be deleted in the database thread or not.*/
|
||||
void setDeleteRemovedSubgraphsInDatabaseThread(bool flag) { _deleteRemovedSubgraphsInDatabaseThread = flag; }
|
||||
|
||||
@@ -247,12 +256,12 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
|
||||
/** Merge the changes to the scene graph by calling calling removeExpiredSubgraphs then addLoadedDataToSceneGraph.
|
||||
* Note, must only be called from single thread update phase. */
|
||||
virtual void updateSceneGraph(double currentFrameTime)
|
||||
virtual void updateSceneGraph(const osg::FrameStamp &frameStamp)
|
||||
{
|
||||
removeExpiredSubgraphs(currentFrameTime);
|
||||
addLoadedDataToSceneGraph(currentFrameTime);
|
||||
removeExpiredSubgraphs(frameStamp);
|
||||
addLoadedDataToSceneGraph(frameStamp);
|
||||
}
|
||||
|
||||
|
||||
/** Turn the compilation of rendering objects for specified graphics context on (true) or off(false). */
|
||||
void setCompileGLObjectsForContextID(unsigned int contextID, bool on);
|
||||
|
||||
@@ -487,10 +496,10 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
/** Iterate through the active PagedLOD nodes children removing
|
||||
* children which havn't been visited since specified expiryTime.
|
||||
* note, should be only be called from the update thread. */
|
||||
virtual void removeExpiredSubgraphs(double currentFrameTime);
|
||||
virtual void removeExpiredSubgraphs(const osg::FrameStamp &frameStamp);
|
||||
|
||||
/** Add the loaded data to the scene graph.*/
|
||||
void addLoadedDataToSceneGraph(double currentFrameTime);
|
||||
void addLoadedDataToSceneGraph(const osg::FrameStamp &frameStamp);
|
||||
|
||||
|
||||
bool _done;
|
||||
@@ -523,6 +532,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
PagedLODList _pagedLODList;
|
||||
|
||||
double _expiryDelay;
|
||||
int _expiryFrames;
|
||||
|
||||
ActiveGraphicsContexts _activeGraphicsContexts;
|
||||
// CompileGraphicsContexts _compileGraphicsContexts;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/observer_ptr>
|
||||
#include <osg/OperationThread>
|
||||
#include <osg/FrameStamp>
|
||||
|
||||
#include <OpenThreads/Mutex>
|
||||
|
||||
@@ -84,7 +85,7 @@ class OSGDB_EXPORT ImagePager : public osg::NodeVisitor::ImageRequestHandler
|
||||
virtual bool requiresUpdateSceneGraph() const;
|
||||
|
||||
/** Merge the changes to the scene graph. */
|
||||
virtual void updateSceneGraph(double currentFrameTime);
|
||||
virtual void updateSceneGraph(const osg::FrameStamp &frameStamp);
|
||||
|
||||
int cancel();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user