Skip to content

Commit efc42ff

Browse files
committed
[algorithm] switched the order of coupling point removal and addition
* no reason to simultaneously add and remove coupling points
1 parent 6248993 commit efc42ff

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,20 +186,8 @@ class InsertionAlgorithm : public BaseAlgorithm
186186
Operations::CreateCenterProximity::Operation::get(itTip->getTypeInfo());
187187
const BaseProximity::SPtr tipProx = createTipProximity(itTip->element());
188188

189-
ElementIterator::SPtr itShaft = l_shaftGeom->begin(l_shaftGeom->getSize() - 2);
190-
auto createShaftProximity =
191-
Operations::CreateCenterProximity::Operation::get(itShaft->getTypeInfo());
192-
const BaseProximity::SPtr shaftProx = createShaftProximity(itShaft->element());
193-
const EdgeProximity::SPtr edgeProx = dynamic_pointer_cast<EdgeProximity>(shaftProx);
194-
const type::Vec3 normal = (edgeProx->element()->getP1()->getPosition() -
195-
edgeProx->element()->getP0()->getPosition())
196-
.normalized();
197189
const type::Vec3 ab = m_couplingPts.back()->getPosition() - tipProx->getPosition();
198-
const SReal dotProd = dot(ab, normal);
199-
if (dotProd > 0.0) m_couplingPts.pop_back();
200-
201-
const SReal dist = ab.norm();
202-
if (dist > d_tipDistThreshold.getValue())
190+
if (ab.norm() > d_tipDistThreshold.getValue())
203191
{
204192
auto findClosestProxOnVol =
205193
Operations::FindClosestProximity::Operation::get(l_volGeom);
@@ -212,6 +200,19 @@ class InsertionAlgorithm : public BaseAlgorithm
212200
m_couplingPts.push_back(volProx);
213201
}
214202
}
203+
else // Don't bother with removing the point that was just added
204+
{
205+
ElementIterator::SPtr itShaft = l_shaftGeom->begin(l_shaftGeom->getSize() - 2);
206+
auto createShaftProximity =
207+
Operations::CreateCenterProximity::Operation::get(itShaft->getTypeInfo());
208+
const BaseProximity::SPtr shaftProx = createShaftProximity(itShaft->element());
209+
const EdgeProximity::SPtr edgeProx = dynamic_pointer_cast<EdgeProximity>(shaftProx);
210+
const type::Vec3 normal = (edgeProx->element()->getP1()->getPosition() -
211+
edgeProx->element()->getP0()->getPosition())
212+
.normalized();
213+
const SReal dotProd = dot(ab, normal);
214+
if (dotProd > 0.0) m_couplingPts.pop_back();
215+
}
215216

216217
auto findClosestProxOnShaft =
217218
Operations::FindClosestProximity::Operation::get(l_shaftGeom);

0 commit comments

Comments
 (0)