Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/CollisionAlgorithm/operations/NeedleOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace sofa::collisionalgorithm::Operations::Needle
bool prunePointsUsingEdges(std::vector<BaseProximity::SPtr>& couplingPts,
const EdgeElement::SPtr& edge)
{
if (!edge)
if (!edge)
{
msg_warning("Needle::PrunePointsAheadOfTip")
<< "Null element pointer in prunePointsUsingEdges; returning false";
Expand All @@ -16,6 +16,12 @@ bool prunePointsUsingEdges(std::vector<BaseProximity::SPtr>& couplingPts,
const type::Vec3 tip(edge->getP1()->getPosition());
const type::Vec3 edgeDirection = tip - edgeBase;

// Only prune if the tip is retracting (moving against the insertion direction).
// NOTE: This uses the needle tip velocity only. If retraction results from needle-tissue
// relative movement, retraction is not detected.
const type::Vec3 tipVelocity = edge->getP1()->getVelocity();
if (dot(tipVelocity, edgeDirection) >= 0_sreal) return true;
Comment thread
th-skam marked this conversation as resolved.
Outdated

const int initSize = couplingPts.size();

while(!couplingPts.empty())
Expand Down
Loading