Skip to content

Commit

Permalink
Merge pull request #3396 from opensim-org/fix_body-inertia-doesnt-update
Browse files Browse the repository at this point in the history
Hotfixed body inertia not updating from property changes (#3395)
  • Loading branch information
nickbianco authored Feb 16, 2023
2 parents 32ed0bc + be012e1 commit c138570
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ v4.5
- Fix CSV file adapter hanging on csv files that are missing end-header (issue #2432).
- Improve documentation for MotionType to serve scripting users (Issue #3324).
- Drop support for 32-bit Matlab in build system since Matlab stopped providing 32-bit distributions (issue #3373).
- Hotfixed body inertia not being updated after changing the 'inertia' property of a body (Issue #3395).

v4.4
====
Expand Down
8 changes: 4 additions & 4 deletions OpenSim/Simulation/SimbodyEngine/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void Body::constructProperties()
void Body::extendFinalizeFromProperties()
{
Super::extendFinalizeFromProperties();
_inertia = SimTK::Inertia{}; // forces `getInertia` to re-update from the property (#3395)
const SimTK::MassProperties& massProps = getMassProperties();
_internalRigidBody = SimTK::Body::Rigid(massProps);
_slaves.clear();
Expand Down Expand Up @@ -215,8 +216,8 @@ void Body::scaleInertialProperties(const SimTK::Vec3& scaleFactors, bool scaleMa
if (scaleMass)
upd_mass() *= massScaleFactor;
// Fix issue #2871 by fmatari
SimTK::Mat33 inertia = _inertia.toMat33();
//SimTK::SymMat33 inertia = _inertia.asSymMat33();
SimTK::Mat33 inertia = getInertia().toMat33();
//SimTK::SymMat33 inertia = getInertia().asSymMat33();

// If the mass is zero, then make the inertia tensor zero as well.
// If the X, Y, Z scale factors are equal, then you can scale the
Expand Down Expand Up @@ -346,8 +347,7 @@ void Body::scaleInertialProperties(const ScaleSet& scaleSet, bool scaleMass)
void Body::scaleMass(double aScaleFactor)
{
upd_mass() *= aScaleFactor;
_inertia *= aScaleFactor;
upd_inertia() *= aScaleFactor;
setInertia(aScaleFactor * getInertia());
}

//=============================================================================
Expand Down

0 comments on commit c138570

Please sign in to comment.