diff --git a/code/ACLoader.cpp b/code/ACLoader.cpp index 0e8cc87cb..5554a8ebc 100644 --- a/code/ACLoader.cpp +++ b/code/ACLoader.cpp @@ -100,7 +100,7 @@ using namespace Assimp; for (unsigned int i = 0; i < num;++i) \ { \ AI_AC_SKIP_TO_NEXT_TOKEN(); \ - buffer = fast_atof_move(buffer,((float*)out)[i]); \ + buffer = fast_atoreal_move(buffer,((float*)out)[i]); \ } diff --git a/code/ASEParser.cpp b/code/ASEParser.cpp index ae1e9fbfe..3e959319a 100644 --- a/code/ASEParser.cpp +++ b/code/ASEParser.cpp @@ -1614,7 +1614,7 @@ void Parser::ParseLV4MeshBonesVertices(unsigned int iNumVertices,ASE::Mesh& mesh // then parse the vertex weight if (!SkipSpaces(&filePtr))break; - filePtr = fast_atof_move(filePtr,pairOut.second); + filePtr = fast_atoreal_move(filePtr,pairOut.second); // -1 marks unused entries if (-1 != pairOut.first) @@ -2131,7 +2131,7 @@ void Parser::ParseLV4MeshFloat(float& fOut) return; } // parse the first float - filePtr = fast_atof_move(filePtr,fOut); + filePtr = fast_atoreal_move(filePtr,fOut); } // ------------------------------------------------------------------------------------------------ void Parser::ParseLV4MeshLong(unsigned int& iOut) diff --git a/code/AssimpCExport.cpp b/code/AssimpCExport.cpp index 90e327668..8a9867d42 100644 --- a/code/AssimpCExport.cpp +++ b/code/AssimpCExport.cpp @@ -71,7 +71,7 @@ ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut) return; } - SceneCombiner::CopyScene(pOut,pIn,false); + SceneCombiner::CopyScene(pOut,pIn,true); } // ------------------------------------------------------------------------------------------------ diff --git a/code/BVHLoader.cpp b/code/BVHLoader.cpp index 0330113f2..b474f6f54 100644 --- a/code/BVHLoader.cpp +++ b/code/BVHLoader.cpp @@ -374,7 +374,7 @@ float BVHLoader::GetNextTokenAsFloat() // check if the float is valid by testing if the atof() function consumed every char of the token const char* ctoken = token.c_str(); float result = 0.0f; - ctoken = fast_atof_move( ctoken, result); + ctoken = fast_atoreal_move( ctoken, result); if( ctoken != token.c_str() + token.length()) ThrowException( boost::str( boost::format( "Expected a floating point number, but found \"%s\".") % token)); diff --git a/code/CSMLoader.cpp b/code/CSMLoader.cpp index 40447f05c..d590caf22 100644 --- a/code/CSMLoader.cpp +++ b/code/CSMLoader.cpp @@ -134,7 +134,7 @@ void CSMImporter::InternReadFile( const std::string& pFile, else if (TokenMatchI(buffer,"rate",4)) { SkipSpaces(&buffer); float d; - buffer = fast_atof_move(buffer,d); + buffer = fast_atoreal_move(buffer,d); anim->mTicksPerSecond = d; } else if (TokenMatchI(buffer,"order",5)) { @@ -214,15 +214,15 @@ void CSMImporter::InternReadFile( const std::string& pFile, else { aiVectorKey* sub = s->mPositionKeys + s->mNumPositionKeys; sub->mTime = (double)frame; - buffer = fast_atof_move(buffer, (float&)sub->mValue.x); + buffer = fast_atoreal_move(buffer, (float&)sub->mValue.x); if(!SkipSpacesAndLineEnd(&buffer)) throw DeadlyImportError("CSM: Unexpected EOF occured reading sample y coord"); - buffer = fast_atof_move(buffer, (float&)sub->mValue.y); + buffer = fast_atoreal_move(buffer, (float&)sub->mValue.y); if(!SkipSpacesAndLineEnd(&buffer)) throw DeadlyImportError("CSM: Unexpected EOF occured reading sample z coord"); - buffer = fast_atof_move(buffer, (float&)sub->mValue.z); + buffer = fast_atoreal_move(buffer, (float&)sub->mValue.z); ++s->mNumPositionKeys; } diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index ae862a423..dbec9620b 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -500,7 +500,7 @@ void ColladaParser::ReadController( Collada::Controller& pController) for( unsigned int a = 0; a < 16; a++) { // read a number - content = fast_atof_move( content, pController.mBindShapeMatrix[a]); + content = fast_atoreal_move( content, pController.mBindShapeMatrix[a]); // skip whitespace after it SkipSpacesAndLineEnd( &content); } @@ -980,13 +980,13 @@ void ColladaParser::ReadLight( Collada::Light& pLight) // text content contains 3 floats const char* content = GetTextContent(); - content = fast_atof_move( content, (float&)pLight.mColor.r); + content = fast_atoreal_move( content, (float&)pLight.mColor.r); SkipSpacesAndLineEnd( &content); - content = fast_atof_move( content, (float&)pLight.mColor.g); + content = fast_atoreal_move( content, (float&)pLight.mColor.g); SkipSpacesAndLineEnd( &content); - content = fast_atof_move( content, (float&)pLight.mColor.b); + content = fast_atoreal_move( content, (float&)pLight.mColor.b); SkipSpacesAndLineEnd( &content); TestClosing( "color"); @@ -1342,16 +1342,16 @@ void ColladaParser::ReadEffectColor( aiColor4D& pColor, Sampler& pSampler) // text content contains 4 floats const char* content = GetTextContent(); - content = fast_atof_move( content, (float&)pColor.r); + content = fast_atoreal_move( content, (float&)pColor.r); SkipSpacesAndLineEnd( &content); - content = fast_atof_move( content, (float&)pColor.g); + content = fast_atoreal_move( content, (float&)pColor.g); SkipSpacesAndLineEnd( &content); - content = fast_atof_move( content, (float&)pColor.b); + content = fast_atoreal_move( content, (float&)pColor.b); SkipSpacesAndLineEnd( &content); - content = fast_atof_move( content, (float&)pColor.a); + content = fast_atoreal_move( content, (float&)pColor.a); SkipSpacesAndLineEnd( &content); TestClosing( "color"); } @@ -1404,7 +1404,7 @@ void ColladaParser::ReadEffectFloat( float& pFloat) { // text content contains a single floats const char* content = GetTextContent(); - content = fast_atof_move( content, pFloat); + content = fast_atoreal_move( content, pFloat); SkipSpacesAndLineEnd( &content); TestClosing( "float"); @@ -1681,7 +1681,7 @@ void ColladaParser::ReadDataArray() float value; // read a number - content = fast_atof_move( content, value); + content = fast_atoreal_move( content, value); data.mValues.push_back( value); // skip whitespace after it SkipSpacesAndLineEnd( &content); @@ -2445,7 +2445,7 @@ void ColladaParser::ReadNodeTransformation( Node* pNode, TransformType pType) for( unsigned int a = 0; a < sNumParameters[pType]; a++) { // read a number - content = fast_atof_move( content, tf.f[a]); + content = fast_atoreal_move( content, tf.f[a]); // skip whitespace after it SkipSpacesAndLineEnd( &content); } diff --git a/code/IFCGeometry.cpp b/code/IFCGeometry.cpp index 18ddf8f5b..7fa56f813 100644 --- a/code/IFCGeometry.cpp +++ b/code/IFCGeometry.cpp @@ -1214,7 +1214,7 @@ bool TryAddOpenings_Quadrulate(const std::vector& openings,const st // see if this BB intersects any other, in which case we could not use the Quadrify() // algorithm and would revert to Poly2Tri only. - /*BOOST_FOREACH(const BoundingBox& ibb, bbs) { + BOOST_FOREACH(const BoundingBox& ibb, bbs) { if (ibb.first.x < bb.second.x && ibb.second.x > bb.first.x && ibb.first.y < bb.second.y && ibb.second.y > bb.second.x) { @@ -1222,7 +1222,7 @@ bool TryAddOpenings_Quadrulate(const std::vector& openings,const st "bounding box overlaps, using poly2tri fallback"); return TryAddOpenings_Poly2Tri(openings, nors, curmesh); } - }*/ + } bbs.push_back(bb); } diff --git a/code/IRRMeshLoader.cpp b/code/IRRMeshLoader.cpp index 97984e842..4efa13112 100644 --- a/code/IRRMeshLoader.cpp +++ b/code/IRRMeshLoader.cpp @@ -298,24 +298,24 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, aiVector3D temp;aiColor4D c; // Read the vertex position - sz = fast_atof_move(sz,(float&)temp.x); + sz = fast_atoreal_move(sz,(float&)temp.x); SkipSpaces(&sz); - sz = fast_atof_move(sz,(float&)temp.y); + sz = fast_atoreal_move(sz,(float&)temp.y); SkipSpaces(&sz); - sz = fast_atof_move(sz,(float&)temp.z); + sz = fast_atoreal_move(sz,(float&)temp.z); SkipSpaces(&sz); curVertices.push_back(temp); // Read the vertex normals - sz = fast_atof_move(sz,(float&)temp.x); + sz = fast_atoreal_move(sz,(float&)temp.x); SkipSpaces(&sz); - sz = fast_atof_move(sz,(float&)temp.y); + sz = fast_atoreal_move(sz,(float&)temp.y); SkipSpaces(&sz); - sz = fast_atof_move(sz,(float&)temp.z); + sz = fast_atoreal_move(sz,(float&)temp.z); SkipSpaces(&sz); curNormals.push_back(temp); @@ -331,10 +331,10 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, // read the first UV coordinate set - sz = fast_atof_move(sz,(float&)temp.x); + sz = fast_atoreal_move(sz,(float&)temp.x); SkipSpaces(&sz); - sz = fast_atof_move(sz,(float&)temp.y); + sz = fast_atoreal_move(sz,(float&)temp.y); SkipSpaces(&sz); temp.z = 0.f; temp.y = 1.f - temp.y; // DX to OGL @@ -342,35 +342,35 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, // read the (optional) second UV coordinate set if (vertexFormat == 1) { - sz = fast_atof_move(sz,(float&)temp.x); + sz = fast_atoreal_move(sz,(float&)temp.x); SkipSpaces(&sz); - sz = fast_atof_move(sz,(float&)temp.y); + sz = fast_atoreal_move(sz,(float&)temp.y); temp.y = 1.f - temp.y; // DX to OGL curUV2s.push_back(temp); } // read optional tangent and bitangent vectors else if (vertexFormat == 2) { // tangents - sz = fast_atof_move(sz,(float&)temp.x); + sz = fast_atoreal_move(sz,(float&)temp.x); SkipSpaces(&sz); - sz = fast_atof_move(sz,(float&)temp.z); + sz = fast_atoreal_move(sz,(float&)temp.z); SkipSpaces(&sz); - sz = fast_atof_move(sz,(float&)temp.y); + sz = fast_atoreal_move(sz,(float&)temp.y); SkipSpaces(&sz); temp.y *= -1.0f; curTangents.push_back(temp); // bitangents - sz = fast_atof_move(sz,(float&)temp.x); + sz = fast_atoreal_move(sz,(float&)temp.x); SkipSpaces(&sz); - sz = fast_atof_move(sz,(float&)temp.z); + sz = fast_atoreal_move(sz,(float&)temp.z); SkipSpaces(&sz); - sz = fast_atof_move(sz,(float&)temp.y); + sz = fast_atoreal_move(sz,(float&)temp.y); SkipSpaces(&sz); temp.y *= -1.0f; curBitangents.push_back(temp); diff --git a/code/IRRShared.cpp b/code/IRRShared.cpp index 1b87ebac1..11477faff 100644 --- a/code/IRRShared.cpp +++ b/code/IRRShared.cpp @@ -167,21 +167,21 @@ void IrrlichtBase::ReadVectorProperty (VectorProperty& out) const char* ptr = reader->getAttributeValue(i); SkipSpaces(&ptr); - ptr = fast_atof_move( ptr,(float&)out.value.x ); + ptr = fast_atoreal_move( ptr,(float&)out.value.x ); SkipSpaces(&ptr); if (',' != *ptr) { DefaultLogger::get()->error("IRR(MESH): Expected comma in vector definition"); } else SkipSpaces(ptr+1,&ptr); - ptr = fast_atof_move( ptr,(float&)out.value.y ); + ptr = fast_atoreal_move( ptr,(float&)out.value.y ); SkipSpaces(&ptr); if (',' != *ptr) { DefaultLogger::get()->error("IRR(MESH): Expected comma in vector definition"); } else SkipSpaces(ptr+1,&ptr); - ptr = fast_atof_move( ptr,(float&)out.value.z ); + ptr = fast_atoreal_move( ptr,(float&)out.value.z ); } } } diff --git a/code/LWSLoader.cpp b/code/LWSLoader.cpp index 54a15d0f9..cc8a691c1 100644 --- a/code/LWSLoader.cpp +++ b/code/LWSLoader.cpp @@ -189,9 +189,9 @@ void LWSImporter::ReadEnvelope(const LWS::Element& dad, LWO::Envelope& fill ) float f; SkipSpaces(&c); - c = fast_atof_move(c,key.value); + c = fast_atoreal_move(c,key.value); SkipSpaces(&c); - c = fast_atof_move(c,f); + c = fast_atoreal_move(c,f); key.time = f; @@ -224,7 +224,7 @@ void LWSImporter::ReadEnvelope(const LWS::Element& dad, LWO::Envelope& fill ) } for (unsigned int i = 0; i < num;++i) { SkipSpaces(&c); - c = fast_atof_move(c,key.params[i]); + c = fast_atoreal_move(c,key.params[i]); } } else if ((*it).tokens[0] == "Behaviors") { @@ -265,10 +265,10 @@ void LWSImporter::ReadEnvelope_Old( // parse value and time, skip the rest for the moment. LWO::Key key; - const char* c = fast_atof_move((*it).tokens[0].c_str(),key.value); + const char* c = fast_atoreal_move((*it).tokens[0].c_str(),key.value); SkipSpaces(&c); float f; - fast_atof_move((*it).tokens[0].c_str(),f); + fast_atoreal_move((*it).tokens[0].c_str(),f); key.time = f; envl.keys.push_back(key); @@ -738,7 +738,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) DefaultLogger::get()->error("LWS: Unexpected keyword: \'LightIntensity\'"); - else fast_atof_move(c, nodes.back().lightIntensity ); + else fast_atoreal_move(c, nodes.back().lightIntensity ); } // 'LightType': set type of currently active light @@ -779,11 +779,11 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, DefaultLogger::get()->error("LWS: Unexpected keyword: \'LightColor\'"); else { - c = fast_atof_move(c, (float&) nodes.back().lightColor.r ); + c = fast_atoreal_move(c, (float&) nodes.back().lightColor.r ); SkipSpaces(&c); - c = fast_atof_move(c, (float&) nodes.back().lightColor.g ); + c = fast_atoreal_move(c, (float&) nodes.back().lightColor.g ); SkipSpaces(&c); - c = fast_atof_move(c, (float&) nodes.back().lightColor.b ); + c = fast_atoreal_move(c, (float&) nodes.back().lightColor.b ); } } @@ -792,11 +792,11 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, if (nodes.empty()) DefaultLogger::get()->error("LWS: Unexpected keyword: \'PivotPosition\'"); else { - c = fast_atof_move(c, (float&) nodes.back().pivotPos.x ); + c = fast_atoreal_move(c, (float&) nodes.back().pivotPos.x ); SkipSpaces(&c); - c = fast_atof_move(c, (float&) nodes.back().pivotPos.y ); + c = fast_atoreal_move(c, (float&) nodes.back().pivotPos.y ); SkipSpaces(&c); - c = fast_atof_move(c, (float&) nodes.back().pivotPos.z ); + c = fast_atoreal_move(c, (float&) nodes.back().pivotPos.z ); // Mark pivotPos as set nodes.back().isPivotSet = true; } diff --git a/code/MD5Parser.cpp b/code/MD5Parser.cpp index faae9cbc6..3056ff8b0 100644 --- a/code/MD5Parser.cpp +++ b/code/MD5Parser.cpp @@ -197,11 +197,11 @@ bool MD5Parser::ParseSection(Section& out) if ('(' != *sz++) \ MD5Parser::ReportWarning("Unexpected token: ( was expected",(*eit).iLineNumber); \ AI_MD5_SKIP_SPACES(); \ - sz = fast_atof_move(sz,(float&)vec.x); \ + sz = fast_atoreal_move(sz,(float&)vec.x); \ AI_MD5_SKIP_SPACES(); \ - sz = fast_atof_move(sz,(float&)vec.y); \ + sz = fast_atoreal_move(sz,(float&)vec.y); \ AI_MD5_SKIP_SPACES(); \ - sz = fast_atof_move(sz,(float&)vec.z); \ + sz = fast_atoreal_move(sz,(float&)vec.z); \ AI_MD5_SKIP_SPACES(); \ if (')' != *sz++) \ MD5Parser::ReportWarning("Unexpected token: ) was expected",(*eit).iLineNumber); @@ -295,9 +295,9 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections) if ('(' != *sz++) MD5Parser::ReportWarning("Unexpected token: ( was expected",(*eit).iLineNumber); AI_MD5_SKIP_SPACES(); - sz = fast_atof_move(sz,(float&)vert.mUV.x); + sz = fast_atoreal_move(sz,(float&)vert.mUV.x); AI_MD5_SKIP_SPACES(); - sz = fast_atof_move(sz,(float&)vert.mUV.y); + sz = fast_atoreal_move(sz,(float&)vert.mUV.y); AI_MD5_SKIP_SPACES(); if (')' != *sz++) MD5Parser::ReportWarning("Unexpected token: ) was expected",(*eit).iLineNumber); @@ -333,7 +333,7 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections) WeightDesc& weight = desc.mWeights[idx]; weight.mBone = strtoul10(sz,&sz); AI_MD5_SKIP_SPACES(); - sz = fast_atof_move(sz,weight.mWeight); + sz = fast_atoreal_move(sz,weight.mWeight); AI_MD5_READ_TRIPLE(weight.vOffsetPosition); } } @@ -406,7 +406,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections) for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit){ const char* sz = (*eit).szStart; while (SkipSpacesAndLineEnd(&sz)) { - float f;sz = fast_atof_move(sz,f); + float f;sz = fast_atoreal_move(sz,f); desc.mValues.push_back(f); } } @@ -427,7 +427,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections) mAnimatedBones.reserve( strtoul10((*iter).mGlobalValue.c_str())); } else if((*iter).mName == "frameRate") { - fast_atof_move((*iter).mGlobalValue.c_str(),fFrameRate); + fast_atoreal_move((*iter).mGlobalValue.c_str(),fFrameRate); } } DefaultLogger::get()->debug("MD5AnimParser end"); diff --git a/code/MaterialSystem.cpp b/code/MaterialSystem.cpp index 8bb95ede7..d9ef679c8 100644 --- a/code/MaterialSystem.cpp +++ b/code/MaterialSystem.cpp @@ -137,7 +137,7 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat, const char* cur = prop->mData+4; ai_assert(prop->mDataLength>=5 && !prop->mData[prop->mDataLength-1]); for (unsigned int a = 0; ;++a) { - cur = fast_atof_move(cur,pOut[a]); + cur = fast_atoreal_move(cur,pOut[a]); if(a==iWrite-1) { break; } diff --git a/code/NFFLoader.cpp b/code/NFFLoader.cpp index a92e62180..c2c30989b 100644 --- a/code/NFFLoader.cpp +++ b/code/NFFLoader.cpp @@ -81,7 +81,7 @@ void NFFImporter::GetExtensionList(std::set& extensions) // ------------------------------------------------------------------------------------------------ #define AI_NFF_PARSE_FLOAT(f) \ SkipSpaces(&sz); \ - if (!::IsLineEnd(*sz))sz = fast_atof_move(sz, (float&)f); + if (!::IsLineEnd(*sz))sz = fast_atoreal_move(sz, (float&)f); // ------------------------------------------------------------------------------------------------ #define AI_NFF_PARSE_TRIPLE(v) \ diff --git a/code/OFFLoader.cpp b/code/OFFLoader.cpp index 1bcae3596..c8fe5cdce 100644 --- a/code/OFFLoader.cpp +++ b/code/OFFLoader.cpp @@ -131,9 +131,9 @@ void OFFImporter::InternReadFile( const std::string& pFile, aiVector3D& v = tempPositions[i]; sz = line; SkipSpaces(&sz); - sz = fast_atof_move(sz,(float&)v.x); SkipSpaces(&sz); - sz = fast_atof_move(sz,(float&)v.y); SkipSpaces(&sz); - fast_atof_move(sz,(float&)v.z); + sz = fast_atoreal_move(sz,(float&)v.x); SkipSpaces(&sz); + sz = fast_atoreal_move(sz,(float&)v.y); SkipSpaces(&sz); + fast_atoreal_move(sz,(float&)v.z); } diff --git a/code/PlyParser.cpp b/code/PlyParser.cpp index b6302cd29..524733192 100644 --- a/code/PlyParser.cpp +++ b/code/PlyParser.cpp @@ -811,13 +811,13 @@ bool PLY::PropertyInstance::ParseValue( case EDT_Float: - pCur = fast_atof_move(pCur,out->fFloat); + pCur = fast_atoreal_move(pCur,out->fFloat); break; case EDT_Double: float f; - pCur = fast_atof_move(pCur,f); + pCur = fast_atoreal_move(pCur,f); out->fDouble = (double)f; break; diff --git a/code/RawLoader.cpp b/code/RawLoader.cpp index 2959e24e6..1d6610c6d 100644 --- a/code/RawLoader.cpp +++ b/code/RawLoader.cpp @@ -137,7 +137,7 @@ void RAWImporter::InternReadFile( const std::string& pFile, for (num = 0; num < 12;++num) { if(!SkipSpaces(&sz) || !IsNumeric(*sz))break; - sz = fast_atof_move(sz,data[num]); + sz = fast_atoreal_move(sz,data[num]); } if (num != 12 && num != 9) { diff --git a/code/SMDLoader.cpp b/code/SMDLoader.cpp index 5f441ee49..77d02d65a 100644 --- a/code/SMDLoader.cpp +++ b/code/SMDLoader.cpp @@ -1018,7 +1018,7 @@ bool SMDImporter::ParseFloat(const char* szCurrent, if(!SkipSpaces(&szCurrent)) return false; - *szCurrentOut = fast_atof_move(szCurrent,out); + *szCurrentOut = fast_atoreal_move(szCurrent,out); return true; } diff --git a/code/STEPFile.h b/code/STEPFile.h index be77a2ec2..cc038faca 100644 --- a/code/STEPFile.h +++ b/code/STEPFile.h @@ -281,8 +281,8 @@ namespace STEP { }; typedef PrimitiveDataType INTEGER; - typedef PrimitiveDataType REAL; - typedef PrimitiveDataType NUMBER; + typedef PrimitiveDataType REAL; + typedef PrimitiveDataType NUMBER; typedef PrimitiveDataType STRING; diff --git a/code/STEPFileReader.cpp b/code/STEPFileReader.cpp index 48dc60990..7741a8f90 100644 --- a/code/STEPFileReader.cpp +++ b/code/STEPFileReader.cpp @@ -344,7 +344,7 @@ boost::shared_ptr EXPRESS::DataType::Parse(const char*& if (*cur == '.') { // XXX many STEP files contain extremely accurate data, float's precision may not suffice in many cases float f; - inout = fast_atof_move(start,f); + inout = fast_atoreal_move(start,f); return boost::make_shared(f); } } diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index 07227305e..8917fcb46 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -239,11 +239,11 @@ void STLImporter::LoadASCIIFile() { sz += 7; SkipSpaces(&sz); - sz = fast_atof_move(sz, (float&)vn->x ); + sz = fast_atoreal_move(sz, (float&)vn->x ); SkipSpaces(&sz); - sz = fast_atof_move(sz, (float&)vn->y ); + sz = fast_atoreal_move(sz, (float&)vn->y ); SkipSpaces(&sz); - sz = fast_atof_move(sz, (float&)vn->z ); + sz = fast_atoreal_move(sz, (float&)vn->z ); *(vn+1) = *vn; *(vn+2) = *vn; } @@ -259,11 +259,11 @@ void STLImporter::LoadASCIIFile() sz += 7; SkipSpaces(&sz); aiVector3D* vn = &pMesh->mVertices[(curFace-1)*3 + curVertex++]; - sz = fast_atof_move(sz, (float&)vn->x ); + sz = fast_atoreal_move(sz, (float&)vn->x ); SkipSpaces(&sz); - sz = fast_atof_move(sz, (float&)vn->y ); + sz = fast_atoreal_move(sz, (float&)vn->y ); SkipSpaces(&sz); - sz = fast_atof_move(sz, (float&)vn->z ); + sz = fast_atoreal_move(sz, (float&)vn->z ); } } else if (!::strncmp(sz,"endsolid",8)) { diff --git a/code/UnrealLoader.cpp b/code/UnrealLoader.cpp index 1f9075045..786e25ec8 100644 --- a/code/UnrealLoader.cpp +++ b/code/UnrealLoader.cpp @@ -288,13 +288,13 @@ void UnrealImporter::InternReadFile( const std::string& pFile, for (;!IsLineEnd(*data);++data) { if (data[0] == 'X' && data[1] == '=') { - data = fast_atof_move(data+2,(float&)nd->mTransformation.a1); + data = fast_atoreal_move(data+2,(float&)nd->mTransformation.a1); } else if (data[0] == 'Y' && data[1] == '=') { - data = fast_atof_move(data+2,(float&)nd->mTransformation.b2); + data = fast_atoreal_move(data+2,(float&)nd->mTransformation.b2); } else if (data[0] == 'Z' && data[1] == '=') { - data = fast_atof_move(data+2,(float&)nd->mTransformation.c3); + data = fast_atoreal_move(data+2,(float&)nd->mTransformation.c3); } } } diff --git a/code/XFileParser.cpp b/code/XFileParser.cpp index 6640d0b43..c0a1a8f6c 100644 --- a/code/XFileParser.cpp +++ b/code/XFileParser.cpp @@ -1368,7 +1368,7 @@ float XFileParser::ReadFloat() } float result = 0.0f; - P = fast_atof_move( P, result); + P = fast_atoreal_move( P, result); CheckForSeparator(); diff --git a/code/fast_atof.h b/code/fast_atof.h index 90b67725d..0f3536c37 100644 --- a/code/fast_atof.h +++ b/code/fast_atof.h @@ -222,20 +222,22 @@ inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* //! about 6 times faster than atof in win32. // If you find any bugs, please send them to me, niko (at) irrlicht3d.org. // ------------------------------------------------------------------------------------ -inline const char* fast_atof_move( const char* c, float& out) +template +inline const char* fast_atoreal_move( const char* c, Real& out) { - float f; + Real f; bool inv = (*c=='-'); - if (inv || *c=='+') + if (inv || *c=='+') { ++c; + } - f = (float) strtoul10_64 ( c, &c); + f = static_cast( strtoul10_64 ( c, &c) ); if (*c == '.' || (c[0] == ',' && (c[1] >= '0' || c[1] <= '9'))) // allow for commas, too { ++c; - // NOTE: The original implementation is highly unaccurate here. The precision of a single + // NOTE: The original implementation is highly inaccurate here. The precision of a single // IEEE 754 float is not high enough, everything behind the 6th digit tends to be more // inaccurate than it would need to be. Casting to double seems to solve the problem. // strtol_64 is used to prevent integer overflow. @@ -244,31 +246,35 @@ inline const char* fast_atof_move( const char* c, float& out) // number of digits to be read. AI_FAST_ATOF_RELAVANT_DECIMALS can be a value between // 1 and 15. unsigned int diff = AI_FAST_ATOF_RELAVANT_DECIMALS; - double pl = (double) strtoul10_64 ( c, &c, &diff ); + double pl = static_cast( strtoul10_64 ( c, &c, &diff )); pl *= fast_atof_table[diff]; - f += (float)pl; + f += static_cast( pl ); } // A major 'E' must be allowed. Necessary for proper reading of some DXF files. // Thanks to Zhao Lei to point out that this if() must be outside the if (*c == '.' ..) - if (*c == 'e' || *c == 'E') - { + if (*c == 'e' || *c == 'E') { + ++c; bool einv = (*c=='-'); - if (einv || *c=='+') + if (einv || *c=='+') { ++c; + } - float exp = (float)strtoul10_64(c, &c); - if (einv) - exp *= -1.0f; - - f *= pow(10.0f, exp); + // The reason float constants are used here is that we've seen cases where compilers + // would perform such casts on compile-time constants at runtime, which would be + // bad considering how frequently fast_atoreal_move is called in Assimp. + Real exp = static_cast( strtoul10_64(c, &c) ); + if (einv) { + exp *= static_cast(-1.0f); + } + f *= pow(static_cast(10.0f), exp); } - if (inv) - f *= -1.0f; - + if (inv) { + f *= static_cast(-1.0f); + } out = f; return c; } @@ -278,7 +284,7 @@ inline const char* fast_atof_move( const char* c, float& out) inline float fast_atof(const char* c) { float ret; - fast_atof_move(c, ret); + fast_atoreal_move(c, ret); return ret; } @@ -286,7 +292,7 @@ inline float fast_atof(const char* c) inline float fast_atof( const char* c, const char** cout) { float ret; - *cout = fast_atof_move(c, ret); + *cout = fast_atoreal_move(c, ret); return ret; } @@ -294,7 +300,32 @@ inline float fast_atof( const char* c, const char** cout) inline float fast_atof( const char** inout) { float ret; - *inout = fast_atof_move(*inout, ret); + *inout = fast_atoreal_move(*inout, ret); + + return ret; +} + + +inline double fast_atod(const char* c) +{ + double ret; + fast_atoreal_move(c, ret); + return ret; +} + + +inline double fast_atod( const char* c, const char** cout) +{ + double ret; + *cout = fast_atoreal_move(c, ret); + + return ret; +} + +inline double fast_atod( const char** inout) +{ + double ret; + *inout = fast_atoreal_move(*inout, ret); return ret; }