diff --git a/vcg/space/box3.h b/vcg/space/box3.h index 62bd4fcc..93fa769d 100644 --- a/vcg/space/box3.h +++ b/vcg/space/box3.h @@ -387,22 +387,22 @@ ScalarType DistancePoint3Box3(const Point3 &p, const ScalarType dx = std::min(b.max.X()-p.X(), p.X()-b.min.X()); const ScalarType dy = std::min(b.max.Y()-p.Y(), p.Y()-b.min.Y()); const ScalarType dz = std::min(b.max.Z()-p.Z(), p.Z()-b.min.Z()); - + return std::min(dx, std::min(dy, dz)); } - - { - ScalarType sq_dist = ScalarType(0); - for (int i=0; i<3; ++i) - { - ScalarType delta = ScalarType(0); - if (p[i] < b.min[i]) delta = p[i] - b.min[i]; - else if (p[i] > b.max[i]) delta = p[i] - b.max[i]; - sq_dist += delta * delta; - } - - return Sqrt(sq_dist); - } + + { + ScalarType sq_dist = ScalarType(0); + for (int i=0; i<3; ++i) + { + ScalarType delta = ScalarType(0); + if (p[i] < b.min[i]) delta = p[i] - b.min[i]; + else if (p[i] > b.max[i]) delta = p[i] - b.max[i]; + sq_dist += delta * delta; + } + + return math::Sqrt(sq_dist); + } }