Skip to content

Commit 3104014

Browse files
committed
[algorithm] Finding location of last CP relies on shaft edge direction instead of tipToLastCP
1 parent 5dc6427 commit 3104014

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,17 +243,17 @@ class InsertionAlgorithm : public BaseAlgorithm
243243

244244
const type::Vec3 p0 = edgeProx->element()->getP0()->getPosition();
245245
const type::Vec3 p1 = edgeProx->element()->getP1()->getPosition();
246+
const type::Vec3 shaftEdgeDir = (p1 - p0).normalized();
247+
const type::Vec3 lastCPToP1 = p1 - lastCP;
246248

247-
// Candidate coupling point along shaft segment
248-
const type::Vec3 candidateCP =
249-
lastCP + tipDistThreshold * (p1 - lastCP).normalized();
249+
// Skip if last CP lies after edge end point
250+
if (dot(shaftEdgeDir, lastCPToP1) < 0_sreal) continue;
250251

251-
// Skip if candidate CP lies before the last CP
252-
if (dot(tipToLastCP, (candidateCP - lastCP)) > 0_sreal) continue;
252+
// Candidate coupling point along shaft segment
253+
const type::Vec3 candidateCP = lastCP + tipDistThreshold * shaftEdgeDir;
253254

254255
// Project candidate CP onto the edge element and compute scalar coordinate
255256
// along segment
256-
const type::Vec3 shaftEdgeDir = (p1 - p0).normalized();
257257
const SReal edgeSegmentLength = (p1 - p0).norm();
258258
const type::Vec3 p0ToCandidateCP = candidateCP - p0;
259259
const SReal projPtOnEdge = dot(p0ToCandidateCP, shaftEdgeDir);

0 commit comments

Comments
 (0)