diff --git a/src/osg/Matrix_implementation.cpp b/src/osg/Matrix_implementation.cpp index 3cc9facf1..4534e0da8 100644 --- a/src/osg/Matrix_implementation.cpp +++ b/src/osg/Matrix_implementation.cpp @@ -138,9 +138,16 @@ Quat Matrix_implementation::getRotate() const QY = 0.5 * sqrt( osg::maximum( 0.0, 1.0 - _mat[0][0] + _mat[1][1] - _mat[2][2] ) ); QZ = 0.5 * sqrt( osg::maximum( 0.0, 1.0 - _mat[0][0] - _mat[1][1] + _mat[2][2] ) ); +#if 0 + // Robert Osfield, June 7th 2007, arggg this new implementation produces many many errors, so have to revert to sign(..) orignal below. QX = QX * osg::signOrZero( _mat[1][2] - _mat[2][1]) ; QY = QY * osg::signOrZero( _mat[2][0] - _mat[0][2]) ; QZ = QZ * osg::signOrZero( _mat[0][1] - _mat[1][0]) ; +#else + QX = QX * osg::sign( _mat[1][2] - _mat[2][1]) ; + QY = QY * osg::sign( _mat[2][0] - _mat[0][2]) ; + QZ = QZ * osg::sign( _mat[0][1] - _mat[1][0]) ; +#endif return q; } @@ -149,8 +156,10 @@ Quat Matrix_implementation::getRotate() const #if 1 // David Spillings implementation Mk 1 - void Matrix_implementation::get( Quat& q ) const + Quat Matrix_implementation::getRotate() const { + Quat q; + value_type s; value_type tq[4]; int i, j; @@ -201,12 +210,16 @@ Quat Matrix_implementation::getRotate() const QX *= s; QY *= s; QZ *= s; + + return q; } #else // Original implementation - void Matrix_implementation::get( Quat& q ) const + Quat Matrix_implementation::getRotate() const { + Quat q; + // Source: Gamasutra, Rotating Objects Using Quaternions // //http://www.gamasutra.com/features/programming/19980703/quaternions_01.htm @@ -256,6 +269,8 @@ Quat Matrix_implementation::getRotate() const QZ = tq[2]; QW = tq[3]; } + + return q; } #endif #endif