Skip to content

Commit

Permalink
Added an assert (from patch 1557801) for a very common composite mass…
Browse files Browse the repository at this point in the history
… problem encountered by new users - centre of mass must be at the body origin. (Use dMassTranslate( mass, -mass->c ) to correct it). Note that at some point in the future, ODE will support offset masses, until that time it'll save a lot of people time if it asserts about it (and hopefully may spur on development of offset masses!)
  • Loading branch information
David Walters committed Nov 6, 2006
1 parent ff60783 commit 06df7c4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ode/src/ode.cpp
Expand Up @@ -475,6 +475,12 @@ void dBodySetMass (dBodyID b, const dMass *mass)
dAASSERT (b && mass );
dIASSERT(dMassCheck(mass));

// The centre of mass must be at the origin.
// Use dMassTranslate( mass, -mass->c[0], -mass->c[1], -mass->c[2] ) to correct it.
dUASSERT( fabs( mass->c[0] ) <= dEpsilon &&
fabs( mass->c[1] ) <= dEpsilon &&
fabs( mass->c[2] ) <= dEpsilon, "The centre of mass must be at the origin." )

memcpy (&b->mass,mass,sizeof(dMass));
if (dInvertPDMatrix (b->mass.I,b->invI,3)==0) {
dDEBUGMSG ("inertia must be positive definite!");
Expand Down

0 comments on commit 06df7c4

Please sign in to comment.