0029938: Visualization - SelectMgr_ViewerSelector::PickedPoint() should return point...
[occt.git] / src / Select3D / Select3D_SensitiveSet.cxx
index 88d3ded..df7f996 100644 (file)
@@ -76,7 +76,6 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
 {
   myDetectedIdx = -1;
   const BVH_Tree<Standard_Real, 3, BVH_BinaryTree>* aBVH = myContent.GetBVH().get();
-  thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
   if (myContent.Size() < 1 || !theMgr.Overlaps (aBVH->MinPoint (0),
                                                 aBVH->MaxPoint (0)))
   {
@@ -88,7 +87,7 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
   Standard_Integer aHead = -1;
 
   Standard_Integer aMatchesNb = -1;
-  Standard_Real    aMinDepth  = RealLast();
+  SelectBasics_PickResult aPickResult;
   for (;;)
   {
     const BVH_Vec4i& aData = aBVH->NodeInfoBuffer()[aNode];
@@ -150,16 +149,14 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
         }
         else // overlap test
         {
-          Standard_Real aCurrentDepth = aMinDepth;
-
-          if (!overlapsElement (theMgr, anElemIdx, aCurrentDepth))
+          if (!overlapsElement (theMgr, anElemIdx, aPickResult))
           {
             continue;
           }
 
-          if (aMinDepth > aCurrentDepth)
+          if (thePickResult.Depth() > aPickResult.Depth())
           {
-            aMinDepth = aCurrentDepth;
+            thePickResult = aPickResult;
             myDetectedIdx = anElemIdx;
           }
 
@@ -176,7 +173,7 @@ Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeMan
 
   if (aMatchesNb != -1)
   {
-    thePickResult = SelectBasics_PickResult (aMinDepth, distanceToCOG (theMgr));
+    thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
   }
 
   return !theMgr.IsOverlapAllowed() || aMatchesNb != -1;