- make fast_atof_move a template and rename it to fast_atoreal_move.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1125 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/5/head
parent
16a5bef3ba
commit
c12fadc93b
|
@ -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<float>(buffer,((float*)out)[i]); \
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<float>(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<float>(filePtr,fOut);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Parser::ParseLV4MeshLong(unsigned int& iOut)
|
||||
|
|
|
@ -71,7 +71,7 @@ ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut)
|
|||
return;
|
||||
}
|
||||
|
||||
SceneCombiner::CopyScene(pOut,pIn,false);
|
||||
SceneCombiner::CopyScene(pOut,pIn,true);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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<float>( ctoken, result);
|
||||
|
||||
if( ctoken != token.c_str() + token.length())
|
||||
ThrowException( boost::str( boost::format( "Expected a floating point number, but found \"%s\".") % token));
|
||||
|
|
|
@ -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<float>(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<float>(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<float>(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<float>(buffer, (float&)sub->mValue.z);
|
||||
|
||||
++s->mNumPositionKeys;
|
||||
}
|
||||
|
|
|
@ -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<float>( 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<float>( content, (float&)pLight.mColor.r);
|
||||
SkipSpacesAndLineEnd( &content);
|
||||
|
||||
content = fast_atof_move( content, (float&)pLight.mColor.g);
|
||||
content = fast_atoreal_move<float>( content, (float&)pLight.mColor.g);
|
||||
SkipSpacesAndLineEnd( &content);
|
||||
|
||||
content = fast_atof_move( content, (float&)pLight.mColor.b);
|
||||
content = fast_atoreal_move<float>( 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<float>( content, (float&)pColor.r);
|
||||
SkipSpacesAndLineEnd( &content);
|
||||
|
||||
content = fast_atof_move( content, (float&)pColor.g);
|
||||
content = fast_atoreal_move<float>( content, (float&)pColor.g);
|
||||
SkipSpacesAndLineEnd( &content);
|
||||
|
||||
content = fast_atof_move( content, (float&)pColor.b);
|
||||
content = fast_atoreal_move<float>( content, (float&)pColor.b);
|
||||
SkipSpacesAndLineEnd( &content);
|
||||
|
||||
content = fast_atof_move( content, (float&)pColor.a);
|
||||
content = fast_atoreal_move<float>( 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<float>( 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<float>( 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<float>( content, tf.f[a]);
|
||||
// skip whitespace after it
|
||||
SkipSpacesAndLineEnd( &content);
|
||||
}
|
||||
|
|
|
@ -1214,7 +1214,7 @@ bool TryAddOpenings_Quadrulate(const std::vector<TempOpening>& 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<TempOpening>& openings,const st
|
|||
"bounding box overlaps, using poly2tri fallback");
|
||||
return TryAddOpenings_Poly2Tri(openings, nors, curmesh);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
bbs.push_back(bb);
|
||||
}
|
||||
|
|
|
@ -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<float>(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.y);
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.y);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.z);
|
||||
sz = fast_atoreal_move<float>(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<float>(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.y);
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.y);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.z);
|
||||
sz = fast_atoreal_move<float>(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<float>(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.y);
|
||||
sz = fast_atoreal_move<float>(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<float>(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.y);
|
||||
sz = fast_atoreal_move<float>(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<float>(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.z);
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.z);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.y);
|
||||
sz = fast_atoreal_move<float>(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<float>(sz,(float&)temp.x);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.z);
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.z);
|
||||
SkipSpaces(&sz);
|
||||
|
||||
sz = fast_atof_move(sz,(float&)temp.y);
|
||||
sz = fast_atoreal_move<float>(sz,(float&)temp.y);
|
||||
SkipSpaces(&sz);
|
||||
temp.y *= -1.0f;
|
||||
curBitangents.push_back(temp);
|
||||
|
|
|
@ -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<float>( 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<float>( 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<float>( ptr,(float&)out.value.z );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<float>(c,key.value);
|
||||
SkipSpaces(&c);
|
||||
c = fast_atof_move(c,f);
|
||||
c = fast_atoreal_move<float>(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<float>(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<float>((*it).tokens[0].c_str(),key.value);
|
||||
SkipSpaces(&c);
|
||||
float f;
|
||||
fast_atof_move((*it).tokens[0].c_str(),f);
|
||||
fast_atoreal_move<float>((*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<float>(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<float>(c, (float&) nodes.back().lightColor.r );
|
||||
SkipSpaces(&c);
|
||||
c = fast_atof_move(c, (float&) nodes.back().lightColor.g );
|
||||
c = fast_atoreal_move<float>(c, (float&) nodes.back().lightColor.g );
|
||||
SkipSpaces(&c);
|
||||
c = fast_atof_move(c, (float&) nodes.back().lightColor.b );
|
||||
c = fast_atoreal_move<float>(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<float>(c, (float&) nodes.back().pivotPos.x );
|
||||
SkipSpaces(&c);
|
||||
c = fast_atof_move(c, (float&) nodes.back().pivotPos.y );
|
||||
c = fast_atoreal_move<float>(c, (float&) nodes.back().pivotPos.y );
|
||||
SkipSpaces(&c);
|
||||
c = fast_atof_move(c, (float&) nodes.back().pivotPos.z );
|
||||
c = fast_atoreal_move<float>(c, (float&) nodes.back().pivotPos.z );
|
||||
// Mark pivotPos as set
|
||||
nodes.back().isPivotSet = true;
|
||||
}
|
||||
|
|
|
@ -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<float>(sz,(float&)vec.x); \
|
||||
AI_MD5_SKIP_SPACES(); \
|
||||
sz = fast_atof_move(sz,(float&)vec.y); \
|
||||
sz = fast_atoreal_move<float>(sz,(float&)vec.y); \
|
||||
AI_MD5_SKIP_SPACES(); \
|
||||
sz = fast_atof_move(sz,(float&)vec.z); \
|
||||
sz = fast_atoreal_move<float>(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<float>(sz,(float&)vert.mUV.x);
|
||||
AI_MD5_SKIP_SPACES();
|
||||
sz = fast_atof_move(sz,(float&)vert.mUV.y);
|
||||
sz = fast_atoreal_move<float>(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<float>(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<float>(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<float>((*iter).mGlobalValue.c_str(),fFrameRate);
|
||||
}
|
||||
}
|
||||
DefaultLogger::get()->debug("MD5AnimParser end");
|
||||
|
|
|
@ -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<float>(cur,pOut[a]);
|
||||
if(a==iWrite-1) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ void NFFImporter::GetExtensionList(std::set<std::string>& 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<float>(sz, (float&)f);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define AI_NFF_PARSE_TRIPLE(v) \
|
||||
|
|
|
@ -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<float>(sz,(float&)v.x); SkipSpaces(&sz);
|
||||
sz = fast_atoreal_move<float>(sz,(float&)v.y); SkipSpaces(&sz);
|
||||
fast_atoreal_move<float>(sz,(float&)v.z);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -811,13 +811,13 @@ bool PLY::PropertyInstance::ParseValue(
|
|||
|
||||
case EDT_Float:
|
||||
|
||||
pCur = fast_atof_move(pCur,out->fFloat);
|
||||
pCur = fast_atoreal_move<float>(pCur,out->fFloat);
|
||||
break;
|
||||
|
||||
case EDT_Double:
|
||||
|
||||
float f;
|
||||
pCur = fast_atof_move(pCur,f);
|
||||
pCur = fast_atoreal_move<float>(pCur,f);
|
||||
out->fDouble = (double)f;
|
||||
break;
|
||||
|
||||
|
|
|
@ -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<float>(sz,data[num]);
|
||||
}
|
||||
if (num != 12 && num != 9)
|
||||
{
|
||||
|
|
|
@ -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<float>(szCurrent,out);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -281,8 +281,8 @@ namespace STEP {
|
|||
};
|
||||
|
||||
typedef PrimitiveDataType<int64_t> INTEGER;
|
||||
typedef PrimitiveDataType<float> REAL;
|
||||
typedef PrimitiveDataType<float> NUMBER;
|
||||
typedef PrimitiveDataType<double> REAL;
|
||||
typedef PrimitiveDataType<double> NUMBER;
|
||||
typedef PrimitiveDataType<std::string> STRING;
|
||||
|
||||
|
||||
|
|
|
@ -344,7 +344,7 @@ boost::shared_ptr<const EXPRESS::DataType> 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<float>(start,f);
|
||||
return boost::make_shared<EXPRESS::REAL>(f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,11 +239,11 @@ void STLImporter::LoadASCIIFile()
|
|||
{
|
||||
sz += 7;
|
||||
SkipSpaces(&sz);
|
||||
sz = fast_atof_move(sz, (float&)vn->x );
|
||||
sz = fast_atoreal_move<float>(sz, (float&)vn->x );
|
||||
SkipSpaces(&sz);
|
||||
sz = fast_atof_move(sz, (float&)vn->y );
|
||||
sz = fast_atoreal_move<float>(sz, (float&)vn->y );
|
||||
SkipSpaces(&sz);
|
||||
sz = fast_atof_move(sz, (float&)vn->z );
|
||||
sz = fast_atoreal_move<float>(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<float>(sz, (float&)vn->x );
|
||||
SkipSpaces(&sz);
|
||||
sz = fast_atof_move(sz, (float&)vn->y );
|
||||
sz = fast_atoreal_move<float>(sz, (float&)vn->y );
|
||||
SkipSpaces(&sz);
|
||||
sz = fast_atof_move(sz, (float&)vn->z );
|
||||
sz = fast_atoreal_move<float>(sz, (float&)vn->z );
|
||||
}
|
||||
}
|
||||
else if (!::strncmp(sz,"endsolid",8)) {
|
||||
|
|
|
@ -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<float>(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<float>(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<float>(data+2,(float&)nd->mTransformation.c3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1368,7 +1368,7 @@ float XFileParser::ReadFloat()
|
|||
}
|
||||
|
||||
float result = 0.0f;
|
||||
P = fast_atof_move( P, result);
|
||||
P = fast_atoreal_move<float>( P, result);
|
||||
|
||||
CheckForSeparator();
|
||||
|
||||
|
|
|
@ -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 <typename Real>
|
||||
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<Real>( 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<double>( strtoul10_64 ( c, &c, &diff ));
|
||||
|
||||
pl *= fast_atof_table[diff];
|
||||
f += (float)pl;
|
||||
f += static_cast<Real>( 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<float> is called in Assimp.
|
||||
Real exp = static_cast<Real>( strtoul10_64(c, &c) );
|
||||
if (einv) {
|
||||
exp *= static_cast<Real>(-1.0f);
|
||||
}
|
||||
f *= pow(static_cast<Real>(10.0f), exp);
|
||||
}
|
||||
|
||||
if (inv)
|
||||
f *= -1.0f;
|
||||
|
||||
if (inv) {
|
||||
f *= static_cast<Real>(-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<float>(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<float>(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<float>(*inout, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
inline double fast_atod(const char* c)
|
||||
{
|
||||
double ret;
|
||||
fast_atoreal_move<double>(c, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
inline double fast_atod( const char* c, const char** cout)
|
||||
{
|
||||
double ret;
|
||||
*cout = fast_atoreal_move<double>(c, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline double fast_atod( const char** inout)
|
||||
{
|
||||
double ret;
|
||||
*inout = fast_atoreal_move<double>(*inout, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue