From a84bf869c2e82454bbc498c03df87c98973731d2 Mon Sep 17 00:00:00 2001 From: Eshed Date: Sat, 15 Oct 2016 12:05:57 +0300 Subject: [PATCH] replace more math.h functions occurences with std:: --- code/CalcTangentsProcess.cpp | 2 +- code/ColladaLoader.cpp | 2 +- code/ComputeUVMappingProcess.cpp | 18 +++++++++--------- code/MD3FileData.h | 4 ++-- code/X3DImporter.cpp | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/code/CalcTangentsProcess.cpp b/code/CalcTangentsProcess.cpp index dbba1be..c13ffcb 100644 --- a/code/CalcTangentsProcess.cpp +++ b/code/CalcTangentsProcess.cpp @@ -256,7 +256,7 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) } std::vector verticesFound; - const float fLimit = cosf(configMaxAngle); + const float fLimit = std::cos(configMaxAngle); std::vector closeVertices; // in the second pass we now smooth out all tangents and bitangents at the same local position diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 4f463f2..681f996 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -1181,7 +1181,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars const ai_real last_eval_angle = last_key_angle + (cur_key_angle - last_key_angle) * (time - last_key_time) / (cur_key_time - last_key_time); const ai_real delta = std::abs(cur_key_angle - last_eval_angle); if (delta >= 180.0) { - const int subSampleCount = static_cast(floorf(delta / 90.0)); + const int subSampleCount = static_cast(std::floor(delta / 90.0)); if (cur_key_time != time) { const ai_real nextSampleTime = time + (cur_key_time - time) / subSampleCount; nextTime = std::min(nextTime, nextSampleTime); diff --git a/code/ComputeUVMappingProcess.cpp b/code/ComputeUVMappingProcess.cpp index ff5142f..b7c1ffc 100644 --- a/code/ComputeUVMappingProcess.cpp +++ b/code/ComputeUVMappingProcess.cpp @@ -206,7 +206,7 @@ void ComputeUVMappingProcess::ComputeSphereMapping(aiMesh* mesh,const aiVector3D // lon = arctan (y/x) for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D diff = (mesh->mVertices[pnt]-center).Normalize(); - out[pnt] = aiVector3D((atan2 (diff.z, diff.y) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, + out[pnt] = aiVector3D((std::atan2(diff.z, diff.y) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, (std::asin (diff.x) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.0); } } @@ -214,7 +214,7 @@ void ComputeUVMappingProcess::ComputeSphereMapping(aiMesh* mesh,const aiVector3D // ... just the same again for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D diff = (mesh->mVertices[pnt]-center).Normalize(); - out[pnt] = aiVector3D((atan2 (diff.x, diff.z) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, + out[pnt] = aiVector3D((std::atan2(diff.x, diff.z) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, (std::asin (diff.y) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.0); } } @@ -222,7 +222,7 @@ void ComputeUVMappingProcess::ComputeSphereMapping(aiMesh* mesh,const aiVector3D // ... just the same again for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D diff = (mesh->mVertices[pnt]-center).Normalize(); - out[pnt] = aiVector3D((atan2 (diff.y, diff.x) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, + out[pnt] = aiVector3D((std::atan2(diff.y, diff.x) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, (std::asin (diff.z) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.0); } } @@ -234,8 +234,8 @@ void ComputeUVMappingProcess::ComputeSphereMapping(aiMesh* mesh,const aiVector3D // again the same, except we're applying a transformation now for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D diff = ((mTrafo*mesh->mVertices[pnt])-center).Normalize(); - out[pnt] = aiVector3D((atan2 (diff.y, diff.x) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, - (asin (diff.z) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.0); + out[pnt] = aiVector3D((std::atan2(diff.y, diff.x) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, + (std::asin(diff.z) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.0); } } @@ -268,7 +268,7 @@ void ComputeUVMappingProcess::ComputeCylinderMapping(aiMesh* mesh,const aiVector aiVector3D& uv = out[pnt]; uv.y = (pos.x - min.x) / diff; - uv.x = (atan2 ( pos.z - center.z, pos.y - center.y) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; + uv.x = (std::atan2( pos.z - center.z, pos.y - center.y) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; } } else if (axis * base_axis_y >= angle_epsilon) { @@ -281,7 +281,7 @@ void ComputeUVMappingProcess::ComputeCylinderMapping(aiMesh* mesh,const aiVector aiVector3D& uv = out[pnt]; uv.y = (pos.y - min.y) / diff; - uv.x = (atan2 ( pos.x - center.x, pos.z - center.z) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; + uv.x = (std::atan2( pos.x - center.x, pos.z - center.z) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; } } else if (axis * base_axis_z >= angle_epsilon) { @@ -294,7 +294,7 @@ void ComputeUVMappingProcess::ComputeCylinderMapping(aiMesh* mesh,const aiVector aiVector3D& uv = out[pnt]; uv.y = (pos.z - min.z) / diff; - uv.x = (atan2 ( pos.y - center.y, pos.x - center.x) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; + uv.x = (std::atan2( pos.y - center.y, pos.x - center.x) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; } } // slower code path in case the mapping axis is not one of the coordinate system axes @@ -310,7 +310,7 @@ void ComputeUVMappingProcess::ComputeCylinderMapping(aiMesh* mesh,const aiVector aiVector3D& uv = out[pnt]; uv.y = (pos.y - min.y) / diff; - uv.x = (atan2 ( pos.x - center.x, pos.z - center.z) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; + uv.x = (std::atan2( pos.x - center.x, pos.z - center.z) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; } } diff --git a/code/MD3FileData.h b/code/MD3FileData.h index 51a5739..a886926 100644 --- a/code/MD3FileData.h +++ b/code/MD3FileData.h @@ -298,10 +298,10 @@ inline void Vec3NormalToLatLng( const aiVector3D& p_vIn, uint16_t& p_iOut ) { int a, b; - a = int(57.2957795f * ( atan2f( p_vIn[1], p_vIn[0] ) ) * (255.0f / 360.0f )); + a = int(57.2957795f * ( std::atan2( p_vIn[1], p_vIn[0] ) ) * (255.0f / 360.0f )); a &= 0xff; - b = int(57.2957795f * ( acosf( p_vIn[2] ) ) * ( 255.0f / 360.0f )); + b = int(57.2957795f * ( std::acos( p_vIn[2] ) ) * ( 255.0f / 360.0f )); b &= 0xff; ((unsigned char*)&p_iOut)[0] = b; // longitude diff --git a/code/X3DImporter.cpp b/code/X3DImporter.cpp index a14d87d..0d2d99f 100644 --- a/code/X3DImporter.cpp +++ b/code/X3DImporter.cpp @@ -775,7 +775,7 @@ void X3DImporter::XML_ReadNode_GetAttrVal_AsListS(const int pAttrIdx, std::list< aiVector3D X3DImporter::GeometryHelper_Make_Point2D(const float pAngle, const float pRadius) { - return aiVector3D(pRadius * cosf(pAngle), pRadius * sinf(pAngle), 0); + return aiVector3D(pRadius * std::cos(pAngle), pRadius * std::sin(pAngle), 0); } void X3DImporter::GeometryHelper_Make_Arc2D(const float pStartAngle, const float pEndAngle, const float pRadius, size_t pNumSegments, -- 2.7.4