diff --git a/src/BVH/BVH_Box.hxx b/src/BVH/BVH_Box.hxx index 6f808d31f5..2bae241ffe 100644 --- a/src/BVH/BVH_Box.hxx +++ b/src/BVH/BVH_Box.hxx @@ -427,11 +427,11 @@ struct SurfaceCalculator { static T Area(const typename BVH_Box::BVH_VecNt& theSize) { - const T anArea = theSize.x() * theSize.y(); + const T anArea = std::abs(theSize.x() * theSize.y()); if (anArea < std::numeric_limits::epsilon()) { - return theSize.x() + theSize.y(); + return std::abs(theSize.x()) + std::abs(theSize.y()); } return anArea; @@ -443,13 +443,13 @@ struct SurfaceCalculator { static T Area(const typename BVH_Box::BVH_VecNt& theSize) { - const T anArea = - (theSize.x() * theSize.y() + theSize.x() * theSize.z() + theSize.z() * theSize.y()) - * static_cast(2.0); + const T anArea = (std::abs(theSize.x() * theSize.y()) + std::abs(theSize.x() * theSize.z()) + + std::abs(theSize.z() * theSize.y())) + * static_cast(2.0); if (anArea < std::numeric_limits::epsilon()) { - return theSize.x() + theSize.y() + theSize.z(); + return std::abs(theSize.x()) + std::abs(theSize.y()) + std::abs(theSize.z()); } return anArea; @@ -461,13 +461,13 @@ struct SurfaceCalculator { static T Area(const typename BVH_Box::BVH_VecNt& theSize) { - const T anArea = - (theSize.x() * theSize.y() + theSize.x() * theSize.z() + theSize.z() * theSize.y()) - * static_cast(2.0); + const T anArea = (std::abs(theSize.x() * theSize.y()) + std::abs(theSize.x() * theSize.z()) + + std::abs(theSize.z() * theSize.y())) + * static_cast(2.0); if (anArea < std::numeric_limits::epsilon()) { - return theSize.x() + theSize.y() + theSize.z(); + return std::abs(theSize.x()) + std::abs(theSize.y()) + std::abs(theSize.z()); } return anArea;