diff --git a/include/osg/LOD b/include/osg/LOD index fd86a4df8..f9c7fa296 100644 --- a/include/osg/LOD +++ b/include/osg/LOD @@ -76,6 +76,15 @@ class SG_EXPORT LOD : public Group inline const Vec3& getCenter() const { if (_centerMode==USER_DEFINED_CENTER) return _userDefinedCenter; else return getBound().center(); } + /** Set the object-space reference radius of the volume enclosed by the LOD. + * Used to detmine the bounding sphere of the LOD in the absense of any children.*/ + inline void setRadius(float radius) { _radius = radius; } + + /** Get the object-space radius of the volume enclosed by the LOD.*/ + inline float getRadius() const { return _radius; } + + + /** Modes that control how the range values should be intepreted when computing which child is active.*/ enum RangeMode { @@ -110,6 +119,8 @@ class SG_EXPORT LOD : public Group protected : virtual ~LOD() {} + virtual bool computeBound() const; + virtual void childRemoved(unsigned int pos, unsigned int numChildrenToRemove); virtual void childInserted(unsigned int pos); @@ -118,6 +129,7 @@ class SG_EXPORT LOD : public Group CenterMode _centerMode; Vec3 _userDefinedCenter; + float _radius; RangeMode _rangeMode; RangeList _rangeList; diff --git a/include/osg/PagedLOD b/include/osg/PagedLOD index 6d57d74e9..9ef5bf44f 100644 --- a/include/osg/PagedLOD +++ b/include/osg/PagedLOD @@ -77,14 +77,6 @@ class SG_EXPORT PagedLOD : public LOD unsigned int getNumTimeStamps() const { return _perRangeDataList.size(); } - /** 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; } @@ -100,8 +92,6 @@ class SG_EXPORT PagedLOD : public LOD virtual ~PagedLOD() {} - virtual bool computeBound() const; - virtual void childRemoved(unsigned int pos, unsigned int numChildrenToRemove); virtual void childInserted(unsigned int pos); @@ -110,7 +100,6 @@ class SG_EXPORT PagedLOD : public LOD void expandPerRangeDataTo(unsigned int pos); - float _radius; unsigned int _numChildrenThatCannotBeExpired; PerRangeDataList _perRangeDataList; diff --git a/src/osg/LOD.cpp b/src/osg/LOD.cpp index 0103fc1cc..b7894063d 100644 --- a/src/osg/LOD.cpp +++ b/src/osg/LOD.cpp @@ -26,6 +26,7 @@ LOD::LOD(const LOD& lod,const CopyOp& copyop): Group(lod,copyop), _centerMode(lod._centerMode), _userDefinedCenter(lod._userDefinedCenter), + _radius(lod._radius), _rangeList(lod._rangeList) { } @@ -80,6 +81,22 @@ void LOD::traverse(NodeVisitor& nv) } } +bool LOD::computeBound() const +{ + if (_centerMode==USER_DEFINED_CENTER && _radius>=0.0f) + { + _bsphere._center = _userDefinedCenter; + _bsphere._radius = _radius; + _bsphere_computed = true; + + return true; + } + else + { + return Group::computeBound(); + } +} + bool LOD::addChild( Node *child ) { if (Group::addChild(child)) diff --git a/src/osg/PagedLOD.cpp b/src/osg/PagedLOD.cpp index 4d4b41521..74ba86e98 100644 --- a/src/osg/PagedLOD.cpp +++ b/src/osg/PagedLOD.cpp @@ -32,7 +32,6 @@ PagedLOD::PagedLOD() PagedLOD::PagedLOD(const PagedLOD& plod,const CopyOp& copyop): LOD(plod,copyop), - _radius(plod._radius), _numChildrenThatCannotBeExpired(plod._numChildrenThatCannotBeExpired), _perRangeDataList(plod._perRangeDataList) { @@ -108,21 +107,6 @@ 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(); - } -} void PagedLOD::childRemoved(unsigned int pos, unsigned int numChildrenToRemove) { diff --git a/src/osgPlugins/ive/FragmentProgram.cpp b/src/osgPlugins/ive/FragmentProgram.cpp index 156ae9979..94d254f94 100644 --- a/src/osgPlugins/ive/FragmentProgram.cpp +++ b/src/osgPlugins/ive/FragmentProgram.cpp @@ -68,8 +68,12 @@ void FragmentProgram::read(DataInputStream* in){ // Read data int i, size; size = in->readInt(); - for(i=0; isetProgramLocalParameter( in->readInt(), in->readVec4() ); + for(i=0; ireadInt(); + osg::Vec4 v = in->readVec4(); + this->setProgramLocalParameter( index, v ); + } std::string fp = in->readString(); this->setFragmentProgram( fp ); diff --git a/src/osgPlugins/ive/LOD.cpp b/src/osgPlugins/ive/LOD.cpp index 92e7fe6bd..4d45f0de5 100644 --- a/src/osgPlugins/ive/LOD.cpp +++ b/src/osgPlugins/ive/LOD.cpp @@ -30,9 +30,14 @@ void LOD::write(DataOutputStream* out){ throw Exception("LOD::write(): Could not cast this osg::LOD to an osg::Group."); // Write LOD's properties. + out->writeFloat(getRadius()); + // Write centermode out->writeInt(getCenterMode()); out->writeVec3(getCenter()); + + out->writeInt(getRangeMode()); + // Write rangelist int size = getNumRanges(); out->writeInt(size); @@ -57,9 +62,14 @@ void LOD::read(DataInputStream* in){ throw Exception("LOD::read(): Could not cast this osg::LOD to an osg::Group."); // Read LOD's properties + setRadius(in->readFloat()); + // Read centermode setCenterMode((osg::LOD::CenterMode)in->readInt()); setCenter(in->readVec3()); + + setRangeMode((RangeMode)in->readInt()); + // Read rangelist int size = in->readInt();; for(int i=0;iwriteInt(getCenterMode()); out->writeVec3(getCenter()); + + out->writeInt(getRangeMode()); + + // Write rangelist int size = getNumRanges(); out->writeInt(size); @@ -110,6 +114,9 @@ void PagedLOD::read(DataInputStream* in){ // Read centermode setCenterMode((osg::LOD::CenterMode)in->readInt()); setCenter(in->readVec3()); + + setRangeMode((RangeMode)in->readInt()); + // Read rangelist size = in->readInt(); for(i=0;i(obj); - float radius; - if (fr[0].matchWord("Radius") && fr[1].getFloat(radius)) - { - lod.setRadius(radius); - fr+=2; - iteratorAdvanced = true; - } - unsigned int num; if (fr[0].matchWord("NumChildrenThatCannotBeExpired") && fr[1].getUInt(num)) { @@ -104,8 +96,6 @@ bool PagedLOD_writeLocalData(const Object& obj, Output& fw) { const PagedLOD& lod = static_cast(obj); - fw.indent() << "Radius "<