Pārlūkot izejas kodu

- 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-9d2fd5bffc1f
aramis_acg 13 gadi atpakaļ
vecāks
revīzija
c12fadc93b

+ 1 - 1
code/ACLoader.cpp

@@ -100,7 +100,7 @@ using namespace Assimp;
 	for (unsigned int i = 0; i < num;++i) \
 	for (unsigned int i = 0; i < num;++i) \
 	{ \
 	{ \
 		AI_AC_SKIP_TO_NEXT_TOKEN(); \
 		AI_AC_SKIP_TO_NEXT_TOKEN(); \
-		buffer = fast_atof_move(buffer,((float*)out)[i]); \
+		buffer = fast_atoreal_move<float>(buffer,((float*)out)[i]); \
 	}
 	}
 
 
 
 

+ 2 - 2
code/ASEParser.cpp

@@ -1614,7 +1614,7 @@ void Parser::ParseLV4MeshBonesVertices(unsigned int iNumVertices,ASE::Mesh& mesh
 
 
 					// then parse the vertex weight
 					// then parse the vertex weight
 					if (!SkipSpaces(&filePtr))break;
 					if (!SkipSpaces(&filePtr))break;
-					filePtr = fast_atof_move(filePtr,pairOut.second);
+					filePtr = fast_atoreal_move<float>(filePtr,pairOut.second);
 
 
 					// -1 marks unused entries
 					// -1 marks unused entries
 					if (-1 != pairOut.first)
 					if (-1 != pairOut.first)
@@ -2131,7 +2131,7 @@ void Parser::ParseLV4MeshFloat(float& fOut)
 		return;
 		return;
 	}
 	}
 	// parse the first float
 	// parse the first float
-	filePtr = fast_atof_move(filePtr,fOut);
+	filePtr = fast_atoreal_move<float>(filePtr,fOut);
 }
 }
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 void Parser::ParseLV4MeshLong(unsigned int& iOut)
 void Parser::ParseLV4MeshLong(unsigned int& iOut)

+ 1 - 1
code/AssimpCExport.cpp

@@ -71,7 +71,7 @@ ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut)
 		return;
 		return;
 	}
 	}
 
 
-	SceneCombiner::CopyScene(pOut,pIn,false);
+	SceneCombiner::CopyScene(pOut,pIn,true);
 }
 }
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------

+ 1 - 1
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
 	// check if the float is valid by testing if the atof() function consumed every char of the token
 	const char* ctoken = token.c_str();
 	const char* ctoken = token.c_str();
 	float result = 0.0f;
 	float result = 0.0f;
-	ctoken = fast_atof_move( ctoken, result);
+	ctoken = fast_atoreal_move<float>( ctoken, result);
 
 
 	if( ctoken != token.c_str() + token.length())
 	if( ctoken != token.c_str() + token.length())
 		ThrowException( boost::str( boost::format( "Expected a floating point number, but found \"%s\".") % token));
 		ThrowException( boost::str( boost::format( "Expected a floating point number, but found \"%s\".") % token));

+ 4 - 4
code/CSMLoader.cpp

@@ -134,7 +134,7 @@ void CSMImporter::InternReadFile( const std::string& pFile,
 			else if (TokenMatchI(buffer,"rate",4))	{
 			else if (TokenMatchI(buffer,"rate",4))	{
 				SkipSpaces(&buffer);
 				SkipSpaces(&buffer);
 				float d;
 				float d;
-				buffer = fast_atof_move(buffer,d);
+				buffer = fast_atoreal_move<float>(buffer,d);
 				anim->mTicksPerSecond = d;
 				anim->mTicksPerSecond = d;
 			}
 			}
 			else if (TokenMatchI(buffer,"order",5))	{
 			else if (TokenMatchI(buffer,"order",5))	{
@@ -214,15 +214,15 @@ void CSMImporter::InternReadFile( const std::string& pFile,
 						else	{
 						else	{
 							aiVectorKey* sub = s->mPositionKeys + s->mNumPositionKeys;
 							aiVectorKey* sub = s->mPositionKeys + s->mNumPositionKeys;
 							sub->mTime = (double)frame;
 							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))
 							if(!SkipSpacesAndLineEnd(&buffer))
 								throw DeadlyImportError("CSM: Unexpected EOF occured reading sample y coord");
 								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))
 							if(!SkipSpacesAndLineEnd(&buffer))
 								throw DeadlyImportError("CSM: Unexpected EOF occured reading sample z coord");
 								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;
 							++s->mNumPositionKeys;
 						}
 						}

