Moved the radius parameter from PageLOD into LOD.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -68,8 +68,12 @@ void FragmentProgram::read(DataInputStream* in){
|
||||
// Read data
|
||||
int i, size;
|
||||
size = in->readInt();
|
||||
for(i=0; i<size; i++)
|
||||
this->setProgramLocalParameter( in->readInt(), in->readVec4() );
|
||||
for(i=0; i<size; i++)
|
||||
{
|
||||
int index = in->readInt();
|
||||
osg::Vec4 v = in->readVec4();
|
||||
this->setProgramLocalParameter( index, v );
|
||||
}
|
||||
|
||||
std::string fp = in->readString();
|
||||
this->setFragmentProgram( fp );
|
||||
|
||||
@@ -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;i<size;i++){
|
||||
|
||||
@@ -62,6 +62,10 @@ void PagedLOD::write(DataOutputStream* out){
|
||||
// Write centermode
|
||||
out->writeInt(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<size;i++){
|
||||
|
||||
@@ -39,6 +39,15 @@ bool LOD_readLocalData(Object& obj, Input& fr)
|
||||
fr+=4;
|
||||
}
|
||||
|
||||
float radius;
|
||||
if (fr[0].matchWord("Radius") && fr[1].getFloat(radius))
|
||||
{
|
||||
lod.setRadius(radius);
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
|
||||
// For backwards compatibility with old style LOD's (pre October 2002).
|
||||
bool matchFirst = false;
|
||||
if ((matchFirst=fr.matchSequence("Ranges {")) || fr.matchSequence("Ranges %i {"))
|
||||
@@ -123,6 +132,8 @@ bool LOD_writeLocalData(const Object& obj, Output& fw)
|
||||
|
||||
if (lod.getCenterMode()==osg::LOD::USER_DEFINED_CENTER) fw.indent() << "Center "<< lod.getCenter() << std::endl;
|
||||
|
||||
fw.indent() << "Radius "<<lod.getRadius()<<std::endl;
|
||||
|
||||
fw.indent() << "RangeList "<<lod.getNumRanges()<<" {"<< std::endl;
|
||||
fw.moveIn();
|
||||
|
||||
|
||||
@@ -27,14 +27,6 @@ bool PagedLOD_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
PagedLOD& lod = static_cast<PagedLOD&>(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<const PagedLOD&>(obj);
|
||||
|
||||
fw.indent() << "Radius "<<lod.getRadius()<<std::endl;
|
||||
|
||||
fw.indent() << "NumChildrenThatCannotBeExpired "<<lod.getNumChildrenThatCannotBeExpired()<<std::endl;
|
||||
|
||||
fw.indent() << "FileNameList "<<lod.getNumFileNames()<<" {"<< std::endl;
|
||||
|
||||
Reference in New Issue
Block a user