Set mass data consistent velocity (#45)

- Rename b3Body_GetWorldCenterOfMass to b3Body_GetWorldCenter.
- Rename b3Body_GetLocalCenterOfMass to b3Body_GetLocalCenter.
- Fixed b3Body_SetMassData to correct velocity when local center moves.
This commit is contained in:
Erin Catto 2026-07-04 11:22:29 -07:00 • committed by GitHub
commit 0f6fdad541
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 94 additions and 30 deletions

View file

@ -1161,7 +1161,7 @@ public:
b3Vec3 linearVelocity = b3Body_GetLinearVelocity( m_bodyId );
float kineticEnergy = 0.5f * b3Dot( angularVelocity, b3MulMV( massData.inertia, angularVelocity ) );
kineticEnergy += 0.5f * massData.mass * b3Dot( linearVelocity, linearVelocity );
b3Pos center = b3Body_GetWorldCenterOfMass( m_bodyId );
b3Pos center = b3Body_GetWorldCenter( m_bodyId );
b3Vec3 gravity = b3World_GetGravity( m_worldId );
float potentialEnergy = -massData.mass * center.y * gravity.y;
DrawTextLine( "kinetic energy = %g", kineticEnergy );