Skip to content
Permalink
Browse files

Add OSG_USE_FLOAT_QUAT option for single precision quaternions, ON by…

… default

Serializer fixed.
  • Loading branch information...
scrawl scrawl
scrawl authored and scrawl committed Nov 20, 2015
1 parent 31f5720 commit 55b2dd8004bd8754a4b61acf150e4630e19d0fc4
@@ -376,6 +376,9 @@ OPTION(OSG_NOTIFY_DISABLED "Set to ON to build OpenSceneGraph with the notify()
OPTION(OSG_USE_FLOAT_MATRIX "Set to ON to build OpenSceneGraph with float Matrix instead of double." ON)
MARK_AS_ADVANCED(OSG_USE_FLOAT_MATRIX)

OPTION(OSG_USE_FLOAT_QUAT "Set to ON to build OpenSceneGraph with float Quat (quaternion) instead of double." ON)
MARK_AS_ADVANCED(OSG_USE_FLOAT_QUAT)

OPTION(OSG_USE_FLOAT_PLANE "Set to ON to build OpenSceneGraph with float Plane instead of double." ON)
MARK_AS_ADVANCED(OSG_USE_FLOAT_PLANE)

@@ -31,7 +31,11 @@ class OSG_EXPORT Quat

public:

#ifdef OSG_USE_FLOAT_QUAT
typedef float value_type;
#else
typedef double value_type;
#endif

value_type _v[4]; // a four-vector

@@ -24,6 +24,7 @@
#define OSG_CONFIG 1

#cmakedefine OSG_NOTIFY_DISABLED
#cmakedefine OSG_USE_FLOAT_QUAT
#cmakedefine OSG_USE_FLOAT_MATRIX
#cmakedefine OSG_USE_FLOAT_PLANE
#cmakedefine OSG_USE_FLOAT_BOUNDINGSPHERE
@@ -185,9 +185,13 @@ InputStream& InputStream::operator>>( osg::Vec3d& v )
InputStream& InputStream::operator>>( osg::Vec4d& v )
{ *this >> v.x() >> v.y() >> v.z() >> v.w(); return *this; }


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 )
{
@@ -155,7 +155,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; }
@@ -402,7 +402,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 @@ class ReaderWriterP3DXML : public osgDB::ReaderWriter
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;

0 comments on commit 55b2dd8

Please sign in to comment.
You can’t perform that action at this time.