forked from enlightenment/efl
EPhysics: consider gravity on forces getter
SVN revision: 75479
This commit is contained in:
parent
335dcc1165
commit
80f7e6307c
|
@ -2444,7 +2444,8 @@ EAPI void ephysics_body_force_apply(EPhysics_Body *body, double x, double y, Eva
|
|||
* @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.
|
||||
|
@ -2455,6 +2456,7 @@ EAPI void ephysics_body_force_apply(EPhysics_Body *body, double x, double y, Eva
|
|||
* @see ephysics_body_central_force_apply().
|
||||
* @see ephysics_body_torque_apply().
|
||||
* @see ephysics_body_forces_clear().
|
||||
* @see ephysics_world_gravity_set().
|
||||
*
|
||||
* @ingroup EPhysics_Body
|
||||
*/
|
||||
|
|
|
@ -1461,7 +1461,7 @@ ephysics_body_torque_apply(EPhysics_Body *body, double torque)
|
|||
EAPI void
|
||||
ephysics_body_forces_get(const EPhysics_Body *body, double *x, double *y, double *torque)
|
||||
{
|
||||
double rate;
|
||||
double rate, gx, gy;
|
||||
|
||||
if (!body)
|
||||
{
|
||||
|
@ -1470,9 +1470,10 @@ ephysics_body_forces_get(const EPhysics_Body *body, double *x, double *y, double
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue