From 1017656a61b3f84994869936384980974a09472b Mon Sep 17 00:00:00 2001 From: ponchio Date: Thu, 15 Jul 2010 19:37:59 +0000 Subject: [PATCH] returned closest point was wrong. --- vcg/space/index/aabb_binary_tree/closest.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vcg/space/index/aabb_binary_tree/closest.h b/vcg/space/index/aabb_binary_tree/closest.h index 285e143b..a9dd6b55 100644 --- a/vcg/space/index/aabb_binary_tree/closest.h +++ b/vcg/space/index/aabb_binary_tree/closest.h @@ -128,12 +128,15 @@ public: ScalarType closestDist = math::Sqrt(minMaxDist) + std::numeric_limits::epsilon(); ScalarType closestDistSq = closestDist * closestDist; + for (NodePtrVector_ci ci=leaves.begin(); ci!=leaves.end(); ++ci) { if ((*ci)->ScalarValue() < closestDistSq) { for (typename TreeType::ObjPtrVectorConstIterator si=(*ci)->oBegin; si!=(*ci)->oEnd; ++si) { if (getPointDistance(*(*si), p, closestDist, closestPoint)) { closestDistSq = closestDist * closestDist; closestObject = (*si); + q = closestPoint; + minDist = closestDist; } } } @@ -141,9 +144,6 @@ public: leaves.clear(); - q = closestPoint; - minDist = closestDist; - return (closestObject); }