Skip to content

Commit 56d7cbe

Browse files
authored
Fix grouping of skeletons by constraints (#1628)
1 parent 620d095 commit 56d7cbe

10 files changed

+17
-13
lines changed

dart/constraint/BallJointConstraint.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,13 @@ void BallJointConstraint::applyImpulse(double* _lambda)
334334
dynamics::SkeletonPtr BallJointConstraint::getRootSkeleton() const
335335
{
336336
if (mBodyNode1->isReactive())
337-
return mBodyNode1->getSkeleton()->mUnionRootSkeleton.lock();
337+
return ConstraintBase::getRootSkeleton(mBodyNode1->getSkeleton());
338338

339339
if (mBodyNode2)
340340
{
341341
if (mBodyNode2->isReactive())
342342
{
343-
return mBodyNode2->getSkeleton()->mUnionRootSkeleton.lock();
343+
return ConstraintBase::getRootSkeleton(mBodyNode2->getSkeleton());
344344
}
345345
else
346346
{

dart/constraint/JointConstraint.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ void JointConstraint::applyImpulse(double* lambda)
537537
//==============================================================================
538538
dynamics::SkeletonPtr JointConstraint::getRootSkeleton() const
539539
{
540-
return mJoint->getSkeleton()->mUnionRootSkeleton.lock();
540+
return ConstraintBase::getRootSkeleton(mJoint->getSkeleton()->getSkeleton());
541541
}
542542

543543
//==============================================================================

dart/constraint/JointCoulombFrictionConstraint.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ void JointCoulombFrictionConstraint::applyImpulse(double* _lambda)
276276
//==============================================================================
277277
dynamics::SkeletonPtr JointCoulombFrictionConstraint::getRootSkeleton() const
278278
{
279-
return mJoint->getSkeleton()->mUnionRootSkeleton.lock();
279+
return ConstraintBase::getRootSkeleton(mJoint->getSkeleton()->getSkeleton());
280280
}
281281

282282
//==============================================================================

dart/constraint/JointLimitConstraint.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ void JointLimitConstraint::applyImpulse(double* lambda)
456456
//==============================================================================
457457
dynamics::SkeletonPtr JointLimitConstraint::getRootSkeleton() const
458458
{
459-
return mJoint->getSkeleton()->mUnionRootSkeleton.lock();
459+
return ConstraintBase::getRootSkeleton(mJoint->getSkeleton()->getSkeleton());
460460
}
461461

462462
//==============================================================================

dart/constraint/MimicMotorConstraint.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ void MimicMotorConstraint::applyImpulse(double* lambda)
288288
//==============================================================================
289289
dynamics::SkeletonPtr MimicMotorConstraint::getRootSkeleton() const
290290
{
291-
return mJoint->getSkeleton()->mUnionRootSkeleton.lock();
291+
return ConstraintBase::getRootSkeleton(mJoint->getSkeleton()->getSkeleton());
292292
}
293293

294294
//==============================================================================

dart/constraint/ServoMotorConstraint.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ void ServoMotorConstraint::applyImpulse(double* lambda)
277277
//==============================================================================
278278
dynamics::SkeletonPtr ServoMotorConstraint::getRootSkeleton() const
279279
{
280-
return mJoint->getSkeleton()->mUnionRootSkeleton.lock();
280+
return ConstraintBase::getRootSkeleton(mJoint->getSkeleton()->getSkeleton());
281281
}
282282

283283
//==============================================================================

dart/constraint/SoftContactConstraint.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,11 @@ double SoftContactConstraint::computeRestitutionCoefficient(
981981
dynamics::SkeletonPtr SoftContactConstraint::getRootSkeleton() const
982982
{
983983
if (mSoftBodyNode1 || mBodyNode1->isReactive())
984-
return mBodyNode1->getSkeleton()->mUnionRootSkeleton.lock();
984+
return ConstraintBase::getRootSkeleton(
985+
mBodyNode1->getSkeleton()->getSkeleton());
985986
else
986-
return mBodyNode2->getSkeleton()->mUnionRootSkeleton.lock();
987+
return ConstraintBase::getRootSkeleton(
988+
mBodyNode2->getSkeleton()->getSkeleton());
987989
}
988990

989991
//==============================================================================

dart/constraint/WeldJointConstraint.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,15 @@ void WeldJointConstraint::applyImpulse(double* _lambda)
355355
dynamics::SkeletonPtr WeldJointConstraint::getRootSkeleton() const
356356
{
357357
if (mBodyNode1->isReactive())
358-
return mBodyNode1->getSkeleton()->mUnionRootSkeleton.lock();
358+
return ConstraintBase::getRootSkeleton(
359+
mBodyNode1->getSkeleton()->getSkeleton());
359360

360361
if (mBodyNode2)
361362
{
362363
if (mBodyNode2->isReactive())
363364
{
364-
return mBodyNode2->getSkeleton()->mUnionRootSkeleton.lock();
365+
return ConstraintBase::getRootSkeleton(
366+
mBodyNode2->getSkeleton()->getSkeleton());
365367
}
366368
else
367369
{

dart/dynamics/detail/DegreeOfFreedomPtr.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class TemplateDegreeOfFreedomPtr
218218
TemplateBodyNodePtr<BodyNodeT> mBodyNodePtr;
219219

220220
/// Local index of this DegreeOfFreedom within its Joint
221-
std::size_t mIndex;
221+
std::size_t mIndex = 0;
222222
};
223223

224224
/// TemplateWeakDegreeOfFreedomPtr is a templated class that enables users to

unittests/regression/test_Issue1231.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ TEST(Issue1231, NoContacts)
4545
dart::simulation::WorldPtr world = dart::simulation::World::create();
4646

4747
double x = -0.25;
48-
for (const std::string& name : {"1", "2"})
48+
for (const auto& name : {"1", "2"})
4949
{
5050
const auto skeleton = dart::dynamics::Skeleton::create(name);
5151
skeleton->setMobile(false);

0 commit comments

Comments
 (0)