From 8b866c9c47002e7474b5787d9906cca798c6cd99 Mon Sep 17 00:00:00 2001 From: David Williams Date: Thu, 5 Jan 2012 21:01:23 +0000 Subject: [PATCH] Changed abs() to std::abs() in a few places. --- .../include/PolyVoxCore/AStarPathfinder.inl | 8 ++++---- .../include/PolyVoxCore/CubicSurfaceExtractor.inl | 2 +- library/PolyVoxCore/include/PolyVoxCore/Raycast.inl | 12 ++++++------ .../include/PolyVoxCore/RaycastWithCallback.inl | 12 ++++++------ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/AStarPathfinder.inl b/library/PolyVoxCore/include/PolyVoxCore/AStarPathfinder.inl index 54a5a826..76262eb1 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/AStarPathfinder.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/AStarPathfinder.inl @@ -249,7 +249,7 @@ namespace PolyVox float AStarPathfinder::SixConnectedCost(const Vector3DInt32& a, const Vector3DInt32& b) { //This is the only heuristic I'm sure of - just use the manhatten distance for the 6-connected case. - uint32_t faceSteps = abs(a.getX()-b.getX()) + abs(a.getY()-b.getY()) + abs(a.getZ()-b.getZ()); + uint32_t faceSteps = std::abs(a.getX()-b.getX()) + std::abs(a.getY()-b.getY()) + std::abs(a.getZ()-b.getZ()); return faceSteps * 1.0f; } @@ -270,9 +270,9 @@ namespace PolyVox //Can't say I'm certain about this heuristic - if anyone has //a better idea of what it should be then please let me know. uint32_t array[3]; - array[0] = abs(a.getX() - b.getX()); - array[1] = abs(a.getY() - b.getY()); - array[2] = abs(a.getZ() - b.getZ()); + array[0] = std::abs(a.getX() - b.getX()); + array[1] = std::abs(a.getY() - b.getY()); + array[2] = std::abs(a.getZ() - b.getZ()); //Maybe this is better implemented directly //using three compares and two swaps... but not diff --git a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl index 3e63752a..84993133 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl @@ -302,7 +302,7 @@ namespace PolyVox { //All four vertices of a given quad have the same material, //so just check that the first pair or vertices match. - if(fabs(m_meshCurrent->getVertices()[q1.vertices[0]].getMaterial() - m_meshCurrent->getVertices()[q2.vertices[0]].getMaterial()) < 0.001) + if(std::abs(m_meshCurrent->getVertices()[q1.vertices[0]].getMaterial() - m_meshCurrent->getVertices()[q2.vertices[0]].getMaterial()) < 0.001) { //Now check whether quad 2 is adjacent to quad one by comparing vertices. //Adjacent quads must share two vertices, and the second quad could be to the diff --git a/library/PolyVoxCore/include/PolyVoxCore/Raycast.inl b/library/PolyVoxCore/include/PolyVoxCore/Raycast.inl index c5ec65b3..30285305 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Raycast.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Raycast.inl @@ -123,15 +123,15 @@ namespace PolyVox int dk = ((z1 < z2) ? 1 : ((z1 > z2) ? -1 : 0)); float minx = floorf(x1), maxx = minx + 1.0f; - float tx = ((x1 > x2) ? (x1 - minx) : (maxx - x1)) / abs(x2 - x1); + float tx = ((x1 > x2) ? (x1 - minx) : (maxx - x1)) / std::abs(x2 - x1); float miny = floorf(y1), maxy = miny + 1.0f; - float ty = ((y1 > y2) ? (y1 - miny) : (maxy - y1)) / abs(y2 - y1); + float ty = ((y1 > y2) ? (y1 - miny) : (maxy - y1)) / std::abs(y2 - y1); float minz = floorf(z1), maxz = minz + 1.0f; - float tz = ((z1 > z2) ? (z1 - minz) : (maxz - z1)) / abs(z2 - z1); + float tz = ((z1 > z2) ? (z1 - minz) : (maxz - z1)) / std::abs(z2 - z1); - float deltatx = 1.0f / abs(x2 - x1); - float deltaty = 1.0f / abs(y2 - y1); - float deltatz = 1.0f / abs(z2 - z1); + float deltatx = 1.0f / std::abs(x2 - x1); + float deltaty = 1.0f / std::abs(y2 - y1); + float deltatz = 1.0f / std::abs(z2 - z1); m_sampVolume.setPosition(i,j,k); m_result.previousVoxel = Vector3DInt32(i,j,k); diff --git a/library/PolyVoxCore/include/PolyVoxCore/RaycastWithCallback.inl b/library/PolyVoxCore/include/PolyVoxCore/RaycastWithCallback.inl index 4e29cff5..1527a710 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RaycastWithCallback.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RaycastWithCallback.inl @@ -108,15 +108,15 @@ namespace PolyVox int dk = ((z1 < z2) ? 1 : ((z1 > z2) ? -1 : 0)); float minx = floorf(x1), maxx = minx + 1.0f; - float tx = ((x1 > x2) ? (x1 - minx) : (maxx - x1)) / abs(x2 - x1); + float tx = ((x1 > x2) ? (x1 - minx) : (maxx - x1)) / std::abs(x2 - x1); float miny = floorf(y1), maxy = miny + 1.0f; - float ty = ((y1 > y2) ? (y1 - miny) : (maxy - y1)) / abs(y2 - y1); + float ty = ((y1 > y2) ? (y1 - miny) : (maxy - y1)) / std::abs(y2 - y1); float minz = floorf(z1), maxz = minz + 1.0f; - float tz = ((z1 > z2) ? (z1 - minz) : (maxz - z1)) / abs(z2 - z1); + float tz = ((z1 > z2) ? (z1 - minz) : (maxz - z1)) / std::abs(z2 - z1); - float deltatx = 1.0f / abs(x2 - x1); - float deltaty = 1.0f / abs(y2 - y1); - float deltatz = 1.0f / abs(z2 - z1); + float deltatx = 1.0f / std::abs(x2 - x1); + float deltaty = 1.0f / std::abs(y2 - y1); + float deltatz = 1.0f / std::abs(z2 - z1); m_sampVolume.setPosition(i,j,k);