forked from enlightenment/efl
parent
22d76ad177
commit
ec5414e7bd
|
@ -32,8 +32,10 @@ _update_vel_cb(void *data, EPhysics_Body *body, void *event_info __UNUSED__)
|
|||
Test_Data *test_data = data;
|
||||
double vx, vy, vaz;
|
||||
|
||||
vaz = ephysics_body_angular_velocity_get(body);
|
||||
ephysics_body_linear_velocity_get(body, &vx, &vy);
|
||||
ephysics_body_angular_velocity_get(body, &vaz);
|
||||
vx = (vx > 0 || vx <= -0.01) ? vx : 0;
|
||||
vy = (vy > 0 || vy <= -0.01) ? vy : 0;
|
||||
|
||||
snprintf(linear_vel, sizeof(linear_vel),
|
||||
"Linear velocity: x = %.2f, y = %.2f", vx, vy);
|
||||
|
|
|
@ -988,6 +988,8 @@ EAPI double ephysics_body_mass_get(const EPhysics_Body *body);
|
|||
* @param x The linear velocity on axis x.
|
||||
* @param y The linear velocity on axis y.
|
||||
*
|
||||
* @note EPhysics unit for linear velocity is Evas coordinates per second.
|
||||
*
|
||||
* @see ephysics_body_angular_velocity_get().
|
||||
*
|
||||
* @ingroup EPhysics_Body
|
||||
|
@ -999,13 +1001,15 @@ EAPI void ephysics_body_linear_velocity_get(const EPhysics_Body *body, double *x
|
|||
* Get body's angular velocity on z axis.
|
||||
*
|
||||
* @param body The physics body.
|
||||
* @param z The angular velocity on axis z.
|
||||
* @return The angular velocity on axis z, or 0 on error.
|
||||
*
|
||||
* @note EPhysics unit for angular velocity is degrees per second.
|
||||
*
|
||||
* @see ephysics_body_linear_velocity_get().
|
||||
*
|
||||
* @ingroup EPhysics_Body
|
||||
*/
|
||||
EAPI void ephysics_body_angular_velocity_get(const EPhysics_Body *body, double *z);
|
||||
EAPI double ephysics_body_angular_velocity_get(const EPhysics_Body *body);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
|
|
|
@ -550,26 +550,28 @@ ephysics_body_mass_get(const EPhysics_Body *body)
|
|||
EAPI void
|
||||
ephysics_body_linear_velocity_get(const EPhysics_Body *body, double *x, double *y)
|
||||
{
|
||||
double rate;
|
||||
if (!body)
|
||||
{
|
||||
ERR("Can't get body linear velocity, body is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (x) *x = body->rigid_body->getLinearVelocity().getX();
|
||||
if (y) *y = body->rigid_body->getLinearVelocity().getY();
|
||||
rate = ephysics_world_rate_get(body->world);
|
||||
if (x) *x = body->rigid_body->getLinearVelocity().getX() * rate;
|
||||
if (y) *y = -body->rigid_body->getLinearVelocity().getY() * rate;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
ephysics_body_angular_velocity_get(const EPhysics_Body *body, double *z)
|
||||
EAPI double
|
||||
ephysics_body_angular_velocity_get(const EPhysics_Body *body)
|
||||
{
|
||||
if (!body)
|
||||
{
|
||||
ERR("Can't get body linear velocity, body is null.");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (z) *z = body->rigid_body->getAngularVelocity().getZ();
|
||||
return -body->rigid_body->getAngularVelocity().getZ() * RAD_TO_DEG;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
|
Loading…
Reference in New Issue