33namespace sofa ::collisionalgorithm::Operations::Needle
44{
55
6+ // Returns true when at least one coupling point was popped from the back,
7+ // false when the set was left unchanged (including the null-edge error path
8+ // and the non-retracting early-exit).
69bool prunePointsUsingEdges (std::vector<BaseProximity::SPtr>& couplingPts,
710 const EdgeElement::SPtr& edge)
811{
@@ -16,11 +19,11 @@ bool prunePointsUsingEdges(std::vector<BaseProximity::SPtr>& couplingPts,
1619 const type::Vec3 tip (edge->getP1 ()->getPosition ());
1720 const type::Vec3 edgeDirection = tip - edgeBase;
1821
19- // Only prune if the tip is retracting (moving against the insertion direction).
20- // NOTE: This uses the needle tip velocity only. If retraction results from needle-tissue
22+ // Only prune if the tip is retracting (moving against the insertion direction).
23+ // NOTE: This uses the needle tip velocity only. If retraction results from needle-tissue
2124 // relative movement, retraction is not detected.
2225 const type::Vec3 tipVelocity = edge->getP1 ()->getVelocity ();
23- if (dot (tipVelocity, edgeDirection) >= 0_sreal) return true ;
26+ if (dot (tipVelocity, edgeDirection) >= 0_sreal) return false ;
2427
2528 const int initSize = couplingPts.size ();
2629
@@ -32,7 +35,7 @@ bool prunePointsUsingEdges(std::vector<BaseProximity::SPtr>& couplingPts,
3235 if (dot (tip2Pt, edgeDirection) < 0_sreal) break ;
3336 couplingPts.pop_back ();
3437 }
35- return (initSize == couplingPts.size ());
38+ return (couplingPts.size () < initSize );
3639}
3740
3841int register_PrunePointsAheadOfTip_Edge =
0 commit comments