From 1baffa3a778fc39b79f0fb215c71d4c436d2c4fe Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 9 Dec 2003 12:08:27 +0000 Subject: [PATCH] Addition of the following methods: /** Set the object-space reference radius of the volume enclosed by the PagedLOD. * Used to detmine the bounding sphere of the PagedLOD in the absense of any children.*/ inline void setRadius(float radius) { _radius = radius; } /** Get the object-space radius of the volume enclosed by the PagedLOD.*/ inline float getRadius() const { return _radius; } /** Set the number of children that the PagedLOD must keep around, even if thay are older than their expiry time.*/ inline void setNumChildrenThatCannotBeExpired(unsigned int num) { _numChildrenThatCannotBeExpired = num; } /** Get the number of children that the PagedLOD must keep around, even if thay are older than their expiry time.*/ unsigned int getNumChildrenThatCannotBeExpired() const { return _numChildrenThatCannotBeExpired; } --- include/osg/PagedLOD | 19 +++++++++++++++++++ src/osg/PagedLOD.cpp | 27 +++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/include/osg/PagedLOD b/include/osg/PagedLOD index 98515708d..f1040d956 100644 --- a/include/osg/PagedLOD +++ b/include/osg/PagedLOD @@ -74,6 +74,21 @@ class SG_EXPORT PagedLOD : public LOD /** return the list of time stamps.*/ inline const TimeStampList& getTimeStampList() const { return _timeStampList; } + + /** Set the object-space reference radius of the volume enclosed by the PagedLOD. + * Used to detmine the bounding sphere of the PagedLOD in the absense of any children.*/ + inline void setRadius(float radius) { _radius = radius; } + + /** Get the object-space radius of the volume enclosed by the PagedLOD.*/ + inline float getRadius() const { return _radius; } + + + /** Set the number of children that the PagedLOD must keep around, even if thay are older than their expiry time.*/ + inline void setNumChildrenThatCannotBeExpired(unsigned int num) { _numChildrenThatCannotBeExpired = num; } + + /** Get the number of children that the PagedLOD must keep around, even if thay are older than their expiry time.*/ + unsigned int getNumChildrenThatCannotBeExpired() const { return _numChildrenThatCannotBeExpired; } + /** Remove the children from the PagedLOD which haven't be visited since specified expiry time. The removed children are added the removeChildren list passed into the method, this allows the children to be deleted later at the callers discression.*/ @@ -83,6 +98,10 @@ class SG_EXPORT PagedLOD : public LOD virtual ~PagedLOD() {} + virtual bool computeBound() const; + + float _radius; + unsigned int _numChildrenThatCannotBeExpired; FileNameList _fileNameList; TimeStampList _timeStampList; }; diff --git a/src/osg/PagedLOD.cpp b/src/osg/PagedLOD.cpp index 2f321b3e2..400b3a815 100644 --- a/src/osg/PagedLOD.cpp +++ b/src/osg/PagedLOD.cpp @@ -5,13 +5,20 @@ using namespace osg; PagedLOD::PagedLOD() { _centerMode = USER_DEFINED_CENTER; + _radius = -1; + _numChildrenThatCannotBeExpired = 0; } PagedLOD::PagedLOD(const PagedLOD& plod,const CopyOp& copyop): - LOD(plod,copyop) + LOD(plod,copyop), + _radius(plod._radius), + _numChildrenThatCannotBeExpired(plod._numChildrenThatCannotBeExpired), + _fileNameList(plod._fileNameList), + _timeStampList(plod._timeStampList) { } + void PagedLOD::traverse(NodeVisitor& nv) { @@ -73,6 +80,22 @@ void PagedLOD::traverse(NodeVisitor& nv) } } +bool PagedLOD::computeBound() const +{ + if (_centerMode==USER_DEFINED_CENTER && _radius>=0.0f) + { + _bsphere._center = _userDefinedCenter; + _bsphere._radius = _radius; + _bsphere_computed = true; + + return true; + } + else + { + return LOD::computeBound(); + } +} + bool PagedLOD::addChild( Node *child ) { if (LOD::addChild(child)) @@ -138,7 +161,7 @@ void PagedLOD::setTimeStamp(unsigned int childNo, double timeStamp) void PagedLOD::removeExpiredChildren(double expiryTime,NodeList& removedChildren) { - for(unsigned int i=_children.size();i>0;) + for(unsigned int i=_children.size();i>_numChildrenThatCannotBeExpired;) { --i; if (!_fileNameList[i].empty() && _timeStampList[i]