Skip to content

Commit ee940a4

Browse files
committed
[operations] Fix operation removing only one coupling point per time step
1 parent 3e29573 commit ee940a4

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/sofa/collisionAlgorithm/operations/NeedleOperations.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,19 @@ bool prunePointsUsingEdges(std::vector<BaseProximity::SPtr>& couplingPts,
1414
}
1515
const type::Vec3 edgeBase(edge->getP0()->getPosition());
1616
const type::Vec3 tip(edge->getP1()->getPosition());
17-
1817
const type::Vec3 edgeDirection = tip - edgeBase;
1918

20-
if (couplingPts.empty()) return false;
21-
const type::Vec3 tip2Pt = couplingPts.back()->getPosition() - tip;
19+
const int initSize = couplingPts.size();
2220

23-
// Positive dot product means the point is ahead of the tip
24-
if (dot(tip2Pt, edgeDirection) > 0_sreal)
21+
while(!couplingPts.empty())
2522
{
23+
const type::Vec3 tip2Pt = couplingPts.back()->getPosition() - tip;
24+
25+
// Negative dot product means the point is behind the tip
26+
if(dot(tip2Pt, edgeDirection) < 0_sreal) break;
2627
couplingPts.pop_back();
27-
return true;
2828
}
29-
30-
return false;
29+
return (initSize == couplingPts.size());
3130
}
3231

3332
int register_PrunePointsAheadOfTip_Edge =

0 commit comments

Comments
 (0)