Add OSG_USE_FLOAT_QUAT build option to use single precision quaternions
This commit is contained in:
committed by
Robert Osfield
parent
c548289ac1
commit
12b298130a
@@ -28,6 +28,7 @@
|
||||
#cmakedefine OSG_USE_FLOAT_PLANE
|
||||
#cmakedefine OSG_USE_FLOAT_BOUNDINGSPHERE
|
||||
#cmakedefine OSG_USE_FLOAT_BOUNDINGBOX
|
||||
#cmakedefine OSG_USE_FLOAT_QUAT
|
||||
#cmakedefine OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION
|
||||
#cmakedefine OSG_USE_REF_PTR_SAFE_DEREFERENCE
|
||||
#cmakedefine OSG_USE_UTF8_FILENAME
|
||||
|
||||
@@ -187,7 +187,10 @@ InputStream& InputStream::operator>>( osg::Vec4d& v )
|
||||
|
||||
|
||||
InputStream& InputStream::operator>>( osg::Quat& q )
|
||||
{ *this >> q.x() >> q.y() >> q.z() >> q.w(); return *this; }
|
||||
{
|
||||
double x, y, z, w; *this >> x >> y >> z >> w;
|
||||
q.set( x, y, z, w ); return *this;
|
||||
}
|
||||
|
||||
InputStream& InputStream::operator>>( osg::Plane& p )
|
||||
{
|
||||
|
||||
@@ -172,7 +172,7 @@ OutputStream& OutputStream::operator<<( const osg::Vec4ui& v )
|
||||
|
||||
|
||||
OutputStream& OutputStream::operator<<( const osg::Quat& q )
|
||||
{ *this << q.x() << q.y() << q.z() << q.w(); return *this; }
|
||||
{ *this << (double)q.x() << (double)q.y() << (double)q.z() << (double)q.w(); return *this; }
|
||||
|
||||
OutputStream& OutputStream::operator<<( const osg::Plane& p )
|
||||
{ *this << (double)p[0] << (double)p[1] << (double)p[2] << (double)p[3]; return *this; }
|
||||
|
||||
@@ -405,7 +405,7 @@ osg::Quat SpherePlaneProjector::getRotation(const osg::Vec3d& p1, bool p1OnSpher
|
||||
osg::Quat rotation;
|
||||
rotation.makeRotate(p1 - getSphere()->getCenter(), p2 - getSphere()->getCenter());
|
||||
|
||||
osg::Vec3d axis; double angle;
|
||||
osg::Vec3d axis; osg::Quat::value_type angle;
|
||||
rotation.getRotate(angle, axis);
|
||||
|
||||
osg::Vec3d realAxis;
|
||||
|
||||
@@ -217,7 +217,11 @@ public:
|
||||
qlhs.makeRotate(osg::DegreesToRadians(lhs[0]),lhs[1],lhs[2],lhs[3]);
|
||||
qrhs.makeRotate(osg::DegreesToRadians(rhs[0]),rhs[1],rhs[2],rhs[3]);
|
||||
osg::Quat quat = qlhs*qrhs;
|
||||
#ifdef OSG_USE_FLOAT_QUAT
|
||||
osg::Vec4f result;
|
||||
#else
|
||||
osg::Vec4d result;
|
||||
#endif
|
||||
quat.getRotate ( result[0], result[1], result[2], result[3]);
|
||||
result[0] = osg::RadiansToDegrees(result[0]);
|
||||
return result;
|
||||
|
||||
@@ -562,7 +562,7 @@ void ToVRML::apply(osg::MatrixTransform& node) {
|
||||
osg::Vec3 scale = mat.getScale();
|
||||
osg::Quat quat;
|
||||
mat.get(quat);
|
||||
double angle;
|
||||
osg::Quat::value_type angle;
|
||||
osg::Vec3 axe;
|
||||
quat.getRotate(angle, axe);
|
||||
|
||||
@@ -597,7 +597,7 @@ void ToVRML::apply(osg::PositionAttitudeTransform& node) {
|
||||
osg::Vec3 trans = node.getPosition();
|
||||
osg::Vec3 scale = node.getScale();
|
||||
osg::Quat quat = node.getAttitude();
|
||||
double angle;
|
||||
osg::Quat::value_type angle;
|
||||
osg::Vec3 axe;
|
||||
quat.getRotate(angle, axe);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user