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:
Robert Osfield
2008-08-17 16:52:35 +00:00
parent 0c234e7997
commit 3de3b2dccc
8 changed files with 69 additions and 28 deletions

View File

@@ -62,6 +62,7 @@ class OSG_EXPORT PagedLOD : public LOD
float _priorityOffset;
float _priorityScale;
double _timeStamp;
int _frameNumber;
osg::ref_ptr<osg::Referenced> _databaseRequest;
};
@@ -85,6 +86,10 @@ class OSG_EXPORT PagedLOD : public LOD
double getTimeStamp(unsigned int childNo) const { return _perRangeDataList[childNo]._timeStamp; }
unsigned int getNumTimeStamps() const { return _perRangeDataList.size(); }
void setFrameNumber(unsigned int childNo, int frameNumber) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._frameNumber=frameNumber; }
double getFrameNumber(unsigned int childNo) const { return _perRangeDataList[childNo]._frameNumber; }
unsigned int getNumFrameNumbers() const { return _perRangeDataList.size(); }
/** Return the DatabaseRequest object used by the DatabasePager to keep track of file load requests
* being carried on behalf of the DatabasePager.
@@ -111,13 +116,11 @@ class OSG_EXPORT PagedLOD : public LOD
/** Get the number of children that the PagedLOD must keep around, even if they are older than their expiry time.*/
unsigned int getNumChildrenThatCannotBeExpired() const { return _numChildrenThatCannotBeExpired; }
/** Remove the children from the PagedLOD which haven't been visited since specified expiry time.
/** Remove the children from the PagedLOD which haven't been visited since specified expiry time and expiry frame number.
* The removed children are added to the removeChildren list passed into the method,
* this allows the children to be deleted later at the caller's discretion.
* Return true if children are removed, false otherwise. */
virtual bool removeExpiredChildren(double expiryTime,NodeList& removedChildren);
virtual bool removeExpiredChildren(double expiryTime, int expiryFrame, NodeList& removedChildren);
protected :