From Mathias Froehlich, changes from atof to use osg::asciiToFloat() to avoid locale issues with atof
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <osg/ArgumentParser>
|
||||
#include <osg/ApplicationUsage>
|
||||
#include <osg/Math>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <set>
|
||||
@@ -163,8 +164,8 @@ bool ArgumentParser::Parameter::assign(const char* str)
|
||||
*_value._bool = (strcmp(str,"True")==0 || strcmp(str,"true")==0 || strcmp(str,"TRUE")==0);
|
||||
break;
|
||||
}
|
||||
case Parameter::FLOAT_PARAMETER: *_value._float = atof(str); break;
|
||||
case Parameter::DOUBLE_PARAMETER: *_value._double = atof(str); break;
|
||||
case Parameter::FLOAT_PARAMETER: *_value._float = osg::asciiToFloat(str); break;
|
||||
case Parameter::DOUBLE_PARAMETER: *_value._double = osg::asciiToDouble(str); break;
|
||||
case Parameter::INT_PARAMETER: *_value._int = atoi(str); break;
|
||||
case Parameter::UNSIGNED_INT_PARAMETER: *_value._uint = atoi(str); break;
|
||||
case Parameter::STRING_PARAMETER: *_value._string = str; break;
|
||||
|
||||
@@ -111,7 +111,7 @@ void CullSettings::readEnvironmentalVariables()
|
||||
|
||||
if ((ptr = getenv("OSG_NEAR_FAR_RATIO")) != 0)
|
||||
{
|
||||
_nearFarRatio = atof(ptr);
|
||||
_nearFarRatio = osg::asciiToDouble(ptr);
|
||||
|
||||
osg::notify(osg::INFO)<<"Set near/far ratio to "<<_nearFarRatio<<std::endl;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <osg/DisplaySettings>
|
||||
#include <osg/ArgumentParser>
|
||||
#include <osg/ApplicationUsage>
|
||||
#include <osg/Math>
|
||||
#include <osg/Notify>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
@@ -267,22 +268,22 @@ void DisplaySettings::readEnvironmentalVariables()
|
||||
|
||||
if( (ptr = getenv("OSG_EYE_SEPARATION")) != 0)
|
||||
{
|
||||
_eyeSeparation = atof(ptr);
|
||||
_eyeSeparation = osg::asciiToFloat(ptr);
|
||||
}
|
||||
|
||||
if( (ptr = getenv("OSG_SCREEN_WIDTH")) != 0)
|
||||
{
|
||||
_screenWidth = atof(ptr);
|
||||
_screenWidth = osg::asciiToFloat(ptr);
|
||||
}
|
||||
|
||||
if( (ptr = getenv("OSG_SCREEN_HEIGHT")) != 0)
|
||||
{
|
||||
_screenHeight = atof(ptr);
|
||||
_screenHeight = osg::asciiToFloat(ptr);
|
||||
}
|
||||
|
||||
if( (ptr = getenv("OSG_SCREEN_DISTANCE")) != 0)
|
||||
{
|
||||
_screenDistance = atof(ptr);
|
||||
_screenDistance = osg::asciiToFloat(ptr);
|
||||
}
|
||||
|
||||
if( (ptr = getenv("OSG_SPLIT_STEREO_HORIZONTAL_EYE_MAPPING")) != 0)
|
||||
|
||||
@@ -885,7 +885,7 @@ DatabasePager::DatabasePager()
|
||||
_expiryDelay = 10.0;
|
||||
if( (ptr = getenv("OSG_EXPIRY_DELAY")) != 0)
|
||||
{
|
||||
_expiryDelay = atof(ptr);
|
||||
_expiryDelay = osg::asciiToDouble(ptr);
|
||||
osg::notify(osg::NOTICE)<<"Expiry delay = "<<_expiryDelay<<std::endl;
|
||||
}
|
||||
|
||||
@@ -904,7 +904,7 @@ DatabasePager::DatabasePager()
|
||||
}
|
||||
else
|
||||
{
|
||||
setReleaseDelay(atof(ptr));
|
||||
setReleaseDelay(osg::asciiToDouble(ptr));
|
||||
}
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Release delay = "<<_releaseDelay<<std::endl;
|
||||
@@ -943,7 +943,7 @@ DatabasePager::DatabasePager()
|
||||
_maximumNumOfObjectsToCompilePerFrame = 4;
|
||||
if( (ptr = getenv("OSG_MINIMUM_COMPILE_TIME_PER_FRAME")) != 0)
|
||||
{
|
||||
_minimumTimeAvailableForGLCompileAndDeletePerFrame = atof(ptr);
|
||||
_minimumTimeAvailableForGLCompileAndDeletePerFrame = osg::asciiToDouble(ptr);
|
||||
}
|
||||
|
||||
if( (ptr = getenv("OSG_MAXIMUM_OBJECTS_TO_COMPILE_PER_FRAME")) != 0)
|
||||
|
||||
@@ -36,7 +36,7 @@ static double getHeightOfDriver()
|
||||
double height = 1.5;
|
||||
if (getenv("OSG_DRIVE_MANIPULATOR_HEIGHT"))
|
||||
{
|
||||
height = atof(getenv("OSG_DRIVE_MANIPULATOR_HEIGHT"));
|
||||
height = osg::asciiToDouble(getenv("OSG_DRIVE_MANIPULATOR_HEIGHT"));
|
||||
}
|
||||
osg::notify(osg::INFO)<<"DriveManipulator::_height set to =="<<height<<std::endl;
|
||||
return height;
|
||||
|
||||
@@ -181,7 +181,7 @@ void VBSPEntity::processItem()
|
||||
|
||||
Vec3f VBSPEntity::getVector(std::string str)
|
||||
{
|
||||
double x, y, z;
|
||||
float x, y, z;
|
||||
|
||||
// Look for the first non-whitespace
|
||||
std::string::size_type start = str.find_first_not_of(" \t\r\n", 0);
|
||||
@@ -190,7 +190,7 @@ Vec3f VBSPEntity::getVector(std::string str)
|
||||
std::string::size_type end = str.find_first_of(" \t\r\n", start);
|
||||
|
||||
if ((end > start) && (start != std::string::npos))
|
||||
x = atof(str.substr(start, end-start).c_str());
|
||||
x = osg::asciiToFloat(str.substr(start, end-start).c_str());
|
||||
else
|
||||
return Vec3f();
|
||||
|
||||
@@ -201,7 +201,7 @@ Vec3f VBSPEntity::getVector(std::string str)
|
||||
end = str.find_first_of(" \t\r\n", start);
|
||||
|
||||
if ((end > start) && (start != std::string::npos))
|
||||
y = atof(str.substr(start, end-start).c_str());
|
||||
y = osg::asciiToFloat(str.substr(start, end-start).c_str());
|
||||
else
|
||||
return Vec3f();
|
||||
|
||||
@@ -214,7 +214,7 @@ Vec3f VBSPEntity::getVector(std::string str)
|
||||
end = str.length();
|
||||
|
||||
if ((end > start) && (start != std::string::npos))
|
||||
z = atof(str.substr(start, end-start).c_str());
|
||||
z = osg::asciiToFloat(str.substr(start, end-start).c_str());
|
||||
else
|
||||
return Vec3f();
|
||||
|
||||
|
||||
@@ -1932,21 +1932,21 @@ yyreduce:
|
||||
case 114:
|
||||
|
||||
{
|
||||
yyval.real = atof(flexer->YYText());
|
||||
yyval.real = osg::asciiToFloat(flexer->YYText());
|
||||
;}
|
||||
break;
|
||||
|
||||
case 115:
|
||||
|
||||
{
|
||||
yyval.real = atof(flexer->YYText());
|
||||
yyval.real = osg::asciiToFloat(flexer->YYText());
|
||||
;}
|
||||
break;
|
||||
|
||||
case 116:
|
||||
|
||||
{
|
||||
yyval.real = atof(flexer->YYText());
|
||||
yyval.real = osg::asciiToFloat(flexer->YYText());
|
||||
;}
|
||||
break;
|
||||
|
||||
|
||||
@@ -858,33 +858,33 @@ class ReaderWriterDW : public osgDB::ReaderWriter
|
||||
} else if (strncmp(buff, "CurrPhase:",10)==0) {
|
||||
} else if (strncmp(buff, "numPhases:",10)==0) {
|
||||
} else if (strncmp(buff, "Opacity:",8)==0) {
|
||||
float opacity=atof(buff+8);
|
||||
float opacity=osg::asciiToFloat(buff+8);
|
||||
matpalet[nmat].setopacity(opacity);
|
||||
} else if (strncmp(buff, "FallOff:",8)==0) {
|
||||
float fo=atof(buff+8);
|
||||
float fo=osg::asciiToFloat(buff+8);
|
||||
matpalet[nmat].setFallOff(fo);
|
||||
} else if (strncmp(buff, "InnerHalfAngle:",15)==0) {
|
||||
float ha=atof(buff+15);
|
||||
float ha=osg::asciiToFloat(buff+15);
|
||||
matpalet[nmat].setHalfAngleIn(ha);
|
||||
} else if (strncmp(buff, "OuterHalfAngle:",15)==0) {
|
||||
float ha=atof(buff+15);
|
||||
float ha=osg::asciiToFloat(buff+15);
|
||||
matpalet[nmat].setHalfAngleOut(ha);
|
||||
} else if (strncmp(buff, "Brightness:",11)==0) {
|
||||
float br=atof(buff+11);
|
||||
float br=osg::asciiToFloat(buff+11);
|
||||
matpalet[nmat].setBright(br);
|
||||
} else if (strncmp(buff, "Attentuation:",13)==0) { // oops - they can't spell
|
||||
matpalet[nmat].setAtten(buff+13);
|
||||
} else if (strncmp(buff, "MaterialType:",13)==0) {
|
||||
matpalet[nmat].setType(buff+14);
|
||||
} else if (strncmp(buff, "SpecularReflectivity:",21)==0) {
|
||||
float spec=atof(buff+21);
|
||||
float spec=osg::asciiToFloat(buff+21);
|
||||
matpalet[nmat].setspecular(spec);
|
||||
} else if (strncmp(buff, "SmoothnessExponent:",19)==0) {
|
||||
float spec=atof(buff+19);
|
||||
float spec=osg::asciiToFloat(buff+19);
|
||||
matpalet[nmat].setspecexp(spec*128.0f/100.0f); // convert to 0-128 range from percent
|
||||
} else if (strncmp(buff, "TextureWidthAndHeight:",22)==0) {
|
||||
char *ct=strchr(buff+22,',');
|
||||
float repx=atof(buff+23), repy=atof(ct+1);
|
||||
float repx=osg::asciiToFloat(buff+23), repy=osg::asciiToFloat(ct+1);
|
||||
matpalet[nmat].settxrep(repx, repy);
|
||||
} else if (strncmp(buff, "PictureFile:",12)==0) {
|
||||
char *end=strchr(buff,'\n'); // end of line
|
||||
|
||||
@@ -172,7 +172,7 @@ DataOutputStream::DataOutputStream(std::ostream * ostream, const osgDB::ReaderWr
|
||||
if (numOfCharInNumber>0)
|
||||
{
|
||||
std::string numberString = optionsString.substr(endOfToken+1, numOfCharInNumber);
|
||||
_maximumErrorToSizeRatio = atof(numberString.c_str());
|
||||
_maximumErrorToSizeRatio = osg::asciiToDouble(numberString.c_str());
|
||||
|
||||
osg::notify(osg::DEBUG_INFO)<<"TerrainMaximumErrorToSizeRatio = "<<_maximumErrorToSizeRatio<<std::endl;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class NormalsReader: public osgDB::ReaderWriter
|
||||
std::string value = opt.substr(index+1);
|
||||
if( key == "scale" || key == "SCALE" )
|
||||
{
|
||||
scale = atof( value.c_str() );
|
||||
scale = osg::asciiToFloat( value.c_str() );
|
||||
}
|
||||
else if( key == "mode" || key == "MODE" )
|
||||
{
|
||||
|
||||
@@ -539,14 +539,14 @@ bool ReaderWriterTXP::extractChildrenLocations(const std::string& name, int pare
|
||||
token = strtok(0, "_");
|
||||
if(!token)
|
||||
break;
|
||||
locs[idx].zmin = (float)atof(token);
|
||||
locs[idx].zmin = osg::asciiToFloat(token);
|
||||
nbTokenRead++;
|
||||
|
||||
// ZMAX
|
||||
token = strtok(0, "_");
|
||||
if(!token)
|
||||
break;
|
||||
locs[idx].zmax= (float)atof(token);
|
||||
locs[idx].zmax = osg::asciiToFloat(token);
|
||||
nbTokenRead++;
|
||||
|
||||
locs[idx].lod = parentLod+1;
|
||||
|
||||
@@ -102,7 +102,7 @@ TXPParser::TXPParser():
|
||||
|
||||
if (getenv("OSG_TXP_DEFAULT_MAX_ANISOTROPY"))
|
||||
{
|
||||
_defaultMaxAnisotropy = atof(getenv("OSG_TXP_DEFAULT_MAX_ANISOTROPY"));
|
||||
_defaultMaxAnisotropy = osg::asciiToFloat(getenv("OSG_TXP_DEFAULT_MAX_ANISOTROPY"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ RecordCameraPathHandler::RecordCameraPathHandler(const std::string& filename, fl
|
||||
const char* str = getenv("OSG_RECORD_CAMERA_PATH_FPS");
|
||||
if (str)
|
||||
{
|
||||
_interval = 1.0f / atof(str);
|
||||
_interval = 1.0f / osg::asciiToDouble(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user