+ 11 - 11
code/ColladaParser.cpp

@@ -500,7 +500,7 @@ void ColladaParser::ReadController( Collada::Controller& pController)
 	      for( unsigned int a = 0; a < 16; a++)
 	      for( unsigned int a = 0; a < 16; a++)
 	      {
 	      {
 		      // read a number
 		      // read a number
-          content = fast_atof_move( content, pController.mBindShapeMatrix[a]);
+          content = fast_atoreal_move<float>( content, pController.mBindShapeMatrix[a]);
 		      // skip whitespace after it
 		      // skip whitespace after it
 		      SkipSpacesAndLineEnd( &content);
 		      SkipSpacesAndLineEnd( &content);
 	      }
 	      }
@@ -980,13 +980,13 @@ void ColladaParser::ReadLight( Collada::Light& pLight)
 				// text content contains 3 floats
 				// text content contains 3 floats
 				const char* content = GetTextContent();
 				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);
 				SkipSpacesAndLineEnd( &content);
 				
 				
-				content = fast_atof_move( content, (float&)pLight.mColor.g);
+				content = fast_atoreal_move<float>( content, (float&)pLight.mColor.g);
 				SkipSpacesAndLineEnd( &content);
 				SkipSpacesAndLineEnd( &content);
 
 
-				content = fast_atof_move( content, (float&)pLight.mColor.b);
+				content = fast_atoreal_move<float>( content, (float&)pLight.mColor.b);
 				SkipSpacesAndLineEnd( &content);
 				SkipSpacesAndLineEnd( &content);
 
 
 				TestClosing( "color");
 				TestClosing( "color");
@@ -1342,16 +1342,16 @@ void ColladaParser::ReadEffectColor( aiColor4D& pColor, Sampler& pSampler)
 				// text content contains 4 floats
 				// text content contains 4 floats
 				const char* content = GetTextContent(); 
 				const char* content = GetTextContent(); 
 
 
-				content = fast_atof_move( content, (float&)pColor.r);
+				content = fast_atoreal_move<float>( content, (float&)pColor.r);
 				SkipSpacesAndLineEnd( &content);
 				SkipSpacesAndLineEnd( &content);
 
 
-				content = fast_atof_move( content, (float&)pColor.g);
+				content = fast_atoreal_move<float>( content, (float&)pColor.g);
 				SkipSpacesAndLineEnd( &content);
 				SkipSpacesAndLineEnd( &content);
 
 
-				content = fast_atof_move( content, (float&)pColor.b);
+				content = fast_atoreal_move<float>( content, (float&)pColor.b);
 				SkipSpacesAndLineEnd( &content);
 				SkipSpacesAndLineEnd( &content);
 
 
-				content = fast_atof_move( content, (float&)pColor.a);
+				content = fast_atoreal_move<float>( content, (float&)pColor.a);
 				SkipSpacesAndLineEnd( &content);
 				SkipSpacesAndLineEnd( &content);
 				TestClosing( "color");
 				TestClosing( "color");
 			} 
 			} 
