* @brief
* Get physics body forces.
*
- * Get all the forces applied over a body.
+ * Get all the forces applied over a body, including gravity.
+ * Damping is not considered.
*
* @param body The physics body.
* @param x The axis x component of total force.
* @see ephysics_body_central_force_apply().
* @see ephysics_body_torque_apply().
* @see ephysics_body_forces_clear().
+ * @see ephysics_world_gravity_set().
*
* @ingroup EPhysics_Body
*/
EAPI void
ephysics_body_forces_get(const EPhysics_Body *body, double *x, double *y, double *torque)
{
- double rate;
+ double rate, gx, gy;
if (!body)
{
}
rate = ephysics_world_rate_get(body->world);
+ ephysics_world_gravity_get(body->world, &gx, &gy);
- if (x) *x = body->force.x * rate;
- if (y) *y = body->force.y * rate;
+ if (x) *x = body->force.x * rate + gx;
+ if (y) *y = body->force.y * rate + gy;
if (torque) *torque = -body->force.torque;
}