diff --git a/include/osg/Math b/include/osg/Math index 4f6c1ec82..b9c0307d8 100644 --- a/include/osg/Math +++ b/include/osg/Math @@ -16,6 +16,8 @@ #include +#include + //certain math functions were not defined until 10.2 //so this code checks the version so it can add in workarounds for older versions. #ifdef __APPLE__ @@ -226,6 +228,12 @@ inline float computeVolume(const T& f1,const T& f2,const T& f3, computeVolume(b1,b3,f2,f3); } +/** Convert a ascii number to a double, ignoring locale settings.*/ +extern OSG_EXPORT double asciiToDouble(const char* str); + +/** Convert a ascii number to a float, ignoring locale settings.*/ +inline float asciiToFloat(const char* str) { return static_cast(asciiToDouble(str)); } + } #endif // __OSG_MATH diff --git a/include/osgDB/Field b/include/osgDB/Field index ea8f96158..51878477f 100644 --- a/include/osgDB/Field +++ b/include/osgDB/Field @@ -21,7 +21,6 @@ namespace osgDB { - class OSGDB_EXPORT Field { public: diff --git a/src/osg/CMakeLists.txt b/src/osg/CMakeLists.txt index 54e33276c..19c682c5c 100644 --- a/src/osg/CMakeLists.txt +++ b/src/osg/CMakeLists.txt @@ -216,24 +216,26 @@ ADD_LIBRARY(${LIB_NAME} CoordinateSystemNode.cpp CopyOp.cpp CullFace.cpp + CullingSet.cpp CullSettings.cpp CullStack.cpp - CullingSet.cpp DeleteHandler.cpp Depth.cpp DisplaySettings.cpp - DrawPixels.cpp Drawable.cpp + DrawPixels.cpp + dxtctool.cpp + dxtctool.h Fog.cpp FragmentProgram.cpp FrameBufferObject.cpp FrameStamp.cpp FrontFace.cpp + Geode.cpp + Geometry.cpp GL2Extensions.cpp GLExtensions.cpp GLObjects.cpp - Geode.cpp - Geometry.cpp GraphicsContext.cpp GraphicsThread.cpp Group.cpp @@ -242,24 +244,25 @@ ADD_LIBRARY(${LIB_NAME} ImageSequence.cpp ImageStream.cpp KdTree.cpp - LOD.cpp Light.cpp LightModel.cpp LightSource.cpp LineSegment.cpp LineStipple.cpp LineWidth.cpp + LOD.cpp LogicOp.cpp Material.cpp + Math.cpp + Matrixd.cpp MatrixDecomposition.cpp - MatrixTransform.cpp + Matrixf.cpp # We don't build this one # Matrix_implementation.cpp - Matrixd.cpp - Matrixf.cpp + MatrixTransform.cpp Multisample.cpp - Node.cpp NodeCallback.cpp + Node.cpp NodeTrackerCallback.cpp NodeVisitor.cpp Notify.cpp @@ -287,36 +290,34 @@ ADD_LIBRARY(${LIB_NAME} ShadowVolumeOccluder.cpp Shape.cpp ShapeDrawable.cpp - State.cpp StateAttribute.cpp + State.cpp StateSet.cpp Stats.cpp Stencil.cpp StencilTwoSided.cpp Switch.cpp - TexEnv.cpp TexEnvCombine.cpp + TexEnv.cpp TexEnvFilter.cpp TexGen.cpp TexGenNode.cpp TexMat.cpp - Texture.cpp Texture1D.cpp - Texture2D.cpp Texture2DArray.cpp + Texture2D.cpp Texture3D.cpp + Texture.cpp TextureCubeMap.cpp TextureRectangle.cpp - TransferFunction.cpp Timer.cpp + TransferFunction.cpp Transform.cpp Uniform.cpp Version.cpp VertexProgram.cpp View.cpp Viewport.cpp - dxtctool.cpp - dxtctool.h ) LINK_INTERNAL(${LIB_NAME} diff --git a/src/osg/Math.cpp b/src/osg/Math.cpp new file mode 100644 index 000000000..6c755a6c2 --- /dev/null +++ b/src/osg/Math.cpp @@ -0,0 +1,114 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#include + +#include + +double osg::asciiToDouble(const char* str) +{ + const char* ptr = str; + + // check if could be a hex number. + if (strncmp(ptr,"0x",2)==0) + { + + double value = 0.0; + + // skip over leading 0x, and then go through rest of string + // checking to make sure all values are 0...9 or a..f. + ptr+=2; + while ( + *ptr!=0 && + ((*ptr>='0' && *ptr<='9') || + (*ptr>='a' && *ptr<='f') || + (*ptr>='A' && *ptr<='F')) + ) + { + if (*ptr>='0' && *ptr<='9') value = value*16.0 + double(*ptr-'0'); + else if (*ptr>='a' && *ptr<='f') value = value*16.0 + double(*ptr-'a'+10); + else if (*ptr>='A' && *ptr<='F') value = value*16.0 + double(*ptr-'A'+10); + ++ptr; + } + + // osg::notify(osg::NOTICE)<<"Read "<='0' && *ptr<='9') || - (*ptr>='a' && *ptr<='f') || - (*ptr>='A' && *ptr<='F')) - ) - { - if (*ptr>='0' && *ptr<='9') value = value*16.0 + double(*ptr-'0'); - else if (*ptr>='a' && *ptr<='f') value = value*16.0 + double(*ptr-'a'+10); - else if (*ptr>='A' && *ptr<='F') value = value*16.0 + double(*ptr-'A'+10); - ++ptr; - } - - // osg::notify(osg::NOTICE)<<"Read "<