From db49c239443a54aad3e0ed5e182db4be5a0dbca7 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 6 Feb 2012 12:06:40 +0000 Subject: [PATCH] From Brad Christiansen, "The attached files add the ability to control when a paged child becomes eligible for expiry based on time and/or elapsed frames. I found that some of the items that had been paged in were being expired on the first frame that they were not visible (as the cache was full). This resulted in excessive paging every time the view was moved. With the following changes I could only allow children to be expired if they had not been used for e.g. 30 seconds or 60 frames." --- include/osg/PagedLOD | 12 ++++++++++++ src/osg/PagedLOD.cpp | 10 ++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/osg/PagedLOD b/include/osg/PagedLOD index 3f2711e4f..a4d527fb8 100644 --- a/include/osg/PagedLOD +++ b/include/osg/PagedLOD @@ -70,6 +70,8 @@ class OSG_EXPORT PagedLOD : public LOD std::string _filename; float _priorityOffset; float _priorityScale; + double _minExpiryTime; + unsigned int _minExpiryFrames; double _timeStamp; unsigned int _frameNumber; unsigned int _frameNumberOfLastReleaseGLObjects; @@ -91,6 +93,16 @@ class OSG_EXPORT PagedLOD : public LOD float getPriorityScale(unsigned int childNo) const { return _perRangeDataList[childNo]._priorityScale; } unsigned int getNumPriorityScales() const { return _perRangeDataList.size(); } + /** Sets the minimum amount of time, in seconds, that must pass without a child being traversed before it can be expired. */ + void setMinimumExpiryTime(unsigned int childNo, double minTime) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._minExpiryTime=minTime; } + double getMinimumExpiryTime(unsigned int childNo) const { return _perRangeDataList[childNo]._minExpiryTime; } + unsigned int getNumMinimumExpiryTimes() const { return _perRangeDataList.size(); } + + /** Sets the minimum number of frames that must be rendered without a child being traversed before it can be expired. */ + void setMinimumExpiryFrames(unsigned int childNo, unsigned int minFrames) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._minExpiryFrames=minFrames; } + unsigned int getMinimumExpiryFrames(unsigned int childNo) const { return _perRangeDataList[childNo]._minExpiryFrames; } + unsigned int getNumMinimumExpiryFrames() const { return _perRangeDataList.size(); } + void setTimeStamp(unsigned int childNo, double timeStamp) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._timeStamp=timeStamp; } double getTimeStamp(unsigned int childNo) const { return _perRangeDataList[childNo]._timeStamp; } diff --git a/src/osg/PagedLOD.cpp b/src/osg/PagedLOD.cpp index 306dddca9..f52daa239 100644 --- a/src/osg/PagedLOD.cpp +++ b/src/osg/PagedLOD.cpp @@ -22,6 +22,8 @@ using namespace osg; PagedLOD::PerRangeData::PerRangeData(): _priorityOffset(0.0f), _priorityScale(1.0f), + _minExpiryTime(0.0), + _minExpiryFrames(0), _timeStamp(0.0f), _frameNumber(0), _frameNumberOfLastReleaseGLObjects(0) {} @@ -30,6 +32,8 @@ PagedLOD::PerRangeData::PerRangeData(const PerRangeData& prd): _filename(prd._filename), _priorityOffset(prd._priorityOffset), _priorityScale(prd._priorityScale), + _minExpiryTime(prd._minExpiryTime), + _minExpiryFrames(prd._minExpiryFrames), _timeStamp(prd._timeStamp), _frameNumber(prd._frameNumber), _frameNumberOfLastReleaseGLObjects(prd._frameNumberOfLastReleaseGLObjects), @@ -45,6 +49,8 @@ PagedLOD::PerRangeData& PagedLOD::PerRangeData::operator = (const PerRangeData& _frameNumber = prd._frameNumber; _frameNumberOfLastReleaseGLObjects = prd._frameNumberOfLastReleaseGLObjects; _databaseRequest = prd._databaseRequest; + _minExpiryTime = prd._minExpiryTime; + _minExpiryFrames = prd._minExpiryFrames; return *this; } @@ -290,8 +296,8 @@ bool PagedLOD::removeExpiredChildren(double expiryTime, unsigned int expiryFrame { unsigned cindex = _children.size() - 1; if (!_perRangeDataList[cindex]._filename.empty() && - _perRangeDataList[cindex]._timeStamp