Mass don't affect falling down velocity
Posted: Wed Jul 13, 2011 2:30 pm
Hi, can't understand why the gravity isn't affected by the body mass in default velocity update method,is there any way to make falling down velocity to be different from one body to another depending on mass of the body?
If i'm right and this is not intended the cpBodyUpdateVelocity shoud be updated to :
void
cpBodyUpdateVelocity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt)
{
body->v = cpvclamp(cpvadd(cpvmult(body->v, damping), cpvmult(cpvadd(cpvmult(gravity,body->m), cpvmult(body->f, body->m_inv)), dt)), body->v_limit);
cpFloat w_limit = body->w_limit;
body->w = cpfclamp(body->w*damping + body->t*body->i_inv*dt, -w_limit, w_limit);
}
If i'm right and this is not intended the cpBodyUpdateVelocity shoud be updated to :
void
cpBodyUpdateVelocity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt)
{
body->v = cpvclamp(cpvadd(cpvmult(body->v, damping), cpvmult(cpvadd(cpvmult(gravity,body->m), cpvmult(body->f, body->m_inv)), dt)), body->v_limit);
cpFloat w_limit = body->w_limit;
body->w = cpfclamp(body->w*damping + body->t*body->i_inv*dt, -w_limit, w_limit);
}