From: drochalo Date: Fri, 29 Sep 2023 10:38:49 +0000 (+0100) Subject: 0031798: Visualization, SelectMgr_ViewerSelector - fix comparing depth of direct... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=8bc5b0f89e83b8463d502bb67f9e1f2e033049f2;p=occt.git 0031798: Visualization, SelectMgr_ViewerSelector - fix comparing depth of direct and indirect triangle hits Added bias to the depth test made for indirect hits. --- diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx index 0031c5f275..9c4c52e9fe 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx @@ -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());