diff --git a/include/osg/Quat b/include/osg/Quat index 9269fc9e3..0f9854797 100644 --- a/include/osg/Quat +++ b/include/osg/Quat @@ -29,66 +29,83 @@ class SG_EXPORT Quat public: - /* ---------------------------------------------------------- - DATA MEMBERS - The only data member is a - Vec4 which holds the elements + typedef double value_type; - In other words, osg:Quat is composed of an osg::Vec4 - The osg::Quat aggregates an osg::Vec4 + value_type _v[4]; // a four-vector - These seem to be different jargon for the same thing :-) - ---------------------------------------------------------- */ - Vec4 _fv; // a four-vector + inline Quat() { _v[0]=0.0; _v[1]=0.0; _v[2]=0.0; _v[3]=0.0; } + + inline Quat( value_type x, value_type y, value_type z, value_type w ) + { + _v[0]=x; + _v[1]=y; + _v[2]=z; + _v[3]=w; + } - inline Quat(): _fv(0.0f,0.0f,0.0f,1.0f) {} - inline Quat( float x, float y, float z, float w ): _fv(x,y,z,w) {} - inline Quat( const Vec4& v ): _fv(v) {} + inline Quat( const Vec4& v ) + { + _v[0]=v.x(); + _v[1]=v.y(); + _v[2]=v.z(); + _v[3]=v.w(); + } - inline Quat( float angle, const Vec3& axis) + inline Quat( value_type angle, const Vec3& axis) { makeRotate(angle,axis); } - inline Quat( float angle1, const Vec3& axis1, - float angle2, const Vec3& axis2, - float angle3, const Vec3& axis3) + inline Quat( value_type angle1, const Vec3& axis1, + value_type angle2, const Vec3& axis2, + value_type angle3, const Vec3& axis3) { makeRotate(angle1,axis1,angle2,axis2,angle3,axis3); } - inline bool operator == (const Quat& rhs) const { return _fv==rhs._fv; } + inline bool operator == (const Quat& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2] && _v[3]==v._v[3]; } - inline bool operator != (const Quat& rhs) const { return _fv!=rhs._fv; } + inline bool operator != (const Quat& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2] || _v[3]!=v._v[3]; } - inline bool operator < (const Quat& rhs) const { return _fvv._v[0]) return false; + else if (_v[1]v._v[1]) return false; + else if (_v[2]v._v[2]) return false; + else return (_v[3] epsilon ) @@ -207,21 +208,20 @@ void Quat::slerp( float t, const Quat& from, const Quat& to ) scale_to = t ; } - // use Vec4 arithmetic - _fv = (from._fv*scale_from) + (quatTo._fv*scale_to); + *this = (from*scale_from) + (quatTo*scale_to); // so that we get a Vec4 } -#define QX _fv[0] -#define QY _fv[1] -#define QZ _fv[2] -#define QW _fv[3] +#define QX _v[0] +#define QY _v[1] +#define QZ _v[2] +#define QW _v[3] #ifdef OSG_USE_UNIT_TESTS -void test_Quat_Eueler(float heading,float pitch,float roll) +void test_Quat_Eueler(value_type heading,value_type pitch,value_type roll) { osg::Quat q; q.makeRotate(heading,pitch,roll); diff --git a/src/osgDB/Field.cpp b/src/osgDB/Field.cpp index 3252cb47c..c1e5b9b51 100644 --- a/src/osgDB/Field.cpp +++ b/src/osgDB/Field.cpp @@ -360,34 +360,12 @@ bool Field::getFloat(float& f) const } } - -bool Field::isDouble() const -{ - getFieldType(); - return _fieldType==REAL || _fieldType==INTEGER; -} - - -bool Field::matchDouble(double d) const +bool Field::getFloat(double& f) const { getFieldType(); if (_fieldType==REAL || _fieldType==INTEGER) { - return atof(_fieldCache)==d; - } - else - { - return false; - } -} - - -bool Field::getDouble(double& d) const -{ - getFieldType(); - if (_fieldType==REAL || _fieldType==INTEGER) - { - d = atof(_fieldCache); + f = (float)atof(_fieldCache); return true; } else diff --git a/src/osgPlugins/osg/ClipPlane.cpp b/src/osgPlugins/osg/ClipPlane.cpp index 944877575..5e23ec8cd 100644 --- a/src/osgPlugins/osg/ClipPlane.cpp +++ b/src/osgPlugins/osg/ClipPlane.cpp @@ -46,10 +46,10 @@ bool ClipPlane_readLocalData(Object& obj, Input& fr) if (fr.matchSequence("plane %f %f %f %f")) { double plane[4]; - fr[1].getDouble(plane[0]); - fr[2].getDouble(plane[1]); - fr[3].getDouble(plane[2]); - fr[4].getDouble(plane[3]); + fr[1].getFloat(plane[0]); + fr[2].getFloat(plane[1]); + fr[3].getFloat(plane[2]); + fr[4].getFloat(plane[3]); clipplane.setClipPlane(plane); fr+=5; diff --git a/src/osgPlugins/osg/DOFTransform.cpp b/src/osgPlugins/osg/DOFTransform.cpp index 60599b1c6..002280f28 100644 --- a/src/osgPlugins/osg/DOFTransform.cpp +++ b/src/osgPlugins/osg/DOFTransform.cpp @@ -48,7 +48,7 @@ bool DOFTransform_readLocalData(Object& obj, Input& fr) { for(int j=0;j<4;++j) { - fr[k].getDouble(v); + fr[k].getFloat(v); matrix(i,j)=v; k++; } diff --git a/src/osgPlugins/osg/Depth.cpp b/src/osgPlugins/osg/Depth.cpp index 392099413..c89a17781 100644 --- a/src/osgPlugins/osg/Depth.cpp +++ b/src/osgPlugins/osg/Depth.cpp @@ -57,7 +57,7 @@ bool Depth_readLocalData(Object& obj, Input& fr) } double znear,zfar; - if (fr[0].matchWord("range") && fr[1].getDouble(znear) && fr[2].getDouble(zfar)) + if (fr[0].matchWord("range") && fr[1].getFloat(znear) && fr[2].getFloat(zfar)) { depth.setRange(znear,zfar); fr+=2; diff --git a/src/osgPlugins/osg/Matrix.cpp b/src/osgPlugins/osg/Matrix.cpp index b2a4ffb3a..475d5faab 100644 --- a/src/osgPlugins/osg/Matrix.cpp +++ b/src/osgPlugins/osg/Matrix.cpp @@ -16,7 +16,7 @@ bool readMatrix(osg::Matrix& matrix, osgDB::Input& fr) double v; while (!fr.eof() && fr[0].getNoNestedBrackets()>entry) { - if (fr[0].getDouble(v)) + if (fr[0].getFloat(v)) { matrix(row,col)=v; ++col; diff --git a/src/osgPlugins/osg/TexMat.cpp b/src/osgPlugins/osg/TexMat.cpp index 3cec5481f..0f895cc3d 100644 --- a/src/osgPlugins/osg/TexMat.cpp +++ b/src/osgPlugins/osg/TexMat.cpp @@ -44,7 +44,7 @@ bool TexMat_readLocalData(Object& obj, Input& fr) { for(int j=0;j<4;++j) { - fr[k].getDouble(v); + fr[k].getFloat(v); matrix(i,j)=v; k++; } diff --git a/src/osgPlugins/osgSim/IO_BlinkSequence.cpp b/src/osgPlugins/osgSim/IO_BlinkSequence.cpp index f73179493..240ac9735 100644 --- a/src/osgPlugins/osgSim/IO_BlinkSequence.cpp +++ b/src/osgPlugins/osgSim/IO_BlinkSequence.cpp @@ -31,7 +31,7 @@ bool BlinkSequence_readLocalData(osg::Object &obj, osgDB::Input &fr) if (fr.matchSequence("phaseShift %f")) { double ps; - fr[1].getDouble(ps); + fr[1].getFloat(ps); fr += 2; seq.setPhaseShift(ps); iteratorAdvanced = true; @@ -40,7 +40,7 @@ bool BlinkSequence_readLocalData(osg::Object &obj, osgDB::Input &fr) { double length; float r, g, b, a; - fr[1].getDouble(length); + fr[1].getFloat(length); fr[2].getFloat(r); fr[3].getFloat(g); fr[4].getFloat(b); @@ -103,7 +103,7 @@ bool BlinkSequence_SequenceGroup_readLocalData(osg::Object &obj, osgDB::Input &f if (fr.matchSequence("baseTime %f")) { - fr[1].getDouble(sg._baseTime); + fr[1].getFloat(sg._baseTime); fr += 2; iteratorAdvanced = true; }