@@ -1404,7 +1404,7 @@ void ColladaParser::ReadEffectFloat( float& pFloat)
 			{
 			{
 				// text content contains a single floats
 				// text content contains a single floats
 				const char* content = GetTextContent();
 				const char* content = GetTextContent();
-				content = fast_atof_move( content, pFloat);
+				content = fast_atoreal_move<float>( content, pFloat);
 				SkipSpacesAndLineEnd( &content);
 				SkipSpacesAndLineEnd( &content);
 
 
 				TestClosing( "float");
 				TestClosing( "float");
@@ -1681,7 +1681,7 @@ void ColladaParser::ReadDataArray()
 
 
 				float value;
 				float value;
 				// read a number
 				// read a number
-				content = fast_atof_move( content, value);
+				content = fast_atoreal_move<float>( content, value);
 				data.mValues.push_back( value);
 				data.mValues.push_back( value);
 				// skip whitespace after it
 				// skip whitespace after it
 				SkipSpacesAndLineEnd( &content);
 				SkipSpacesAndLineEnd( &content);
@@ -2445,7 +2445,7 @@ void ColladaParser::ReadNodeTransformation( Node* pNode, TransformType pType)
 	for( unsigned int a = 0; a < sNumParameters[pType]; a++)
 	for( unsigned int a = 0; a < sNumParameters[pType]; a++)
 	{
 	{
 		// read a number
 		// read a number
-		content = fast_atof_move( content, tf.f[a]);
+		content = fast_atoreal_move<float>( content, tf.f[a]);
 		// skip whitespace after it
 		// skip whitespace after it
 		SkipSpacesAndLineEnd( &content);
 		SkipSpacesAndLineEnd( &content);
 	}
 	}

+ 2 - 2
code/IFCGeometry.cpp

@@ -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()
 		// see if this BB intersects any other, in which case we could not use the Quadrify()
 		// algorithm and would revert to Poly2Tri only.
 		// 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 &&
 			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) {
 				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");
 					"bounding box overlaps, using poly2tri fallback");
 				return TryAddOpenings_Poly2Tri(openings, nors, curmesh);
 				return TryAddOpenings_Poly2Tri(openings, nors, curmesh);
 			}
 			}
-		}*/
+		}
 
 
 		bbs.push_back(bb);
 		bbs.push_back(bb);
 	}
 	}

+ 16 - 16
code/IRRMeshLoader.cpp

@@ -298,24 +298,24 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
 					aiVector3D temp;aiColor4D c;
 					aiVector3D temp;aiColor4D c;
 
 
 					// Read the vertex position
 					// Read the vertex position
-					sz = fast_atof_move(sz,(float&)temp.x);
+					sz = fast_atoreal_move<float>(sz,(float&)temp.x);
 					SkipSpaces(&sz);
 					SkipSpaces(&sz);
 
 
-					sz = fast_atof_move(sz,(float&)temp.y);
+					sz = fast_atoreal_move<float>(sz,(float&)temp.y);
 					SkipSpaces(&sz);
 					SkipSpaces(&sz);
 
 
-					sz = fast_atof_move(sz,(float&)temp.z);
+					sz = fast_atoreal_move<float>(sz,(float&)temp.z);
 					SkipSpaces(&sz);
 					SkipSpaces(&sz);
 					curVertices.push_back(temp);
 					curVertices.push_back(temp);
 
 
 					// Read the vertex normals
 					// Read the vertex normals
-					sz = fast_atof_move(sz,(float&)temp.x);
+					sz = fast_atoreal_move<float>(sz,(float&)temp.x);
 					SkipSpaces(&sz);
 					SkipSpaces(&sz);
 
 
-					sz = fast_atof_move(sz,(float&)temp.y);
+					sz = fast_atoreal_move<float>(sz,(float&)temp.y);
 					SkipSpaces(&sz);
 					SkipSpaces(&sz);
 
 
-					sz = fast_atof_move(sz,(float&)temp.z);
+					sz = fast_atoreal_move<float>(sz,(float&)temp.z);
 					SkipSpaces(&sz);
 					SkipSpaces(&sz);
 					curNormals.push_back(temp);
 					curNormals.push_back(temp);
 
 
@@ -331,10 +331,10 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
 
 
 
 
 					// read the first UV coordinate set
 					// 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);
 					SkipSpaces(&sz);
 
 
