Revert the signOrZero cade path in the getRotate() to fix bugs.

This commit is contained in:
Robert Osfield
2007-06-07 11:06:40 +00:00
parent 0f132ab21e
commit 9064895b91

View File

@@ -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