Skip to content

Commit 25d0db3

Browse files
committed
[operations] Invert bool return from pruning operations
1 parent 0c15a9e commit 25d0db3

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/CollisionAlgorithm/operations/NeedleOperations.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
namespace 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).
69
bool 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

3841
int register_PrunePointsAheadOfTip_Edge =

0 commit comments

Comments
 (0)