-					sz = fast_atof_move(sz,(float&)temp.y);
+					sz = fast_atoreal_move<float>(sz,(float&)temp.y);
 					SkipSpaces(&sz);
 					SkipSpaces(&sz);
 					temp.z = 0.f;
 					temp.z = 0.f;
 					temp.y = 1.f - temp.y;  // DX to OGL
 					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
 					// read the (optional) second UV coordinate set
 					if (vertexFormat == 1)	{
 					if (vertexFormat == 1)	{
-						sz = fast_atof_move(sz,(float&)temp.x);
+						sz = fast_atoreal_move<float>(sz,(float&)temp.x);
 						SkipSpaces(&sz);
 						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
 						temp.y = 1.f - temp.y; // DX to OGL
 						curUV2s.push_back(temp);
 						curUV2s.push_back(temp);
 					}
 					}
 					// read optional tangent and bitangent vectors
 					// read optional tangent and bitangent vectors
 					else if (vertexFormat == 2)	{
 					else if (vertexFormat == 2)	{
 						// tangents
 						// tangents
-						sz = fast_atof_move(sz,(float&)temp.x);
+						sz = fast_atoreal_move<float>(sz,(float&)temp.x);
 						SkipSpaces(&sz);
 						SkipSpaces(&sz);
 
 
-						sz = fast_atof_move(sz,(float&)temp.z);
+						sz = fast_atoreal_move<float>(sz,(float&)temp.z);
 						SkipSpaces(&sz);
 						SkipSpaces(&sz);
 
 
-						sz = fast_atof_move(sz,(float&)temp.y);
+						sz = fast_atoreal_move<float>(sz,(float&)temp.y);
 						SkipSpaces(&sz);
 						SkipSpaces(&sz);
 						temp.y *= -1.0f;
 						temp.y *= -1.0f;
 						curTangents.push_back(temp);
 						curTangents.push_back(temp);
 
 
 						// bitangents
 						// bitangents
-						sz = fast_atof_move(sz,(float&)temp.x);
+						sz = fast_atoreal_move<float>(sz,(float&)temp.x);
 						SkipSpaces(&sz);
 						SkipSpaces(&sz);
 
 
-						sz = fast_atof_move(sz,(float&)temp.z);
+						sz = fast_atoreal_move<float>(sz,(float&)temp.z);
 						SkipSpaces(&sz);
 						SkipSpaces(&sz);
 
 
-						sz = fast_atof_move(sz,(float&)temp.y);
+						sz = fast_atoreal_move<float>(sz,(float&)temp.y);
 						SkipSpaces(&sz);
 						SkipSpaces(&sz);
 						temp.y *= -1.0f;
 						temp.y *= -1.0f;
 						curBitangents.push_back(temp);
 						curBitangents.push_back(temp);

+ 3 - 3
code/IRRShared.cpp

@@ -167,21 +167,21 @@ void IrrlichtBase::ReadVectorProperty  (VectorProperty&  out)
 			const char* ptr = reader->getAttributeValue(i);
 			const char* ptr = reader->getAttributeValue(i);
 
 
 			SkipSpaces(&ptr);
 			SkipSpaces(&ptr);
-			ptr = fast_atof_move( ptr,(float&)out.value.x );
+			ptr = fast_atoreal_move<float>( ptr,(float&)out.value.x );
 			SkipSpaces(&ptr);
 			SkipSpaces(&ptr);
 			if (',' != *ptr)
 			if (',' != *ptr)
 			{
 			{
 				DefaultLogger::get()->error("IRR(MESH): Expected comma in vector definition");
 				DefaultLogger::get()->error("IRR(MESH): Expected comma in vector definition");
 			}
 			}
 			else SkipSpaces(ptr+1,&ptr);
 			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);
 			SkipSpaces(&ptr);
 			if (',' != *ptr)
 			if (',' != *ptr)
 			{
 			{
 				DefaultLogger::get()->error("IRR(MESH): Expected comma in vector definition");
 				DefaultLogger::get()->error("IRR(MESH): Expected comma in vector definition");
 			}
 			}
 			else SkipSpaces(ptr+1,&ptr);
 			else SkipSpaces(ptr+1,&ptr);
-			ptr = fast_atof_move( ptr,(float&)out.value.z );
+			ptr = fast_atoreal_move<float>( ptr,(float&)out.value.z );
 		}
 		}
 	}
 	}
 }
 }

+ 12 - 12
code/LWSLoader.cpp

@@ -189,9 +189,9 @@ void LWSImporter::ReadEnvelope(const LWS::Element& dad, LWO::Envelope& fill )
 
 
 			float f;
 			float f;
 			SkipSpaces(&c);
 			SkipSpaces(&c);
-			c = fast_atof_move(c,key.value);
+			c = fast_atoreal_move<float>(c,key.value);
 			SkipSpaces(&c);
 			SkipSpaces(&c);
