]> OCCT Git - occt.git/commitdiff
0031798: Visualization, SelectMgr_ViewerSelector - fix comparing depth of direct...
authordrochalo <diogo.lopes@opencascade.com>
Fri, 29 Sep 2023 10:38:49 +0000 (11:38 +0100)
committerdrochalo <diogo.lopes@opencascade.com>
Fri, 29 Sep 2023 10:38:49 +0000 (11:38 +0100)
Added bias to the depth test made for indirect hits.

src/SelectMgr/SelectMgr_RectangularFrustum.cxx

index 0031c5f2756598ef82f52e123067468b503946bf..9c4c52e9fe3ab17eec5b49dd63e50f28f53a428c 100644 (file)
@@ -84,7 +84,8 @@ void SelectMgr_RectangularFrustum::segmentSegmentDistance (const gp_Pnt& theSegP
   aTc = (Abs (aTd) < gp::Resolution() ? 0.0 : aTn / aTd);
 
   const gp_Pnt aClosestPnt = myNearPickedPnt.XYZ() + aV * aTc;
-  thePickResult.SetDepth (myNearPickedPnt.Distance (aClosestPnt) * myScale);
+  Standard_Real aPenalty = Max(aC/anA, anA/aC);
+  thePickResult.SetDepth (myNearPickedPnt.Distance (aClosestPnt) * myScale * aPenalty);
 
   const gp_Vec aPickedVec = aClosestPnt.XYZ() - theSegPnt1.XYZ();
   const gp_Vec aFigureVec = theSegPnt2.XYZ()  - theSegPnt1.XYZ();
@@ -733,8 +734,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsTriangle (const gp_Pnt& t
     {
       aNearestEdgeIdx2 = aNearestEdgeIdx1 == 0 ? 2 : aNearestEdgeIdx1 - 1;
     }
-    segmentSegmentDistance (aPnts[aNearestEdgeIdx1], aPnts[aNearestEdgeIdx2], thePickResult);
     thePickResult.SetSurfaceNormal (aTriangleNormal);
+    segmentSegmentDistance (aPnts[aNearestEdgeIdx1], aPnts[aNearestEdgeIdx2], thePickResult);
   }
 
   return !theClipRange.IsClipped (thePickResult.Depth());