1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

Compare commits

...

2 Commits

Author SHA1 Message Date
drochalo
514d047df7 0031798: Visualization, SelectMgr_ViewerSelector - fix comparing depth of direct and indirect triangle hits
Replaced bias approach to depth test criterion to instead use bool that marks if a hit was direct or not. The bool is used in processing elements and in matching methods.
2023-10-03 09:52:42 +01:00
drochalo
8bc5b0f89e 0031798: Visualization, SelectMgr_ViewerSelector - fix comparing depth of direct and indirect triangle hits
Added bias to the depth test made for indirect hits.
2023-09-29 11:38:49 +01:00
4 changed files with 26 additions and 6 deletions

View File

@@ -931,7 +931,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti
{
myDetectedNodeMap->ChangeMap().Unite (aChild->myDetectedNodeMap->Map());
}
if (thePickResult.Depth() > aPickResult.Depth())
if (thePickResult.Depth() > aPickResult.Depth() && thePickResult.IsDirectHit())
{
myDetectedIdx = aGroupIter;
thePickResult = aPickResult;

View File

@@ -111,7 +111,7 @@ Standard_Boolean Select3D_SensitiveSet::processElements (SelectBasics_SelectingV
continue;
}
if (thePickResult.Depth() > aPickResult.Depth())
if ((thePickResult.Depth() > aPickResult.Depth()) && (aPickResult.IsDirectHit()))
{
thePickResult = aPickResult;
myDetectedIdx = anIdx;

View File

@@ -35,7 +35,8 @@ public:
SelectBasics_PickResult()
: myObjPickedPnt (RealLast(), 0.0, 0.0),
myDepth (RealLast()),
myDistToCenter (RealLast()) {}
myDistToCenter (RealLast()),
myIsDirectHit(Standard_False) {}
//! Constructor with initialization.
SelectBasics_PickResult (Standard_Real theDepth,
@@ -43,7 +44,8 @@ public:
const gp_Pnt& theObjPickedPnt)
: myObjPickedPnt (theObjPickedPnt),
myDepth (theDepth),
myDistToCenter (theDistToCenter) {}
myDistToCenter (theDistToCenter),
myIsDirectHit(Standard_False) {}
public:
@@ -56,6 +58,7 @@ public:
myDepth = RealLast();
myObjPickedPnt = gp_Pnt (RealLast(), 0.0, 0.0);
myNormal.SetValues (0.0f, 0.0f, 0.0f);
myIsDirectHit = Standard_False;
}
//! Return depth along picking ray.
@@ -93,11 +96,18 @@ public:
myNormal.SetValues ((float )theNormal.X(), (float )theNormal.Y(), (float )theNormal.Z());
}
//! Set boolean value for pick result direct hit (true) or indirect hit (false)
void SetDirectHit(Standard_Boolean theIsDirectHit) { myIsDirectHit = theIsDirectHit; }
//! Return value for direct hit test
Standard_Boolean IsDirectHit() const { return myIsDirectHit; }
private:
gp_Pnt myObjPickedPnt; //!< User-picked selection point onto object
NCollection_Vec3<float> myNormal; //!< surface normal
Standard_Real myDepth; //!< Depth to detected point
Standard_Real myDistToCenter; //!< Distance from 3d projection user-picked selection point to entity's geometry center
Standard_Boolean myIsDirectHit; //!< Checks if the detected point was obtained from a direct hit
};
#endif // _SelectBasics_PickResult_HeaderFile

View File

@@ -503,6 +503,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsBox (const SelectMgr_Vec3
aDepth = aNearestPnt.Distance (myNearPickedPnt);
thePickResult.SetDepth (aDepth);
thePickResult.SetDirectHit(Standard_False);
return !theClipRange.IsClipped (thePickResult.Depth());
}
@@ -515,6 +516,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsBox (const SelectMgr_Vec3
}
thePickResult.SetDepth (aDepth);
thePickResult.SetDirectHit(Standard_True);
return Standard_True;
}
@@ -538,6 +540,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsPoint (const gp_Pnt& theP
thePickResult.SetDepth (Abs (aDepth) * myScale);
thePickResult.SetPickedPoint (thePnt);
thePickResult.SetDirectHit(Standard_True);
return !theClipRange.IsClipped (thePickResult.Depth());
}
@@ -570,6 +573,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsSegment (const gp_Pnt& th
return Standard_False;
segmentSegmentDistance (thePnt1, thePnt2, thePickResult);
thePickResult.SetDirectHit(Standard_True);
return !theClipRange.IsClipped (thePickResult.Depth());
}
@@ -605,6 +609,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsPolygon (const TColgp_Arr
aMatchingSegmentsNb++;
segmentSegmentDistance (aStartPnt, aEndPnt, aPickResult);
thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
thePickResult.SetDirectHit(Standard_True);
}
}
@@ -710,9 +715,10 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsTriangle (const gp_Pnt& t
thePickResult.SetDepth (myNearPickedPnt.Distance (aPtOnPlane) * myScale);
thePickResult.SetPickedPoint (aPtOnPlane);
thePickResult.SetSurfaceNormal (aTriangleNormal);
thePickResult.SetDirectHit(Standard_True);
return !theClipRange.IsClipped (thePickResult.Depth());
}
Standard_Real aMinDist = RealLast();
Standard_Integer aNearestEdgeIdx1 = -1;
for (Standard_Integer anEdgeIdx = 0; anEdgeIdx < 3; ++anEdgeIdx)
@@ -733,8 +739,9 @@ 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);
thePickResult.SetDirectHit(Standard_False);
}
return !theClipRange.IsClipped (thePickResult.Depth());
@@ -785,6 +792,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsCylinder (const Standard_
thePickResult.SetSurfaceNormal (gp_Vec (aPntOnCylinder.X(), aPntOnCylinder.Y(), 0.0).Transformed (theTrsf));
}
thePickResult.SetPickedPoint (aPntOnCylinder.Transformed (theTrsf));
thePickResult.SetDirectHit(Standard_True);
return !theClipRange.IsClipped (thePickResult.Depth());
}
@@ -821,6 +829,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsCircle (const Standard_Re
}
thePickResult.SetDepth (aTime * myScale);
thePickResult.SetDirectHit(Standard_True);
if (theClipRange.IsClipped (thePickResult.Depth()))
{
thePickResult.SetDepth (aTime * myScale);
@@ -1010,6 +1019,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsSphere (const gp_Pnt& the
}
thePickResult.SetDepth (aTimeEnter * myScale);
thePickResult.SetDirectHit(Standard_True);
if (theClipRange.IsClipped (thePickResult.Depth()))
{
thePickResult.SetDepth (aTimeLeave * myScale);