-			c = fast_atof_move(c,f);
+			c = fast_atoreal_move<float>(c,f);
 
 
 			key.time = 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) {
 			for (unsigned int i = 0; i < num;++i) {
 				SkipSpaces(&c);
 				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") {
 		else if ((*it).tokens[0] == "Behaviors") {
@@ -265,10 +265,10 @@ void LWSImporter::ReadEnvelope_Old(
 
 
 			// parse value and time, skip the rest for the moment.
 			// parse value and time, skip the rest for the moment.
 			LWO::Key key;
 			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);
 			SkipSpaces(&c);
 			float f;
 			float f;
-			fast_atof_move((*it).tokens[0].c_str(),f);
+			fast_atoreal_move<float>((*it).tokens[0].c_str(),f);
 			key.time = f;
 			key.time = f;
 
 
 			envl.keys.push_back(key);
 			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)
 			if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
 				DefaultLogger::get()->error("LWS: Unexpected keyword: \'LightIntensity\'");
 				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
 		// '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\'");
 				DefaultLogger::get()->error("LWS: Unexpected keyword: \'LightColor\'");
 
 
 			else {
 			else {
-				c = fast_atof_move(c, (float&) nodes.back().lightColor.r );
+				c = fast_atoreal_move<float>(c, (float&) nodes.back().lightColor.r );
 				SkipSpaces(&c);
 				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);
 				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())
 			if (nodes.empty())
 				DefaultLogger::get()->error("LWS: Unexpected keyword: \'PivotPosition\'");
 				DefaultLogger::get()->error("LWS: Unexpected keyword: \'PivotPosition\'");
 			else {
 			else {
-				c = fast_atof_move(c, (float&) nodes.back().pivotPos.x );
+				c = fast_atoreal_move<float>(c, (float&) nodes.back().pivotPos.x );
 				SkipSpaces(&c);
 				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);
 				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
                 // Mark pivotPos as set
                 nodes.back().isPivotSet = true;
                 nodes.back().isPivotSet = true;
 			}
 			}

+ 8 - 8
code/MD5Parser.cpp

@@ -197,11 +197,11 @@ bool MD5Parser::ParseSection(Section& out)
 	if ('(' != *sz++) \
 	if ('(' != *sz++) \
 		MD5Parser::ReportWarning("Unexpected token: ( was expected",(*eit).iLineNumber); \
 		MD5Parser::ReportWarning("Unexpected token: ( was expected",(*eit).iLineNumber); \
 	AI_MD5_SKIP_SPACES(); \
 	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(); \
 	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(); \
 	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(); \
 	AI_MD5_SKIP_SPACES(); \
 	if (')' != *sz++) \
 	if (')' != *sz++) \
 		MD5Parser::ReportWarning("Unexpected token: ) was expected",(*eit).iLineNumber);
 		MD5Parser::ReportWarning("Unexpected token: ) was expected",(*eit).iLineNumber);
@@ -295,9 +295,9 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
 					if ('(' != *sz++)
 					if ('(' != *sz++)
 						MD5Parser::ReportWarning("Unexpected token: ( was expected",(*eit).iLineNumber);
 						MD5Parser::ReportWarning("Unexpected token: ( was expected",(*eit).iLineNumber);
 					AI_MD5_SKIP_SPACES();
 					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();
 					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();
 					AI_MD5_SKIP_SPACES();
 					if (')' != *sz++)
 					if (')' != *sz++)
 						MD5Parser::ReportWarning("Unexpected token: ) was expected",(*eit).iLineNumber);
 						MD5Parser::ReportWarning("Unexpected token: ) was expected",(*eit).iLineNumber);
@@ -333,7 +333,7 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
 					WeightDesc& weight = desc.mWeights[idx];	
 					WeightDesc& weight = desc.mWeights[idx];	
 					weight.mBone = strtoul10(sz,&sz);
 					weight.mBone = strtoul10(sz,&sz);
 					AI_MD5_SKIP_SPACES();
 					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);
 					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){
 			for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit){
 				const char* sz = (*eit).szStart;
 				const char* sz = (*eit).szStart;
 				while (SkipSpacesAndLineEnd(&sz))	{
 				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);
 					desc.mValues.push_back(f);
 				}
 				}
 			}
 			}
