forked from enlightenment/efl
parent
fe013dc22e
commit
c45cfc3be1
|
@ -663,7 +663,7 @@ EAPI double ephysics_world_linear_slop_get(EPhysics_World *world);
|
|||
* by the top.
|
||||
*
|
||||
* It's useful when you don't care about bodies leaving the render
|
||||
* area set with @ref ephysics_world_render_area_set(), and don't think
|
||||
* area set with @ref ephysics_world_render_geometry_set(), and don't think
|
||||
* they could / should return. So you can safely delete them and save resources.
|
||||
*
|
||||
* Also, it's useful if you have only a bottom border set with
|
||||
|
@ -1160,6 +1160,23 @@ EAPI void ephysics_body_mass_set(EPhysics_Body *body, double mass);
|
|||
*/
|
||||
EAPI double ephysics_body_mass_get(const EPhysics_Body *body);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Set body's linear velocity on x and y axis.
|
||||
*
|
||||
* @param body The physics 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_linear_velocity_get().
|
||||
* @see ephysics_body_angular_velocity_set().
|
||||
*
|
||||
* @ingroup EPhysics_Body
|
||||
*/
|
||||
EAPI void ephysics_body_linear_velocity_set(EPhysics_Body *body, double x, double y);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Get body's linear velocity on x and y axis.
|
||||
|
@ -1170,12 +1187,29 @@ EAPI double ephysics_body_mass_get(const EPhysics_Body *body);
|
|||
*
|
||||
* @note EPhysics unit for linear velocity is Evas coordinates per second.
|
||||
*
|
||||
* @see ephysics_body_linear_velocity_set().
|
||||
* @see ephysics_body_angular_velocity_get().
|
||||
*
|
||||
* @ingroup EPhysics_Body
|
||||
*/
|
||||
EAPI void ephysics_body_linear_velocity_get(const EPhysics_Body *body, double *x, double *y);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Set body's angular velocity on z axis.
|
||||
*
|
||||
* @param body The physics body.
|
||||
* @param z The angular velocity on axis z.
|
||||
*
|
||||
* @note EPhysics unit for angular velocity is degrees per second.
|
||||
*
|
||||
* @see ephysics_body_angular_velocity_set().
|
||||
* @see ephysics_body_linear_velocity_get().
|
||||
*
|
||||
* @ingroup EPhysics_Body
|
||||
*/
|
||||
EAPI void ephysics_body_angular_velocity_set(EPhysics_Body *body, double z);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Get body's angular velocity on z axis.
|
||||
|
@ -1191,6 +1225,26 @@ EAPI void ephysics_body_linear_velocity_get(const EPhysics_Body *body, double *x
|
|||
*/
|
||||
EAPI double ephysics_body_angular_velocity_get(const EPhysics_Body *body);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Stop angular and linear body movement.
|
||||
*
|
||||
* It's equivalent to set linear velocity to 0 on both axis and
|
||||
* angular velocity to 0 as well.
|
||||
*
|
||||
* It's a momentary situation. If it receives impulse, directly or
|
||||
* by collision, if gravity acts over this body,
|
||||
* it will stop but it will accelerate again.
|
||||
*
|
||||
* @param body The physics body.
|
||||
*
|
||||
* @see ephysics_body_angular_velocity_set().
|
||||
* @see ephysics_body_linear_velocity_set().
|
||||
*
|
||||
* @ingroup EPhysics_Body
|
||||
*/
|
||||
EAPI void ephysics_body_stop(EPhysics_Body *body);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Update the evas object associated to the body.
|
||||
|
|
|
@ -574,13 +574,30 @@ ephysics_body_mass_get(const EPhysics_Body *body)
|
|||
return 1 / body->rigid_body->getInvMass();
|
||||
}
|
||||
|
||||
EAPI void
|
||||
ephysics_body_linear_velocity_set(EPhysics_Body *body, double x, double y)
|
||||
{
|
||||
double rate;
|
||||
|
||||
if (!body)
|
||||
{
|
||||
ERR("Can't set body linear velocity, body is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
rate = ephysics_world_rate_get(body->world);
|
||||
body->rigid_body->setLinearVelocity(btVector3(x / rate, y / rate, 0));
|
||||
DBG("Linear velocity of body %p set to %lf, %lf", body, x, y);
|
||||
}
|
||||
|
||||
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.");
|
||||
ERR("Can't get linear velocity, body is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -589,18 +606,46 @@ ephysics_body_linear_velocity_get(const EPhysics_Body *body, double *x, double *
|
|||
if (y) *y = -body->rigid_body->getLinearVelocity().getY() * rate;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
ephysics_body_angular_velocity_set(EPhysics_Body *body, double z)
|
||||
{
|
||||
if (!body)
|
||||
{
|
||||
ERR("Can't set angular velocity, body is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
body->rigid_body->setAngularVelocity(btVector3(0, 0, -z/RAD_TO_DEG));
|
||||
DBG("Angular velocity of body %p set to %lf", body, z);
|
||||
}
|
||||
|
||||
EAPI double
|
||||
ephysics_body_angular_velocity_get(const EPhysics_Body *body)
|
||||
{
|
||||
if (!body)
|
||||
{
|
||||
ERR("Can't get body linear velocity, body is null.");
|
||||
ERR("Can't get angular velocity, body is null.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -body->rigid_body->getAngularVelocity().getZ() * RAD_TO_DEG;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
ephysics_body_stop(EPhysics_Body *body)
|
||||
{
|
||||
if (!body)
|
||||
{
|
||||
ERR("Can't stop a null body.");
|
||||
return;
|
||||
}
|
||||
|
||||
body->rigid_body->setLinearVelocity(btVector3(0, 0, 0));
|
||||
body->rigid_body->setAngularVelocity(btVector3(0, 0, 0));
|
||||
|
||||
DBG("Body %p stopped", body);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
ephysics_body_evas_object_update(EPhysics_Body *body)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue