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;
|
Test_Data *test_data = data;
|
||||||
double vx, vy, vaz;
|
double vx, vy, vaz;
|
||||||
|
|
||||||
|
vaz = ephysics_body_angular_velocity_get(body);
|
||||||
ephysics_body_linear_velocity_get(body, &vx, &vy);
|
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),
|
snprintf(linear_vel, sizeof(linear_vel),
|
||||||
"Linear velocity: x = %.2f, y = %.2f", vx, vy);
|
"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 x The linear velocity on axis x.
|
||||||
* @param y The linear velocity on axis y.
|
* @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().
|
* @see ephysics_body_angular_velocity_get().
|
||||||
*
|
*
|
||||||
* @ingroup EPhysics_Body
|
* @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.
|
* Get body's angular velocity on z axis.
|
||||||
*
|
*
|
||||||
* @param body The physics body.
|
* @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().
|
* @see ephysics_body_linear_velocity_get().
|
||||||
*
|
*
|
||||||
* @ingroup EPhysics_Body
|
* @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
|
* @brief
|
||||||
|
|
|
@ -550,26 +550,28 @@ ephysics_body_mass_get(const EPhysics_Body *body)
|
||||||
EAPI void
|
EAPI void
|
||||||
ephysics_body_linear_velocity_get(const EPhysics_Body *body, double *x, double *y)
|
ephysics_body_linear_velocity_get(const EPhysics_Body *body, double *x, double *y)
|
||||||
{
|
{
|
||||||
if (!body)
|
double rate;
|
||||||
|
if (!body)
|
||||||
{
|
{
|
||||||
ERR("Can't get body linear velocity, body is null.");
|
ERR("Can't get body linear velocity, body is null.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x) *x = body->rigid_body->getLinearVelocity().getX();
|
rate = ephysics_world_rate_get(body->world);
|
||||||
if (y) *y = body->rigid_body->getLinearVelocity().getY();
|
if (x) *x = body->rigid_body->getLinearVelocity().getX() * rate;
|
||||||
|
if (y) *y = -body->rigid_body->getLinearVelocity().getY() * rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI double
|
||||||
ephysics_body_angular_velocity_get(const EPhysics_Body *body, double *z)
|
ephysics_body_angular_velocity_get(const EPhysics_Body *body)
|
||||||
{
|
{
|
||||||
if (!body)
|
if (!body)
|
||||||
{
|
{
|
||||||
ERR("Can't get body linear velocity, body is null.");
|
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
|
EAPI void
|
||||||
|
|
Loading…
Reference in New Issue