From f03218215dee0608d534200783f6d471239e335f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 1 Oct 2006 19:00:39 +0000 Subject: [PATCH] From Colin McDonald, "I have corrected a byte swapping problem in the new OpenFlight plugin. It was only reading floats & doubles correctly on little endian systems, which require byte swapping, and not on big endian systems which don't require any swapping." --- src/osgPlugins/OpenFlight/DataInputStream.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/osgPlugins/OpenFlight/DataInputStream.cpp b/src/osgPlugins/OpenFlight/DataInputStream.cpp index 9e33921bc..c0e2a71fc 100644 --- a/src/osgPlugins/OpenFlight/DataInputStream.cpp +++ b/src/osgPlugins/OpenFlight/DataInputStream.cpp @@ -77,13 +77,9 @@ uint32 DataInputStream::readUInt32(uint32 def) float32 DataInputStream::readFloat32(float32 def) { float32 d=def; - char buf[sizeof(float32)]; - vread(buf, sizeof(float32)); + vread((char*)&d, sizeof(float32)); if (_byteswap && good()) - { - osg::swapBytes4(buf); - memcpy(&d,buf,sizeof(float32)); - } + osg::swapBytes4((char*)&d); return d; } @@ -91,13 +87,9 @@ float32 DataInputStream::readFloat32(float32 def) float64 DataInputStream::readFloat64(float64 def) { float64 d=def; - char buf[sizeof(float64)]; - vread(buf, sizeof(float64)); + vread((char*)&d, sizeof(float64)); if (_byteswap && good()) - { - osg::swapBytes8(buf); - memcpy(&d,buf,sizeof(float64)); - } + osg::swapBytes8((char*)&d); return d; }