@@ -427,7 +427,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
 			mAnimatedBones.reserve( strtoul10((*iter).mGlobalValue.c_str()));
 			mAnimatedBones.reserve( strtoul10((*iter).mGlobalValue.c_str()));
 		}
 		}
 		else if((*iter).mName == "frameRate")	{
 		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");
 	DefaultLogger::get()->debug("MD5AnimParser end");

+ 1 - 1
code/MaterialSystem.cpp

@@ -137,7 +137,7 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
 		const char* cur =  prop->mData+4;
 		const char* cur =  prop->mData+4;
 		ai_assert(prop->mDataLength>=5 && !prop->mData[prop->mDataLength-1]);
 		ai_assert(prop->mDataLength>=5 && !prop->mData[prop->mDataLength-1]);
 		for (unsigned int a = 0; ;++a) {	
 		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) {
 			if(a==iWrite-1) {
 				break;
 				break;
 			}
 			}

+ 1 - 1
code/NFFLoader.cpp

@@ -81,7 +81,7 @@ void NFFImporter::GetExtensionList(std::set<std::string>& extensions)
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 #define AI_NFF_PARSE_FLOAT(f) \
 #define AI_NFF_PARSE_FLOAT(f) \
 	SkipSpaces(&sz); \
 	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) \
 #define AI_NFF_PARSE_TRIPLE(v) \

+ 3 - 3
code/OFFLoader.cpp

@@ -131,9 +131,9 @@ void OFFImporter::InternReadFile( const std::string& pFile,
 		aiVector3D& v = tempPositions[i];
 		aiVector3D& v = tempPositions[i];
 
 
 		sz = line; SkipSpaces(&sz);
 		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);
 	}
 	}
 
 
 	
 	

+ 2 - 2
code/PlyParser.cpp

@@ -811,13 +811,13 @@ bool PLY::PropertyInstance::ParseValue(
 
 
 	case EDT_Float:
 	case EDT_Float:
 
 
-		pCur = fast_atof_move(pCur,out->fFloat);
+		pCur = fast_atoreal_move<float>(pCur,out->fFloat);
 		break;
 		break;
 
 
 	case EDT_Double:
 	case EDT_Double:
 
 
 		float f;
 		float f;
-		pCur = fast_atof_move(pCur,f);
+		pCur = fast_atoreal_move<float>(pCur,f);
 		out->fDouble = (double)f;
 		out->fDouble = (double)f;
 		break;
 		break;
 
 

+ 1 - 1
code/RawLoader.cpp

@@ -137,7 +137,7 @@ void RAWImporter::InternReadFile( const std::string& pFile,
 			for (num = 0; num < 12;++num)
 			for (num = 0; num < 12;++num)
 			{
 			{
 				if(!SkipSpaces(&sz) || !IsNumeric(*sz))break;
 				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)
 			if (num != 12 && num != 9)
 			{
 			{

+ 1 - 1
code/SMDLoader.cpp

@@ -1018,7 +1018,7 @@ bool SMDImporter::ParseFloat(const char* szCurrent,
 	if(!SkipSpaces(&szCurrent))
 	if(!SkipSpaces(&szCurrent))
 		return false;
 		return false;
 
 
-	*szCurrentOut = fast_atof_move(szCurrent,out);
+	*szCurrentOut = fast_atoreal_move<float>(szCurrent,out);
 	return true;
 	return true;
 }
 }
 
 

+ 2 - 2
code/STEPFile.h

@@ -281,8 +281,8 @@ namespace STEP {
 		};
 		};
 
 
 		typedef PrimitiveDataType<int64_t>			INTEGER; 
 		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; 
 		typedef PrimitiveDataType<std::string>		STRING; 
 		
 		
 
 

+ 1 - 1
code/STEPFileReader.cpp

@@ -344,7 +344,7 @@ boost::shared_ptr<const EXPRESS::DataType> EXPRESS::DataType::Parse(const char*&
 		if (*cur == '.') {
 		if (*cur == '.') {
 			// XXX many STEP files contain extremely accurate data, float's precision may not suffice in many cases
 			// XXX many STEP files contain extremely accurate data, float's precision may not suffice in many cases
 			float f;
 			float f;
-			inout = fast_atof_move(start,f);
+			inout = fast_atoreal_move<float>(start,f);
 			return boost::make_shared<EXPRESS::REAL>(f);
 			return boost::make_shared<EXPRESS::REAL>(f);
 		}
 		}
 	}
 	}

+ 6 - 6
code/STLLoader.cpp

@@ -239,11 +239,11 @@ void STLImporter::LoadASCIIFile()
 			{
 			{
 				sz += 7;
 				sz += 7;
 				SkipSpaces(&sz);
 				SkipSpaces(&sz);
-				sz = fast_atof_move(sz, (float&)vn->x ); 
+				sz = fast_atoreal_move<float>(sz, (float&)vn->x ); 
 				SkipSpaces(&sz);
 				SkipSpaces(&sz);
-				sz = fast_atof_move(sz, (float&)vn->y ); 
+				sz = fast_atoreal_move<float>(sz, (float&)vn->y ); 
 				SkipSpaces(&sz);
 				SkipSpaces(&sz);
-				sz = fast_atof_move(sz, (float&)vn->z ); 
+				sz = fast_atoreal_move<float>(sz, (float&)vn->z ); 
 				*(vn+1) = *vn;
 				*(vn+1) = *vn;
 				*(vn+2) = *vn;
 				*(vn+2) = *vn;
 			}
 			}
@@ -259,11 +259,11 @@ void STLImporter::LoadASCIIFile()
 				sz += 7;
 				sz += 7;
 				SkipSpaces(&sz);
 				SkipSpaces(&sz);
 				aiVector3D* vn = &pMesh->mVertices[(curFace-1)*3 + curVertex++];
 				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);
 				SkipSpaces(&sz);
-				sz = fast_atof_move(sz, (float&)vn->y ); 
+				sz = fast_atoreal_move<float>(sz, (float&)vn->y ); 
 				SkipSpaces(&sz);
 				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))	{
 		else if (!::strncmp(sz,"endsolid",8))	{

+ 3 - 3
code/UnrealLoader.cpp

@@ -288,13 +288,13 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
 
 
 						for (;!IsLineEnd(*data);++data)	{
 						for (;!IsLineEnd(*data);++data)	{
 							if (data[0] == 'X' && data[1] == '=')	{
 							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] == '=')	{
 							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] == '=')	{
 							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);
 							}
 							}
 						}
 						}
 					}
 					}

