Skip to content

Commit

Permalink
CustomConvexShape: more accurate inertia for non-uniform scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Jan 15, 2024
1 parent 5794fe5 commit 27a8fd0
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@ jmeConvexShape : public btConvexInternalShape {
void
calculateLocalInertia(btScalar mass, btVector3& storeResult) const {
btVector3 scaleVector = getLocalScaling();
btVector3 factor(scaleVector.y() * scaleVector.z(),
scaleVector.z() * scaleVector.x(),
scaleVector.x() * scaleVector.y());
storeResult = factor * mass * m_descaledInertia;
btScalar x = scaleVector.x();
btScalar y = scaleVector.y();
btScalar z = scaleVector.z();
btScalar xx = x * x;
btScalar yy = y * y;
btScalar zz = z * z;
btVector3 factor(yy + zz, zz + xx, xx + yy);
storeResult = m_descaledInertia * mass * factor / 2;
}

void
Expand Down

0 comments on commit 27a8fd0

Please sign in to comment.