File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
src/sofa/collisionAlgorithm/algorithm Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff 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);
You can’t perform that action at this time.
0 commit comments