From fbb6da418d072b381c524fa8c9d7ed20d3856acc Mon Sep 17 00:00:00 2001 From: "M.X. Grey" Date: Tue, 31 May 2016 18:23:06 -0400 Subject: [PATCH 1/2] Update total mass when removing bodies --- dart/dynamics/Skeleton.cpp | 2 ++ unittests/testSkeleton.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/dart/dynamics/Skeleton.cpp b/dart/dynamics/Skeleton.cpp index 067b9d5cdf370..f6437e42e01b2 100644 --- a/dart/dynamics/Skeleton.cpp +++ b/dart/dynamics/Skeleton.cpp @@ -2216,6 +2216,8 @@ void Skeleton::unregisterBodyNode(BodyNode* _oldBodyNode) mSoftBodyNodes.end(), soft), mSoftBodyNodes.end()); } + + updateTotalMass(); } //============================================================================== diff --git a/unittests/testSkeleton.cpp b/unittests/testSkeleton.cpp index 59fc01b02add9..719c4abfe28d8 100644 --- a/unittests/testSkeleton.cpp +++ b/unittests/testSkeleton.cpp @@ -1257,6 +1257,16 @@ TEST(Skeleton, Updating) screw->setPitch(3); J0f = screw->getRelativeJacobian(); EXPECT_FALSE(equals(J0i, J0f)); + + // Regression test for Pull Request # + const double originalMass = skeleton->getMass(); + BodyNode* lastBn = skeleton->getBodyNode(skeleton->getNumBodyNodes()-1); + const double removedMass = lastBn->getMass(); + EXPECT_FALSE(removedMass == 0.0); + lastBn->remove(); + const double newMass = skeleton->getMass(); + EXPECT_FALSE(originalMass == newMass); + EXPECT_TRUE(newMass == originalMass - removedMass); } int main(int argc, char* argv[]) From 22444c0961c24d58c5a0fc508df9ec061f49c5c9 Mon Sep 17 00:00:00 2001 From: "M.X. Grey" Date: Tue, 31 May 2016 18:24:55 -0400 Subject: [PATCH 2/2] Labeled the Pull Request number --- unittests/testSkeleton.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittests/testSkeleton.cpp b/unittests/testSkeleton.cpp index 719c4abfe28d8..4ebdea0c852af 100644 --- a/unittests/testSkeleton.cpp +++ b/unittests/testSkeleton.cpp @@ -1258,7 +1258,7 @@ TEST(Skeleton, Updating) J0f = screw->getRelativeJacobian(); EXPECT_FALSE(equals(J0i, J0f)); - // Regression test for Pull Request # + // Regression test for Pull Request #731 const double originalMass = skeleton->getMass(); BodyNode* lastBn = skeleton->getBodyNode(skeleton->getNumBodyNodes()-1); const double removedMass = lastBn->getMass();