Skip to content

Commit

Permalink
use std:: namespace for most cmath functions:
Browse files Browse the repository at this point in the history
  • Loading branch information
abma committed Sep 22, 2014
1 parent b359deb commit 775b26e
Show file tree
Hide file tree
Showing 33 changed files with 156 additions and 161 deletions.
4 changes: 2 additions & 2 deletions code/BlenderTessellator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ void BlenderTessellatorP2T::Copy3DVertices( const MLoop* polyLoop, int vertexCou
aiMatrix4x4 BlenderTessellatorP2T::GeneratePointTransformMatrix( const Blender::PlaneP2T& plane ) const
{
aiVector3D sideA( 1.0f, 0.0f, 0.0f );
if ( fabs( plane.normal * sideA ) > 0.999f )
if ( std::fabs( plane.normal * sideA ) > 0.999f )
{
sideA = aiVector3D( 0.0f, 1.0f, 0.0f );
}
Expand Down Expand Up @@ -420,7 +420,7 @@ float BlenderTessellatorP2T::FindLargestMatrixElem( const aiMatrix3x3& mtx ) con
{
for ( int y = 0; y < 3; ++y )
{
result = p2tMax( fabs( mtx[ x ][ y ] ), result );
result = p2tMax( std::fabs( mtx[ x ][ y ] ), result );
}
}

Expand Down
2 changes: 1 addition & 1 deletion code/ColladaLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ void ColladaLoader::BuildLightsForNode( const ColladaParser& pParser, const Coll
{
// Need to rely on falloff_exponent. I don't know how to interpret it, so I need to guess ....
// epsilon chosen to be 0.1
out->mAngleOuterCone = AI_DEG_TO_RAD (acos(pow(0.1f,1.f/srcLight->mFalloffExponent))+
out->mAngleOuterCone = AI_DEG_TO_RAD (std::acos(std::pow(0.1f,1.f/srcLight->mFalloffExponent))+
srcLight->mFalloffAngle);
}
else {
Expand Down
6 changes: 3 additions & 3 deletions code/ComputeUVMappingProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,23 +207,23 @@ void ComputeUVMappingProcess::ComputeSphereMapping(aiMesh* mesh,const aiVector3D
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,
(asin (diff.x) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.f);
(std::asin (diff.x) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.f);
}
}
else if (axis * base_axis_y >= angle_epsilon) {
// ... 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,
(asin (diff.y) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.f);
(std::asin (diff.y) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.f);
}
}
else if (axis * base_axis_z >= angle_epsilon) {
// ... 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,
(asin (diff.z) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.f);
(std::asin (diff.z) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.f);
}
}
// slower code path in case the mapping axis is not one of the coordinate system axes
Expand Down
10 changes: 5 additions & 5 deletions code/FBXConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,15 +497,15 @@ class Converter
bool is_id[3] = { true, true, true };

aiMatrix4x4 temp[3];
if(fabs(rotation.z) > angle_epsilon) {
if(std::fabs(rotation.z) > angle_epsilon) {
aiMatrix4x4::RotationZ(AI_DEG_TO_RAD(rotation.z),temp[2]);
is_id[2] = false;
}
if(fabs(rotation.y) > angle_epsilon) {
if(std::fabs(rotation.y) > angle_epsilon) {
aiMatrix4x4::RotationY(AI_DEG_TO_RAD(rotation.y),temp[1]);
is_id[1] = false;
}
if(fabs(rotation.x) > angle_epsilon) {
if(std::fabs(rotation.x) > angle_epsilon) {
aiMatrix4x4::RotationX(AI_DEG_TO_RAD(rotation.x),temp[0]);
is_id[0] = false;
}
Expand Down Expand Up @@ -674,7 +674,7 @@ class Converter
}

const aiVector3D& Scaling = PropertyGet<aiVector3D>(props,"Lcl Scaling",ok);
if(ok && fabs(Scaling.SquareLength()-1.0f) > zero_epsilon) {
if(ok && std::fabs(Scaling.SquareLength()-1.0f) > zero_epsilon) {
aiMatrix4x4::Scaling(Scaling,chain[TransformationComp_Scaling]);
}

Expand All @@ -684,7 +684,7 @@ class Converter
}

const aiVector3D& GeometricScaling = PropertyGet<aiVector3D>(props, "GeometricScaling", ok);
if (ok && fabs(GeometricScaling.SquareLength() - 1.0f) > zero_epsilon) {
if (ok && std::fabs(GeometricScaling.SquareLength() - 1.0f) > zero_epsilon) {
aiMatrix4x4::Scaling(GeometricScaling, chain[TransformationComp_GeometricScaling]);
}

Expand Down
2 changes: 1 addition & 1 deletion code/FindInvalidDataProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ AI_FORCE_INLINE bool EpsilonCompare(const T& n, const T& s, float epsilon);

// ------------------------------------------------------------------------------------------------
AI_FORCE_INLINE bool EpsilonCompare(float n, float s, float epsilon) {
return fabs(n-s)>epsilon;
return std::fabs(n-s)>epsilon;
}

// ------------------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions code/FixNormalsStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ bool FixInfacingNormalsProcess::ProcessMesh( aiMesh* pcMesh, unsigned int index)
if (fDelta1_z < 0.05f * sqrtf( fDelta1_y * fDelta1_x ))return false;

// now compare the volumes of the bounding boxes
if (::fabsf(fDelta0_x * fDelta1_yz) <
::fabsf(fDelta1_x * fDelta1_y * fDelta1_z))
if (std::fabs(fDelta0_x * fDelta1_yz) <
std::fabs(fDelta1_x * fDelta1_y * fDelta1_z))
{
if (!DefaultLogger::isNullLogger())
{
Expand Down
2 changes: 1 addition & 1 deletion code/GenVertexNormalsProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int
// Slower code path if a smooth angle is set. There are many ways to achieve
// the effect, this one is the most straightforward one.
else {
const float fLimit = ::cos(configMaxAngle);
const float fLimit = std::cos(configMaxAngle);
for (unsigned int i = 0; i < pMesh->mNumVertices;++i) {
// Get all vertices that share this one ...
vertexFinder->FindPositions( pMesh->mVertices[i] , posEpsilon, verticesFound);
Expand Down
10 changes: 5 additions & 5 deletions code/IFCBoolean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ Intersect IntersectSegmentPlane(const IfcVector3& p,const IfcVector3& n, const I
const IfcVector3 pdelta = e0 - p, seg = e1-e0;
const IfcFloat dotOne = n*seg, dotTwo = -(n*pdelta);

if (fabs(dotOne) < 1e-6) {
return fabs(dotTwo) < 1e-6f ? Intersect_LiesOnPlane : Intersect_No;
if (std::fabs(dotOne) < 1e-6) {
return std::fabs(dotTwo) < 1e-6f ? Intersect_LiesOnPlane : Intersect_No;
}

const IfcFloat t = dotTwo/dotOne;
Expand Down Expand Up @@ -210,7 +210,7 @@ bool IntersectsBoundaryProfile( const IfcVector3& e0, const IfcVector3& e1, cons
// segment-segment intersection
// solve b0 + b*s = e0 + e*t for (s,t)
const IfcFloat det = (-b.x * e.y + e.x * b.y);
if(fabs(det) < 1e-6) {
if(std::fabs(det) < 1e-6) {
// no solutions (parallel lines)
continue;
}
Expand All @@ -234,7 +234,7 @@ bool IntersectsBoundaryProfile( const IfcVector3& e0, const IfcVector3& e1, cons
if (t >= -epsilon && (t <= 1.0+epsilon || half_open) && s >= -epsilon && s <= 1.0) {

if (e0_hits_border && !*e0_hits_border) {
*e0_hits_border = fabs(t) < 1e-5f;
*e0_hits_border = std::fabs(t) < 1e-5f;
}

const IfcVector3& p = e0 + e*t;
Expand Down Expand Up @@ -419,7 +419,7 @@ void ProcessPolygonalBoundedBooleanHalfSpaceDifference(const IfcPolygonalBounded

#ifdef ASSIMP_BUILD_DEBUG
if (isect == Intersect_Yes) {
const IfcFloat f = fabs((isectpos - p)*n);
const IfcFloat f = std::fabs((isectpos - p)*n);
ai_assert(f < 1e-5);
}
#endif
Expand Down
24 changes: 12 additions & 12 deletions code/IFCCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ class Conic : public Curve
a *= conv.angle_scale;
b *= conv.angle_scale;

a = fmod(a,static_cast<IfcFloat>( AI_MATH_TWO_PI ));
b = fmod(b,static_cast<IfcFloat>( AI_MATH_TWO_PI ));
a = std::fmod(a,static_cast<IfcFloat>( AI_MATH_TWO_PI ));
b = std::fmod(b,static_cast<IfcFloat>( AI_MATH_TWO_PI ));
const IfcFloat setting = static_cast<IfcFloat>( AI_MATH_PI * conv.settings.conicSamplingAngle / 180.0 );
return static_cast<size_t>( ceil(abs( b-a)) / setting);
return static_cast<size_t>( std::ceil(abs( b-a)) / setting);
}

// --------------------------------------------------
Expand Down Expand Up @@ -124,8 +124,8 @@ class Circle : public Conic
// --------------------------------------------------
IfcVector3 Eval(IfcFloat u) const {
u = -conv.angle_scale * u;
return location + static_cast<IfcFloat>(entity.Radius)*(static_cast<IfcFloat>(::cos(u))*p[0] +
static_cast<IfcFloat>(::sin(u))*p[1]);
return location + static_cast<IfcFloat>(entity.Radius)*(static_cast<IfcFloat>(std::cos(u))*p[0] +
static_cast<IfcFloat>(std::sin(u))*p[1]);
}

private:
Expand Down Expand Up @@ -153,8 +153,8 @@ class Ellipse : public Conic
// --------------------------------------------------
IfcVector3 Eval(IfcFloat u) const {
u = -conv.angle_scale * u;
return location + static_cast<IfcFloat>(entity.SemiAxis1)*static_cast<IfcFloat>(::cos(u))*p[0] +
static_cast<IfcFloat>(entity.SemiAxis2)*static_cast<IfcFloat>(::sin(u))*p[1];
return location + static_cast<IfcFloat>(entity.SemiAxis1)*static_cast<IfcFloat>(std::cos(u))*p[0] +
static_cast<IfcFloat>(entity.SemiAxis2)*static_cast<IfcFloat>(std::sin(u))*p[1];
}

private:
Expand Down Expand Up @@ -486,7 +486,7 @@ class PolyLine : public BoundedCurve
IfcVector3 Eval(IfcFloat p) const {
ai_assert(InRange(p));

const size_t b = static_cast<size_t>(floor(p));
const size_t b = static_cast<size_t>(std::floor(p));
if (b == points.size()-1) {
return points.back();
}
Expand All @@ -498,7 +498,7 @@ class PolyLine : public BoundedCurve
// --------------------------------------------------
size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const {
ai_assert(InRange(a) && InRange(b));
return static_cast<size_t>( ceil(b) - floor(a) );
return static_cast<size_t>( std::ceil(b) - std::floor(a) );
}

// --------------------------------------------------
Expand Down Expand Up @@ -558,7 +558,7 @@ bool Curve :: InRange(IfcFloat u) const
if (IsClosed()) {
return true;
//ai_assert(range.first != std::numeric_limits<IfcFloat>::infinity() && range.second != std::numeric_limits<IfcFloat>::infinity());
//u = range.first + fmod(u-range.first,range.second-range.first);
//u = range.first + std::fmod(u-range.first,range.second-range.first);
}
const IfcFloat epsilon = 1e-5;
return u - range.first > -epsilon && range.second - u > -epsilon;
Expand Down Expand Up @@ -606,12 +606,12 @@ IfcFloat RecursiveSearch(const Curve* cv, const IfcVector3& val, IfcFloat a, Ifc
}

ai_assert(min_diff[0] != inf && min_diff[1] != inf);
if ( fabs(a-min_point[0]) < threshold || recurse >= max_recurse) {
if ( std::fabs(a-min_point[0]) < threshold || recurse >= max_recurse) {
return min_point[0];
}

// fix for closed curves to take their wrap-over into account
if (cv->IsClosed() && fabs(min_point[0]-min_point[1]) > cv->GetParametricRangeDelta()*0.5 ) {
if (cv->IsClosed() && std::fabs(min_point[0]-min_point[1]) > cv->GetParametricRangeDelta()*0.5 ) {
const Curve::ParamRange& range = cv->GetParametricRange();
const IfcFloat wrapdiff = (cv->Eval(range.first)-val).SquareLength();

Expand Down
8 changes: 4 additions & 4 deletions code/IFCGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,17 @@ void ProcessRevolvedAreaSolid(const IfcRevolvedAreaSolid& solid, TempMesh& resul

bool has_area = solid.SweptArea->ProfileType == "AREA" && size>2;
const IfcFloat max_angle = solid.Angle*conv.angle_scale;
if(fabs(max_angle) < 1e-3) {
if(std::fabs(max_angle) < 1e-3) {
if(has_area) {
result = meshout;
}
return;
}

const unsigned int cnt_segments = std::max(2u,static_cast<unsigned int>(16 * fabs(max_angle)/AI_MATH_HALF_PI_F));
const unsigned int cnt_segments = std::max(2u,static_cast<unsigned int>(16 * std::fabs(max_angle)/AI_MATH_HALF_PI_F));
const IfcFloat delta = max_angle/cnt_segments;

has_area = has_area && fabs(max_angle) < AI_MATH_TWO_PI_F*0.99;
has_area = has_area && std::fabs(max_angle) < AI_MATH_TWO_PI_F*0.99;

result.verts.reserve(size*((cnt_segments+1)*4+(has_area?2:0)));
result.vertcnt.reserve(size*cnt_segments+2);
Expand Down Expand Up @@ -480,7 +480,7 @@ IfcMatrix3 DerivePlaneCoordinateSpace(const TempMesh& curmesh, bool& ok, IfcVect
for (i = 0; !done && i < s-2; done || ++i) {
for (j = i+1; j < s-1; ++j) {
nor = -((out[i]-any_point)^(out[j]-any_point));
if(fabs(nor.Length()) > 1e-8f) {
if(std::fabs(nor.Length()) > 1e-8f) {
done = true;
break;
}
Expand Down
Loading

0 comments on commit 775b26e

Please sign in to comment.