mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-24 13:50:49 +03:00
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.
This commit is contained in:
@@ -931,7 +931,7 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::Matches (SelectBasics_Selecti
|
|||||||
{
|
{
|
||||||
myDetectedNodeMap->ChangeMap().Unite (aChild->myDetectedNodeMap->Map());
|
myDetectedNodeMap->ChangeMap().Unite (aChild->myDetectedNodeMap->Map());
|
||||||
}
|
}
|
||||||
if (thePickResult.Depth() > aPickResult.Depth())
|
if (thePickResult.Depth() > aPickResult.Depth() && thePickResult.IsDirectHit())
|
||||||
{
|
{
|
||||||
myDetectedIdx = aGroupIter;
|
myDetectedIdx = aGroupIter;
|
||||||
thePickResult = aPickResult;
|
thePickResult = aPickResult;
|
||||||
|
@@ -111,7 +111,7 @@ Standard_Boolean Select3D_SensitiveSet::processElements (SelectBasics_SelectingV
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thePickResult.Depth() > aPickResult.Depth())
|
if ((thePickResult.Depth() > aPickResult.Depth()) && (aPickResult.IsDirectHit()))
|
||||||
{
|
{
|
||||||
thePickResult = aPickResult;
|
thePickResult = aPickResult;
|
||||||
myDetectedIdx = anIdx;
|
myDetectedIdx = anIdx;
|
||||||
|
@@ -35,7 +35,8 @@ public:
|
|||||||
SelectBasics_PickResult()
|
SelectBasics_PickResult()
|
||||||
: myObjPickedPnt (RealLast(), 0.0, 0.0),
|
: myObjPickedPnt (RealLast(), 0.0, 0.0),
|
||||||
myDepth (RealLast()),
|
myDepth (RealLast()),
|
||||||
myDistToCenter (RealLast()) {}
|
myDistToCenter (RealLast()),
|
||||||
|
myIsDirectHit(Standard_False) {}
|
||||||
|
|
||||||
//! Constructor with initialization.
|
//! Constructor with initialization.
|
||||||
SelectBasics_PickResult (Standard_Real theDepth,
|
SelectBasics_PickResult (Standard_Real theDepth,
|
||||||
@@ -43,7 +44,8 @@ public:
|
|||||||
const gp_Pnt& theObjPickedPnt)
|
const gp_Pnt& theObjPickedPnt)
|
||||||
: myObjPickedPnt (theObjPickedPnt),
|
: myObjPickedPnt (theObjPickedPnt),
|
||||||
myDepth (theDepth),
|
myDepth (theDepth),
|
||||||
myDistToCenter (theDistToCenter) {}
|
myDistToCenter (theDistToCenter),
|
||||||
|
myIsDirectHit(Standard_False) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -56,6 +58,7 @@ public:
|
|||||||
myDepth = RealLast();
|
myDepth = RealLast();
|
||||||
myObjPickedPnt = gp_Pnt (RealLast(), 0.0, 0.0);
|
myObjPickedPnt = gp_Pnt (RealLast(), 0.0, 0.0);
|
||||||
myNormal.SetValues (0.0f, 0.0f, 0.0f);
|
myNormal.SetValues (0.0f, 0.0f, 0.0f);
|
||||||
|
myIsDirectHit = Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Return depth along picking ray.
|
//! Return depth along picking ray.
|
||||||
@@ -93,11 +96,18 @@ public:
|
|||||||
myNormal.SetValues ((float )theNormal.X(), (float )theNormal.Y(), (float )theNormal.Z());
|
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:
|
private:
|
||||||
gp_Pnt myObjPickedPnt; //!< User-picked selection point onto object
|
gp_Pnt myObjPickedPnt; //!< User-picked selection point onto object
|
||||||
NCollection_Vec3<float> myNormal; //!< surface normal
|
NCollection_Vec3<float> myNormal; //!< surface normal
|
||||||
Standard_Real myDepth; //!< Depth to detected point
|
Standard_Real myDepth; //!< Depth to detected point
|
||||||
Standard_Real myDistToCenter; //!< Distance from 3d projection user-picked selection point to entity's geometry center
|
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
|
#endif // _SelectBasics_PickResult_HeaderFile
|
||||||
|
@@ -84,8 +84,7 @@ void SelectMgr_RectangularFrustum::segmentSegmentDistance (const gp_Pnt& theSegP
|
|||||||
aTc = (Abs (aTd) < gp::Resolution() ? 0.0 : aTn / aTd);
|
aTc = (Abs (aTd) < gp::Resolution() ? 0.0 : aTn / aTd);
|
||||||
|
|
||||||
const gp_Pnt aClosestPnt = myNearPickedPnt.XYZ() + aV * aTc;
|
const gp_Pnt aClosestPnt = myNearPickedPnt.XYZ() + aV * aTc;
|
||||||
Standard_Real aPenalty = Max(aC/anA, anA/aC);
|
thePickResult.SetDepth (myNearPickedPnt.Distance (aClosestPnt) * myScale);
|
||||||
thePickResult.SetDepth (myNearPickedPnt.Distance (aClosestPnt) * myScale * aPenalty);
|
|
||||||
|
|
||||||
const gp_Vec aPickedVec = aClosestPnt.XYZ() - theSegPnt1.XYZ();
|
const gp_Vec aPickedVec = aClosestPnt.XYZ() - theSegPnt1.XYZ();
|
||||||
const gp_Vec aFigureVec = theSegPnt2.XYZ() - theSegPnt1.XYZ();
|
const gp_Vec aFigureVec = theSegPnt2.XYZ() - theSegPnt1.XYZ();
|
||||||
@@ -504,6 +503,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsBox (const SelectMgr_Vec3
|
|||||||
|
|
||||||
aDepth = aNearestPnt.Distance (myNearPickedPnt);
|
aDepth = aNearestPnt.Distance (myNearPickedPnt);
|
||||||
thePickResult.SetDepth (aDepth);
|
thePickResult.SetDepth (aDepth);
|
||||||
|
thePickResult.SetDirectHit(Standard_False);
|
||||||
return !theClipRange.IsClipped (thePickResult.Depth());
|
return !theClipRange.IsClipped (thePickResult.Depth());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,6 +516,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsBox (const SelectMgr_Vec3
|
|||||||
}
|
}
|
||||||
|
|
||||||
thePickResult.SetDepth (aDepth);
|
thePickResult.SetDepth (aDepth);
|
||||||
|
thePickResult.SetDirectHit(Standard_True);
|
||||||
|
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
@@ -539,6 +540,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsPoint (const gp_Pnt& theP
|
|||||||
|
|
||||||
thePickResult.SetDepth (Abs (aDepth) * myScale);
|
thePickResult.SetDepth (Abs (aDepth) * myScale);
|
||||||
thePickResult.SetPickedPoint (thePnt);
|
thePickResult.SetPickedPoint (thePnt);
|
||||||
|
thePickResult.SetDirectHit(Standard_True);
|
||||||
|
|
||||||
return !theClipRange.IsClipped (thePickResult.Depth());
|
return !theClipRange.IsClipped (thePickResult.Depth());
|
||||||
}
|
}
|
||||||
@@ -571,6 +573,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsSegment (const gp_Pnt& th
|
|||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
|
||||||
segmentSegmentDistance (thePnt1, thePnt2, thePickResult);
|
segmentSegmentDistance (thePnt1, thePnt2, thePickResult);
|
||||||
|
thePickResult.SetDirectHit(Standard_True);
|
||||||
|
|
||||||
return !theClipRange.IsClipped (thePickResult.Depth());
|
return !theClipRange.IsClipped (thePickResult.Depth());
|
||||||
}
|
}
|
||||||
@@ -606,6 +609,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsPolygon (const TColgp_Arr
|
|||||||
aMatchingSegmentsNb++;
|
aMatchingSegmentsNb++;
|
||||||
segmentSegmentDistance (aStartPnt, aEndPnt, aPickResult);
|
segmentSegmentDistance (aStartPnt, aEndPnt, aPickResult);
|
||||||
thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
|
thePickResult = SelectBasics_PickResult::Min (thePickResult, aPickResult);
|
||||||
|
thePickResult.SetDirectHit(Standard_True);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -711,9 +715,10 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsTriangle (const gp_Pnt& t
|
|||||||
thePickResult.SetDepth (myNearPickedPnt.Distance (aPtOnPlane) * myScale);
|
thePickResult.SetDepth (myNearPickedPnt.Distance (aPtOnPlane) * myScale);
|
||||||
thePickResult.SetPickedPoint (aPtOnPlane);
|
thePickResult.SetPickedPoint (aPtOnPlane);
|
||||||
thePickResult.SetSurfaceNormal (aTriangleNormal);
|
thePickResult.SetSurfaceNormal (aTriangleNormal);
|
||||||
|
thePickResult.SetDirectHit(Standard_True);
|
||||||
return !theClipRange.IsClipped (thePickResult.Depth());
|
return !theClipRange.IsClipped (thePickResult.Depth());
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Real aMinDist = RealLast();
|
Standard_Real aMinDist = RealLast();
|
||||||
Standard_Integer aNearestEdgeIdx1 = -1;
|
Standard_Integer aNearestEdgeIdx1 = -1;
|
||||||
for (Standard_Integer anEdgeIdx = 0; anEdgeIdx < 3; ++anEdgeIdx)
|
for (Standard_Integer anEdgeIdx = 0; anEdgeIdx < 3; ++anEdgeIdx)
|
||||||
@@ -736,6 +741,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsTriangle (const gp_Pnt& t
|
|||||||
}
|
}
|
||||||
thePickResult.SetSurfaceNormal (aTriangleNormal);
|
thePickResult.SetSurfaceNormal (aTriangleNormal);
|
||||||
segmentSegmentDistance (aPnts[aNearestEdgeIdx1], aPnts[aNearestEdgeIdx2], thePickResult);
|
segmentSegmentDistance (aPnts[aNearestEdgeIdx1], aPnts[aNearestEdgeIdx2], thePickResult);
|
||||||
|
thePickResult.SetDirectHit(Standard_False);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !theClipRange.IsClipped (thePickResult.Depth());
|
return !theClipRange.IsClipped (thePickResult.Depth());
|
||||||
@@ -786,6 +792,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsCylinder (const Standard_
|
|||||||
thePickResult.SetSurfaceNormal (gp_Vec (aPntOnCylinder.X(), aPntOnCylinder.Y(), 0.0).Transformed (theTrsf));
|
thePickResult.SetSurfaceNormal (gp_Vec (aPntOnCylinder.X(), aPntOnCylinder.Y(), 0.0).Transformed (theTrsf));
|
||||||
}
|
}
|
||||||
thePickResult.SetPickedPoint (aPntOnCylinder.Transformed (theTrsf));
|
thePickResult.SetPickedPoint (aPntOnCylinder.Transformed (theTrsf));
|
||||||
|
thePickResult.SetDirectHit(Standard_True);
|
||||||
return !theClipRange.IsClipped (thePickResult.Depth());
|
return !theClipRange.IsClipped (thePickResult.Depth());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -822,6 +829,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsCircle (const Standard_Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
thePickResult.SetDepth (aTime * myScale);
|
thePickResult.SetDepth (aTime * myScale);
|
||||||
|
thePickResult.SetDirectHit(Standard_True);
|
||||||
if (theClipRange.IsClipped (thePickResult.Depth()))
|
if (theClipRange.IsClipped (thePickResult.Depth()))
|
||||||
{
|
{
|
||||||
thePickResult.SetDepth (aTime * myScale);
|
thePickResult.SetDepth (aTime * myScale);
|
||||||
@@ -1011,6 +1019,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsSphere (const gp_Pnt& the
|
|||||||
}
|
}
|
||||||
|
|
||||||
thePickResult.SetDepth (aTimeEnter * myScale);
|
thePickResult.SetDepth (aTimeEnter * myScale);
|
||||||
|
thePickResult.SetDirectHit(Standard_True);
|
||||||
if (theClipRange.IsClipped (thePickResult.Depth()))
|
if (theClipRange.IsClipped (thePickResult.Depth()))
|
||||||
{
|
{
|
||||||
thePickResult.SetDepth (aTimeLeave * myScale);
|
thePickResult.SetDepth (aTimeLeave * myScale);
|
||||||
|
Reference in New Issue
Block a user