Browse Source

use cmath and C++ (std::) versions of functions

Eshed 9 years ago
parent
commit
25cda401c5

+ 2 - 2
code/AssxmlExporter.cpp

@@ -299,7 +299,7 @@ void WriteDump(const aiScene* scene, IOStream* io, bool shortened) {
             else if (!shortened){
             else if (!shortened){
                 ioprintf(io,"\t\t<Data length=\"%i\"> \n",tex->mWidth*tex->mHeight*4);
                 ioprintf(io,"\t\t<Data length=\"%i\"> \n",tex->mWidth*tex->mHeight*4);
 
 
-                // const unsigned int width = (unsigned int)log10((double)std::max(tex->mHeight,tex->mWidth))+1;
+                // const unsigned int width = (unsigned int)std::log10((double)std::max(tex->mHeight,tex->mWidth))+1;
                 for (unsigned int y = 0; y < tex->mHeight;++y) {
                 for (unsigned int y = 0; y < tex->mHeight;++y) {
                     for (unsigned int x = 0; x < tex->mWidth;++x) {
                     for (unsigned int x = 0; x < tex->mWidth;++x) {
                         aiTexel* tx = tex->pcData + y*tex->mWidth+x;
                         aiTexel* tx = tex->pcData + y*tex->mWidth+x;
@@ -457,7 +457,7 @@ void WriteDump(const aiScene* scene, IOStream* io, bool shortened) {
         ioprintf(io,"<MeshList num=\"%i\">\n",scene->mNumMeshes);
         ioprintf(io,"<MeshList num=\"%i\">\n",scene->mNumMeshes);
         for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
         for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
             aiMesh* mesh = scene->mMeshes[i];
             aiMesh* mesh = scene->mMeshes[i];
-            // const unsigned int width = (unsigned int)log10((double)mesh->mNumVertices)+1;
+            // const unsigned int width = (unsigned int)std::log10((double)mesh->mNumVertices)+1;
 
 
             // mesh header
             // mesh header
             ioprintf(io,"\t<Mesh types=\"%s %s %s %s\" material_index=\"%i\">\n",
             ioprintf(io,"\t<Mesh types=\"%s %s %s %s\" material_index=\"%i\">\n",

+ 1 - 1
code/BlenderLoader.cpp

@@ -1143,7 +1143,7 @@ aiCamera* BlenderImporter::ConvertCamera(const Scene& /*in*/, const Object* obj,
     out->mUp = aiVector3D(0.f, 1.f, 0.f);
     out->mUp = aiVector3D(0.f, 1.f, 0.f);
     out->mLookAt = aiVector3D(0.f, 0.f, -1.f);
     out->mLookAt = aiVector3D(0.f, 0.f, -1.f);
     if (cam->sensor_x && cam->lens) {
     if (cam->sensor_x && cam->lens) {
-        out->mHorizontalFOV = atan2(cam->sensor_x,  2.f * cam->lens);
+        out->mHorizontalFOV = std::atan2(cam->sensor_x,  2.f * cam->lens);
     }
     }
     out->mClipPlaneNear = cam->clipsta;
     out->mClipPlaneNear = cam->clipsta;
     out->mClipPlaneFar = cam->clipend;
     out->mClipPlaneFar = cam->clipend;

+ 4 - 4
code/ColladaLoader.cpp

@@ -420,13 +420,13 @@ void ColladaLoader::BuildCamerasForNode( const ColladaParser& pParser, const Col
             out->mHorizontalFOV = srcCamera->mHorFov;
             out->mHorizontalFOV = srcCamera->mHorFov;
 
 
             if (srcCamera->mVerFov != 10e10f && srcCamera->mAspect == 10e10f) {
             if (srcCamera->mVerFov != 10e10f && srcCamera->mAspect == 10e10f) {
-                out->mAspect = tan(AI_DEG_TO_RAD(srcCamera->mHorFov)) /
-                    tan(AI_DEG_TO_RAD(srcCamera->mVerFov));
+                out->mAspect = std::tan(AI_DEG_TO_RAD(srcCamera->mHorFov)) /
+                    std::tan(AI_DEG_TO_RAD(srcCamera->mVerFov));
             }
             }
         }
         }
         else if (srcCamera->mAspect != 10e10f && srcCamera->mVerFov != 10e10f)  {
         else if (srcCamera->mAspect != 10e10f && srcCamera->mVerFov != 10e10f)  {
-            out->mHorizontalFOV = 2.0f * AI_RAD_TO_DEG(atan(srcCamera->mAspect *
-                tan(AI_DEG_TO_RAD(srcCamera->mVerFov) * 0.5f)));
+            out->mHorizontalFOV = 2.0f * AI_RAD_TO_DEG(std::atan(srcCamera->mAspect *
+                std::tan(AI_DEG_TO_RAD(srcCamera->mVerFov) * 0.5f)));
         }
         }
 
 
         // Collada uses degrees, we use radians
         // Collada uses degrees, we use radians

+ 3 - 3
code/FixNormalsStep.cpp

@@ -148,9 +148,9 @@ bool FixInfacingNormalsProcess::ProcessMesh( aiMesh* pcMesh, unsigned int index)
     // Check whether this is a planar surface
     // Check whether this is a planar surface
     const float fDelta1_yz = fDelta1_y * fDelta1_z;
     const float fDelta1_yz = fDelta1_y * fDelta1_z;
 
 
-    if (fDelta1_x < 0.05f * sqrtf( fDelta1_yz ))return false;
-    if (fDelta1_y < 0.05f * sqrtf( fDelta1_z * fDelta1_x ))return false;
-    if (fDelta1_z < 0.05f * sqrtf( fDelta1_y * fDelta1_x ))return false;
+    if (fDelta1_x < 0.05f * std::sqrt( fDelta1_yz ))return false;
+    if (fDelta1_y < 0.05f * std::sqrt( fDelta1_z * fDelta1_x ))return false;
+    if (fDelta1_z < 0.05f * std::sqrt( fDelta1_y * fDelta1_x ))return false;
 
 
     // now compare the volumes of the bounding boxes
     // now compare the volumes of the bounding boxes
     if (std::fabs(fDelta0_x * fDelta0_y * fDelta0_z) <
     if (std::fabs(fDelta0_x * fDelta0_y * fDelta0_z) <

+ 1 - 1
code/LWOAnimation.cpp

@@ -160,7 +160,7 @@ void AnimResolver::UpdateAnimRangeSetup()
             case LWO::PrePostBehaviour_Repeat:
             case LWO::PrePostBehaviour_Repeat:
             case LWO::PrePostBehaviour_Oscillate:
             case LWO::PrePostBehaviour_Oscillate:
                 {
                 {
-                const double start_time = delta - fmod(my_first-first,delta);
+                const double start_time = delta - std::fmod(my_first-first,delta);
                 std::vector<LWO::Key>::iterator n = std::find_if((*it).keys.begin(),(*it).keys.end(),
                 std::vector<LWO::Key>::iterator n = std::find_if((*it).keys.begin(),(*it).keys.end(),
                     std::bind1st(std::greater<double>(),start_time)),m;
                     std::bind1st(std::greater<double>(),start_time)),m;
 
 

+ 1 - 1
code/LWOMaterial.cpp

@@ -851,7 +851,7 @@ void LWOImporter::LoadLWO2Surface(unsigned int size)
         case AI_LWO_SMAN:
         case AI_LWO_SMAN:
             {
             {
                 AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,SMAN,4);
                 AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,SMAN,4);
-                surf.mMaximumSmoothAngle = fabs( GetF4() );
+                surf.mMaximumSmoothAngle = std::fabs( GetF4() );
                 break;
                 break;
             }
             }
             // vertex color channel to be applied to the surface
             // vertex color channel to be applied to the surface

+ 2 - 2
code/SIBImporter.cpp

@@ -710,8 +710,8 @@ static void ReadLightInfo(aiLight* light, StreamReaderLE* stream)
     //    OpenGL: I = cos(angle)^E
     //    OpenGL: I = cos(angle)^E
     //   Solving: angle = acos(I^(1/E))
     //   Solving: angle = acos(I^(1/E))
     ai_real E = 1.0 / std::max(spotExponent, (ai_real)0.00001);
     ai_real E = 1.0 / std::max(spotExponent, (ai_real)0.00001);
-    ai_real inner = acos(pow((ai_real)0.99, E));
-    ai_real outer = acos(pow((ai_real)0.01, E));
+    ai_real inner = std::acos(std::pow((ai_real)0.99, E));
+    ai_real outer = std::acos(std::pow((ai_real)0.01, E));
 
 
     // Apply the cutoff.
     // Apply the cutoff.
     outer = std::min(outer, AI_DEG_TO_RAD(spotCutoff));
     outer = std::min(outer, AI_DEG_TO_RAD(spotCutoff));

+ 1 - 1
code/X3DImporter.cpp

@@ -796,7 +796,7 @@ void X3DImporter::GeometryHelper_Make_Arc2D(const float pStartAngle, const float
     }
     }
 
 
 	// calculate arc angle and check type of arc
 	// calculate arc angle and check type of arc
-	float angle_full = fabs(pEndAngle - pStartAngle);
+	float angle_full = std::fabs(pEndAngle - pStartAngle);
     if ( ( angle_full > AI_MATH_TWO_PI_F ) || ( angle_full == 0.0f ) )
     if ( ( angle_full > AI_MATH_TWO_PI_F ) || ( angle_full == 0.0f ) )
     {
     {
         angle_full = AI_MATH_TWO_PI_F;
         angle_full = AI_MATH_TWO_PI_F;

+ 1 - 1
code/X3DImporter_Geometry2D.cpp

@@ -157,7 +157,7 @@ void X3DImporter::ParseNode_Geometry2D_ArcClose2D()
 		// create point list of geometry object.
 		// create point list of geometry object.
 		GeometryHelper_Make_Arc2D(startAngle, endAngle, radius, 10, ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices);///TODO: IME - AI_CONFIG for NumSeg
 		GeometryHelper_Make_Arc2D(startAngle, endAngle, radius, 10, ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices);///TODO: IME - AI_CONFIG for NumSeg
 		// add chord or two radiuses only if not a circle was defined
 		// add chord or two radiuses only if not a circle was defined
-		if(!((fabs(endAngle - startAngle) >= AI_MATH_TWO_PI_F) || (endAngle == startAngle)))
+		if(!((std::fabs(endAngle - startAngle) >= AI_MATH_TWO_PI_F) || (endAngle == startAngle)))
 		{
 		{
 			std::list<aiVector3D>& vlist = ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices;// just short alias.
 			std::list<aiVector3D>& vlist = ((CX3DImporter_NodeElement_Geometry2D*)ne)->Vertices;// just short alias.
 
 

+ 1 - 1
code/XGLLoader.cpp

@@ -501,7 +501,7 @@ aiMatrix4x4 XGLImporter::ReadTrafo()
     up.Normalize();
     up.Normalize();
 
 
     right = forward ^ up;
     right = forward ^ up;
-    if (fabs(up * forward) > 1e-4) {
+    if (std::fabs(up * forward) > 1e-4) {
         // this is definitely wrong - a degenerate coordinate space ruins everything
         // this is definitely wrong - a degenerate coordinate space ruins everything
         // so subtitute identity transform.
         // so subtitute identity transform.
         LogError("<forward> and <up> vectors in <transform> are skewing, ignoring trafo");
         LogError("<forward> and <up> vectors in <transform> are skewing, ignoring trafo");

+ 9 - 9
include/assimp/matrix4x4.inl

@@ -367,21 +367,21 @@ inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector
 	// Use a small epsilon to solve floating-point inaccuracies
 	// Use a small epsilon to solve floating-point inaccuracies
     const TReal epsilon = 10e-3f;
     const TReal epsilon = 10e-3f;
 
 
-	pRotation.y  = asin(vCols[2].x);// D. Angle around oY.
+	pRotation.y  = std::asin(vCols[2].x);// D. Angle around oY.
 
 
-	TReal C = cos(pRotation.y);
+	TReal C = std::cos(pRotation.y);
 
 
-	if(fabs(C) > epsilon)
+	if(std::fabs(C) > epsilon)
 	{
 	{
 		// Finding angle around oX.
 		// Finding angle around oX.
 		TReal tan_x =  vCols[2].z / C;// A
 		TReal tan_x =  vCols[2].z / C;// A
 		TReal tan_y = -vCols[2].y / C;// B
 		TReal tan_y = -vCols[2].y / C;// B
 
 
-		pRotation.x = atan2(tan_y, tan_x);
+		pRotation.x = std::atan2(tan_y, tan_x);
 		// Finding angle around oZ.
 		// Finding angle around oZ.
 		tan_x =  vCols[0].x / C;// E
 		tan_x =  vCols[0].x / C;// E
 		tan_y = -vCols[1].x / C;// F
 		tan_y = -vCols[1].x / C;// F
-		pRotation.z = atan2(tan_y, tan_x);
+		pRotation.z = std::atan2(tan_y, tan_x);
 	}
 	}
 	else
 	else
 	{// oY is fixed.
 	{// oY is fixed.
@@ -391,7 +391,7 @@ inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector
 		TReal tan_x = vCols[1].y;// -BDF+AE => E
 		TReal tan_x = vCols[1].y;// -BDF+AE => E
 		TReal tan_y = vCols[0].y;//  BDE+AF => F
 		TReal tan_y = vCols[0].y;//  BDE+AF => F
 
 
-		pRotation.z = atan2(tan_y, tan_x);
+		pRotation.z = std::atan2(tan_y, tan_x);
 	}
 	}
 }
 }
 
 
@@ -407,14 +407,14 @@ aiQuaterniont<TReal> pRotation;
 	pRotation.Normalize();
 	pRotation.Normalize();
 
 
 	TReal angle_cos = pRotation.w;
 	TReal angle_cos = pRotation.w;
-	TReal angle_sin = sqrt(1.0f - angle_cos * angle_cos);
+	TReal angle_sin = std::sqrt(1.0f - angle_cos * angle_cos);
 
 
-	pRotationAngle = acos(angle_cos) * 2;
+	pRotationAngle = std::acos(angle_cos) * 2;
 
 
 	// Use a small epsilon to solve floating-point inaccuracies
 	// Use a small epsilon to solve floating-point inaccuracies
     const TReal epsilon = 10e-3f;
     const TReal epsilon = 10e-3f;
 
 
-	if(fabs(angle_sin) < epsilon) angle_sin = 1;
+	if(std::fabs(angle_sin) < epsilon) angle_sin = 1;
 
 
 	pRotationAxis.x = pRotation.x / angle_sin;
 	pRotationAxis.x = pRotation.x / angle_sin;
 	pRotationAxis.y = pRotation.y / angle_sin;
 	pRotationAxis.y = pRotation.y / angle_sin;

+ 0 - 1
include/assimp/types.h

@@ -48,7 +48,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 // Some runtime headers
 // Some runtime headers
 #include <sys/types.h>
 #include <sys/types.h>
-#include <math.h>
 #include <stddef.h>
 #include <stddef.h>
 #include <string.h>
 #include <string.h>
 #include <limits.h>
 #include <limits.h>