diff --git a/include/osg/Math b/include/osg/Math index 1c6debca0..d05b12bc6 100644 --- a/include/osg/Math +++ b/include/osg/Math @@ -7,8 +7,6 @@ #include -// #define USE_DEGREES_INTERNALLY - #if defined(WIN32) || defined (macintosh) #include #define M_E 2.7182818284590452354 @@ -70,13 +68,8 @@ namespace osg { -#ifdef USE_DEGREES_INTERNALLY - inline double inDegrees(double angle) { return angle; } - inline double inRadians(double angle) { return angle*180.0/M_PI; } -#else - inline double inDegrees(double angle) { return angle*M_PI/180.0; } - inline double inRadians(double angle) { return angle; } -#endif +inline double inDegrees(double angle) { return angle*M_PI/180.0; } +inline double inRadians(double angle) { return angle; } inline double DegreesToRadians(double angle) { return angle*M_PI/180.0; } inline double RadiansToDegrees(double angle) { return angle*180.0/M_PI; } diff --git a/include/osg/Matrix b/include/osg/Matrix index f18d3ca01..e34c2d110 100644 --- a/include/osg/Matrix +++ b/include/osg/Matrix @@ -17,9 +17,6 @@ using std::ostream; using std::endl; #endif -// temporary #define to keep backwards compatibility. -//#define USE_DEPRECATED_MATRIX_METHODS - namespace osg { class Quat; @@ -71,17 +68,17 @@ class SG_EXPORT Matrix : public Object void makeScale( const Vec3& ); void makeScale( float, float, float ); - void makeTrans( const Vec3& ); - void makeTrans( float, float, float ); + void makeTranslate( const Vec3& ); + void makeTranslate( float, float, float ); //TODO: original preTrans was optimized (M=Tr*M) // but also has the assumption that M (this) is an affine transformation Matrix // can I still do something to optimize the same case now? - void makeRot( const Vec3& from, const Vec3& to ); - void makeRot( float angle, const Vec3& axis ); - void makeRot( float angle, float x, float y, float z ); - void makeRot( const Quat& ); - void makeRot( float, float, float ); //Euler angles + void makeRotate( const Vec3& from, const Vec3& to ); + void makeRotate( float angle, const Vec3& axis ); + void makeRotate( float angle, float x, float y, float z ); + void makeRotate( const Quat& ); + void makeRotate( float, float, float ); //Euler angles bool invert( const Matrix& ); bool invertAffine( const Matrix& ); @@ -90,8 +87,8 @@ class SG_EXPORT Matrix : public Object inline static Matrix identity( void ); inline static Matrix scale( const Vec3& ); inline static Matrix scale( float, float, float ); - inline static Matrix trans( const Vec3& ); - inline static Matrix trans( float, float, float ); + inline static Matrix translate( const Vec3& ); + inline static Matrix translate( float, float, float ); inline static Matrix rotate( const Vec3&, const Vec3& ); inline static Matrix rotate( float, float, float, float ); inline static Matrix rotate( float angle, const Vec3& axis); @@ -108,32 +105,10 @@ class SG_EXPORT Matrix : public Object void setTrans( const Vec3& v ); Vec3 getTrans() const { ensureRealized(); return Vec3(_mat[3][0],_mat[3][1],_mat[3][2]); } -#ifdef USE_DEPRECATED_MATRIX_METHODS - - void copy( const Matrix& ); - void preScale( float sx, float sy, float sz, const Matrix& m ); - void postScale( const Matrix& m, float sx, float sy, float sz ); - void preScale( float sx, float sy, float sz ); - void postScale( float sx, float sy, float sz ); - - void preTrans( float tx, float ty, float tz, const Matrix& m ); - void postTrans( const Matrix& m, float tx, float ty, float tz ); - void preTrans( float tx, float ty, float tz); - void postTrans( float tx, float ty, float tz ); - - void preRot( float deg, float x, float y, float z, const Matrix& m ); - void postRot( const Matrix& m, float deg, float x, float y, float z ); - void preRot( float deg, float x, float y, float z ); - void postRot( float deg, float x, float y, float z ); - -#endif - /** apply apply an 3x3 transform of v*M[0..2,0..2] */ inline static Vec3 transform3x3(const Vec3& v,const Matrix& m); /** apply apply an 3x3 transform of M[0..2,0..2]*v */ inline static Vec3 transform3x3(const Matrix& m,const Vec3& v); - -//end of Deprecated methods // basic Matrix multiplication, our workhorse methods. @@ -201,40 +176,40 @@ inline Matrix Matrix::scale(const Vec3& v ) return scale(v.x(), v.y(), v.z() ); } -inline Matrix Matrix::trans(float tx, float ty, float tz) +inline Matrix Matrix::translate(float tx, float ty, float tz) { Matrix m; - m.makeTrans(tx,ty,tz); + m.makeTranslate(tx,ty,tz); return m; } -inline Matrix Matrix::trans(const Vec3& v ) +inline Matrix Matrix::translate(const Vec3& v ) { - return trans(v.x(), v.y(), v.z() ); + return translate(v.x(), v.y(), v.z() ); } inline Matrix Matrix::rotate( const Quat& q ) { Matrix m; - m.makeRot( q ); + m.makeRotate( q ); return m; } inline Matrix Matrix::rotate(float angle, float x, float y, float z ) { Matrix m; - m.makeRot(angle,x,y,z); + m.makeRotate(angle,x,y,z); return m; } inline Matrix Matrix::rotate(float angle, const Vec3& axis ) { Matrix m; - m.makeRot(angle,axis); + m.makeRotate(angle,axis); return m; } inline Matrix Matrix::rotate(const Vec3& from, const Vec3& to ) { Matrix m; - m.makeRot(from,to); + m.makeRotate(from,to); return m; } diff --git a/include/osg/Quat b/include/osg/Quat index 5e6ec464f..80bb71ffc 100644 --- a/include/osg/Quat +++ b/include/osg/Quat @@ -199,16 +199,16 @@ class SG_EXPORT Quat Not inlined - see the Quat.cpp file for implementation -------------------------------------------------------- */ - void makeRot ( const float angle, + void makeRotate ( const float angle, const float x, const float y, const float z ); - void makeRot ( const float angle, const Vec3& vec ); + void makeRotate ( const float angle, const Vec3& vec ); /** Make a rotation Quat which will rotate vec1 to vec2. Generally take adot product to get the angle between these and then use a cross product to get the rotation axis Watch out for the two special cases of when the vectors are co-incident or opposite in direction.*/ - void makeRot( const Vec3& vec1, const Vec3& vec2 ); + void makeRotate( const Vec3& vec1, const Vec3& vec2 ); /** Return the angle and vector components represented by the quaternion.*/ void getRot ( float& angle, float& x, float& y, float& z ) const; diff --git a/include/osg/Transform b/include/osg/Transform index f014ae579..f5b81551b 100644 --- a/include/osg/Transform +++ b/include/osg/Transform @@ -63,12 +63,6 @@ class SG_EXPORT Transform : public Group (*_matrix) = (*_matrix) * mat; dirtyBound(); } - -#ifdef USE_DEPRECATED_MATRIX_METHODS - void preScale( const float sx, const float sy, const float sz ); - void preTranslate( const float tx, const float ty, const float tz ); - void preRotate( const float deg, const float x, const float y, const float z ); -#endif protected : diff --git a/src/Demos/hangglide/GliderManipulator.cpp b/src/Demos/hangglide/GliderManipulator.cpp index bd14657e3..cca84983e 100644 --- a/src/Demos/hangglide/GliderManipulator.cpp +++ b/src/Demos/hangglide/GliderManipulator.cpp @@ -208,7 +208,7 @@ bool GliderManipulator::calcMovement() float roll = inDegrees(dx*0.1f*dt); osg::Matrix mat; - mat.makeTrans(-center); + mat.makeTranslate(-center); mat *= Matrix::rotate(pitch,sv.x(),sv.y(),sv.z()); mat *= Matrix::rotate(roll,lv.x(),lv.y(),lv.z()); if (_yawMode==YAW_AUTOMATICALLY_WHEN_BANKED) @@ -220,7 +220,7 @@ bool GliderManipulator::calcMovement() lv *= (_velocity*dt); - mat *= Matrix::trans(center + lv); + mat *= Matrix::translate(center + lv); _camera->transformLookAt(mat); diff --git a/src/Demos/osgcluster/osgcluster.cpp b/src/Demos/osgcluster/osgcluster.cpp index f9685ab96..295414989 100644 --- a/src/Demos/osgcluster/osgcluster.cpp +++ b/src/Demos/osgcluster/osgcluster.cpp @@ -43,7 +43,7 @@ class CameraPacket { osg::Vec3 lv = _center-_eye; osg::Matrix matrix; matrix.makeIdent(); - matrix.makeRot(angle_offset,_up.x(),_up.y(),_up.z()); + matrix.makeRotate(angle_offset,_up.x(),_up.y(),_up.z()); lv = lv*matrix; camera.setLookAt(_eye,_eye+lv,_up); diff --git a/src/Demos/osgconv/OrientationConverter.cpp b/src/Demos/osgconv/OrientationConverter.cpp index ff443a1f1..132c313ca 100644 --- a/src/Demos/osgconv/OrientationConverter.cpp +++ b/src/Demos/osgconv/OrientationConverter.cpp @@ -24,7 +24,7 @@ void OrientationConverter::setRotation( const Vec3 &from, const Vec3 &to ) void OrientationConverter::setTranslation( const Vec3 &trans ) { - T = Matrix::trans(trans); + T = Matrix::translate(trans); _trans_set = true; } @@ -45,9 +45,9 @@ void OrientationConverter::convert( Node &node ) // else // - translate back to model's original origin. BoundingSphere bs = node.getBound(); - Matrix C = Matrix::trans( Vec3(0,0,0) - bs.center() ); + Matrix C = Matrix::translate( Vec3(0,0,0) - bs.center() ); if( _trans_set == false ) - T = Matrix::trans( bs.center() ); + T = Matrix::translate( bs.center() ); _cv.setMatrix( C * R * S * T ); node.accept(_cv); diff --git a/src/Demos/osgcube/osgcube.cpp b/src/Demos/osgcube/osgcube.cpp index 0bf3b39c6..d8066c19b 100644 --- a/src/Demos/osgcube/osgcube.cpp +++ b/src/Demos/osgcube/osgcube.cpp @@ -45,8 +45,8 @@ class MyTransformCallback : public osg::NodeCallback{ float delta_angle = _angular_velocity*_timer.delta_s(_orig_t,new_t); osg::Matrix matrix; - matrix.makeRot(delta_angle,1.0f,1.0f,1.0f); - matrix *= osg::Matrix::trans(1.0f,0.0f,0.0f); + matrix.makeRotate(delta_angle,1.0f,1.0f,1.0f); + matrix *= osg::Matrix::translate(1.0f,0.0f,0.0f); matrix *= osg::Matrix::rotate(delta_angle,0.0f,0.0f,1.0f); _nodeToOperateOn->setMatrix(matrix); diff --git a/src/Demos/osgreflect/osgreflect.cpp b/src/Demos/osgreflect/osgreflect.cpp index dd6ae1c1a..0c4bf140c 100644 --- a/src/Demos/osgreflect/osgreflect.cpp +++ b/src/Demos/osgreflect/osgreflect.cpp @@ -367,9 +367,9 @@ int main( int argc, char **argv ) osg::Transform* dcs = new osg::Transform; dcs->setStateSet(dstate); - dcs->preMult(osg::Matrix::trans(0.0f,0.0f,-z)* + dcs->preMult(osg::Matrix::translate(0.0f,0.0f,-z)* osg::Matrix::scale(1.0f,1.0f,-1.0f)* - osg::Matrix::trans(0.0f,0.0f,z)); + osg::Matrix::translate(0.0f,0.0f,z)); dcs->addChild(loadedModelTransform); diff --git a/src/Demos/osgtexture/osgtexture.cpp b/src/Demos/osgtexture/osgtexture.cpp index 045eeca81..07008467e 100644 --- a/src/Demos/osgtexture/osgtexture.cpp +++ b/src/Demos/osgtexture/osgtexture.cpp @@ -115,7 +115,7 @@ osg::Node* createTexturedItem(const osg::Vec3& offset,osg::Texture* texture,osg: // place and also to add individual texture set to it, so that // that state is inherited down to its children. osg::Transform* local_transform = new osg::Transform; - local_transform->postMult(osg::Matrix::trans(offset)); + local_transform->postMult(osg::Matrix::translate(offset)); // create the StateSet to store the texture data osg::StateSet* stateset = new osg::StateSet; @@ -140,7 +140,7 @@ osg::Node* createLayer(const osg::Vec3& offset,osg::Image* image,osg::Node* geom if (image==NULL) return NULL; osg::Transform* top_transform = new osg::Transform; - top_transform->postMult(osg::Matrix::trans(offset)); + top_transform->postMult(osg::Matrix::translate(offset)); osg::Vec3 local_offset(0.0f,0.0f,0.0f); osg::Vec3 local_delta(3.0f,0.0f,0.0f); diff --git a/src/osg/Billboard.cpp b/src/osg/Billboard.cpp index 29a7429b2..e36f51e76 100644 --- a/src/osg/Billboard.cpp +++ b/src/osg/Billboard.cpp @@ -84,7 +84,7 @@ void Billboard::calcRotation(const Vec3& eye_local, const Vec3& pos_local,Matrix { mat.makeIdent(); //float rotation_zrotation_z = atan2f(ev.x(),ev.y()); - //mat.makeRot(inRadians(rotation_z),0.0f,0.0f,1.0f); + //mat.makeRotate(inRadians(rotation_z),0.0f,0.0f,1.0f); float inv = 1.0f/ev_length; float c = ev.y()*inv; float s = ev.x()*inv; @@ -122,7 +122,7 @@ void Billboard::calcRotation(const Vec3& eye_local, const Vec3& pos_local,Matrix cp /= cp_len; float rotation_cp = acosf(dot); - mat.makeRot(inRadians(rotation_cp),cp[0],cp[1],cp[2]); + mat.makeRotate(inRadians(rotation_cp),cp[0],cp[1],cp[2]); } } break; @@ -133,7 +133,7 @@ void Billboard::calcRotation(const Vec3& eye_local, const Vec3& pos_local,Matrix void Billboard::calcTransform(const Vec3& eye_local, const Vec3& pos_local,Matrix& mat) const { - // mat.makeTrans(pos_local[0],pos_local[1],pos_local[2]); + // mat.makeTranslate(pos_local[0],pos_local[1],pos_local[2]); // mat.makeIdent(); calcRotation(eye_local,pos_local,mat); diff --git a/src/osg/Camera.cpp b/src/osg/Camera.cpp index d381aa304..8755de0c4 100644 --- a/src/osg/Camera.cpp +++ b/src/osg/Camera.cpp @@ -678,7 +678,7 @@ void Camera::calculateMatricesAndClippingVolume() const s[2], u[2], -f[2], 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); - (*matrix) = Matrix::trans(-_eye[0], -_eye[1], -_eye[2]) * (*matrix); + (*matrix) = Matrix::translate(-_eye[0], -_eye[1], -_eye[2]) * (*matrix); if (_modelToEyeTransform.valid()) { @@ -696,7 +696,7 @@ void Camera::calculateMatricesAndClippingVolume() const if (_useEyeOffset) { - (*_modelViewMatrix) = (*_modelViewMatrix) * Matrix::trans(-_eyeOffset*_focalLength/_screenDistance); + (*_modelViewMatrix) = (*_modelViewMatrix) * Matrix::translate(-_eyeOffset*_focalLength/_screenDistance); } diff --git a/src/osg/Matrix.cpp b/src/osg/Matrix.cpp index 0d26b48e6..56626a0d5 100644 --- a/src/osg/Matrix.cpp +++ b/src/osg/Matrix.cpp @@ -8,31 +8,9 @@ using namespace osg; - #define DEG2RAD(x) ((x)*M_PI/180.0) #define RAD2DEG(x) ((x)*180.0/M_PI) - -// temporary #define's for warning that deprecated methods are being -// used which should be replaced by the new variants. -#define WARN_DEPRECATED -//#define ABORT_DEPRECATED - -#ifdef WARN_DEPRECATED - #ifdef ABORT_DEPRECATED - - #define DEPRECATED(message) \ - notify(NOTICE) << message< 12 osg::Vec3 pos = m.getTrans(); - m *= osg::Matrix::trans(-pos.x(),-pos.y(),-pos.z()); + m *= osg::Matrix::translate(-pos.x(),-pos.y(),-pos.z()); pos *= (float)_unitScale; - m *= osg::Matrix::trans(pos); + m *= osg::Matrix::translate(pos); dcs->setMatrix(m); osgParent->addChild(dcs); diff --git a/src/osgPlugins/obj/ReaderWriterOBJ.cpp b/src/osgPlugins/obj/ReaderWriterOBJ.cpp index 5611949ee..20b0e0b4f 100644 --- a/src/osgPlugins/obj/ReaderWriterOBJ.cpp +++ b/src/osgPlugins/obj/ReaderWriterOBJ.cpp @@ -157,7 +157,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(const std::string& fil // note obj_x -> osg_x, // obj_y -> osg_z, // obj_z -> osg_y, - xform->setMatrix(osg::Matrix::trans(obj->position[0], obj->position[2], obj->position[1])); + xform->setMatrix(osg::Matrix::translate(obj->position[0], obj->position[2], obj->position[1])); osg_top = xform; } else diff --git a/src/osgUtil/DriveManipulator.cpp b/src/osgUtil/DriveManipulator.cpp index 76863166b..95d224174 100644 --- a/src/osgUtil/DriveManipulator.cpp +++ b/src/osgUtil/DriveManipulator.cpp @@ -408,9 +408,9 @@ bool DriveManipulator::calcMovement() float yaw = -inDegrees(dx*0.1f*dt); osg::Matrix mat; - mat.makeTrans(-center.x(),-center.y(),-center.z()); + mat.makeTranslate(-center.x(),-center.y(),-center.z()); mat *= Matrix::rotate(yaw,uv.x(),uv.y(),uv.z()); - mat *= Matrix::trans(center.x(),center.y(),center.z()); + mat *= Matrix::translate(center.x(),center.y(),center.z()); center = _camera->getEyePoint(); uv = _camera->getUpVector(); diff --git a/src/osgUtil/FlightManipulator.cpp b/src/osgUtil/FlightManipulator.cpp index 39e65bc66..faad55cd8 100644 --- a/src/osgUtil/FlightManipulator.cpp +++ b/src/osgUtil/FlightManipulator.cpp @@ -205,7 +205,7 @@ bool FlightManipulator::calcMovement() float roll = inDegrees(dx*0.1f*dt); osg::Matrix mat; - mat.makeTrans(-center); + mat.makeTranslate(-center); mat *= Matrix::rotate(pitch,sv.x(),sv.y(),sv.z()); mat *= Matrix::rotate(roll,lv.x(),lv.y(),lv.z()); if (_yawMode==YAW_AUTOMATICALLY_WHEN_BANKED) @@ -217,7 +217,7 @@ bool FlightManipulator::calcMovement() lv *= (_velocity*dt); - mat *= Matrix::trans(center+lv); + mat *= Matrix::translate(center+lv); _camera->transformLookAt(mat); diff --git a/src/osgUtil/TrackballManipulator.cpp b/src/osgUtil/TrackballManipulator.cpp index d0c884d6b..7d29a34ea 100644 --- a/src/osgUtil/TrackballManipulator.cpp +++ b/src/osgUtil/TrackballManipulator.cpp @@ -215,9 +215,9 @@ bool TrackballManipulator::calcMovement() trackball(axis,angle,px1,py1,px0,py0); osg::Matrix mat; - mat.makeTrans(-center.x(),-center.y(),-center.z()); + mat.makeTranslate(-center.x(),-center.y(),-center.z()); mat *= Matrix::rotate(angle,axis.x(),axis.y(),axis.z()); - mat *= Matrix::trans(center.x(),center.y(),center.z()); + mat *= Matrix::translate(center.x(),center.y(),center.z()); _camera->transformLookAt(mat); @@ -237,7 +237,7 @@ bool TrackballManipulator::calcMovement() osg::Vec3 dv = uv*(dy*scale)-sv*(dx*scale); osg::Matrix mat; - mat.makeTrans(dv.x(),dv.y(),dv.z()); + mat.makeTranslate(dv.x(),dv.y(),dv.z()); _camera->transformLookAt(mat); @@ -257,9 +257,9 @@ bool TrackballManipulator::calcMovement() osg::Vec3 center = _camera->getCenterPoint(); osg::Matrix mat; - mat.makeTrans(-center.x(),-center.y(),-center.z()); + mat.makeTranslate(-center.x(),-center.y(),-center.z()); mat *= Matrix::scale(scale,scale,scale); - mat *= Matrix::trans(center.x(),center.y(),center.z()); + mat *= Matrix::translate(center.x(),center.y(),center.z()); _camera->transformLookAt(mat); @@ -273,7 +273,7 @@ bool TrackballManipulator::calcMovement() osg::Vec3 dv = _camera->getLookVector()*(dy*scale); osg::Matrix mat; - mat.makeTrans(dv.x(),dv.y(),dv.z()); + mat.makeTranslate(dv.x(),dv.y(),dv.z()); _camera->transformLookAt(mat); diff --git a/src/osgUtil/TransformCallback.cpp b/src/osgUtil/TransformCallback.cpp index 78d603d91..ab51aa0a3 100644 --- a/src/osgUtil/TransformCallback.cpp +++ b/src/osgUtil/TransformCallback.cpp @@ -32,9 +32,9 @@ void TransformCallback::operator() (osg::Node* node, osg::NodeVisitor* nv) double newTime = fs->getReferenceTime(); float delta_angle = _angular_velocity*(newTime-_previousTime); - osg::Matrix mat = osg::Matrix::trans(-_pivot)* + osg::Matrix mat = osg::Matrix::translate(-_pivot)* osg::Matrix::rotate(delta_angle,_axis)* - osg::Matrix::trans(_pivot); + osg::Matrix::translate(_pivot); // update the specified transform