+ 1 - 1
code/XFileParser.cpp

@@ -1368,7 +1368,7 @@ float XFileParser::ReadFloat()
 	}
 	}
 
 
 	float result = 0.0f;
 	float result = 0.0f;
-	P = fast_atof_move( P, result);
+	P = fast_atoreal_move<float>( P, result);
 
 
 	CheckForSeparator();
 	CheckForSeparator();
 
 

+ 52 - 21
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.
 //! about 6 times faster than atof in win32.
 // If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
 // 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=='-');
 	bool inv = (*c=='-');
-	if (inv || *c=='+')
+	if (inv || *c=='+') {
 		++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
 	if (*c == '.' || (c[0] == ',' && (c[1] >= '0' || c[1] <= '9'))) // allow for commas, too
 	{
 	{
 		++c;
 		++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 
 		// 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.
 		// inaccurate than it would need to be. Casting to double seems to solve the problem.
 		// strtol_64 is used to prevent integer overflow.
 		// 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
 		// number of digits to be read. AI_FAST_ATOF_RELAVANT_DECIMALS can be a value between
 		// 1 and 15.
 		// 1 and 15.
 		unsigned int diff = AI_FAST_ATOF_RELAVANT_DECIMALS;
 		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];
 		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.
 	// 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 == '.' ..)
 	// 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;
 		++c;
 		bool einv = (*c=='-');
 		bool einv = (*c=='-');
-		if (einv || *c=='+')
+		if (einv || *c=='+') {
 			++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;
 	out = f;
 	return c;
 	return c;
 }
 }
@@ -278,7 +284,7 @@ inline const char* fast_atof_move( const char* c, float& out)
 inline float fast_atof(const char* c)
 inline float fast_atof(const char* c)
 {
 {
 	float ret;
 	float ret;
-	fast_atof_move(c, ret);
+	fast_atoreal_move<float>(c, ret);
 	return ret;
 	return ret;
 }
 }
 
 
@@ -286,7 +292,7 @@ inline float fast_atof(const char* c)
 inline float fast_atof( const char* c, const char** cout)
 inline float fast_atof( const char* c, const char** cout)
 {
 {
 	float ret;
 	float ret;
-	*cout = fast_atof_move(c, ret);
+	*cout = fast_atoreal_move<float>(c, ret);
 
 
 	return ret;
 	return ret;
 }
 }
@@ -294,7 +300,32 @@ inline float fast_atof( const char* c, const char** cout)
 inline float fast_atof( const char** inout)
 inline float fast_atof( const char** inout)
 {
 {
 	float ret;
 	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;
 	return ret;
 }
 }