diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h index 1c966ce43e..a4c9cf7a61 100644 --- a/legacy/ephysics/src/lib/EPhysics.h +++ b/legacy/ephysics/src/lib/EPhysics.h @@ -1245,6 +1245,37 @@ EAPI double ephysics_body_angular_velocity_get(const EPhysics_Body *body); */ EAPI void ephysics_body_stop(EPhysics_Body *body); +/** + * @brief + * Set the angular and linear damping values. + * + * Damping(linear and angular) values are applied to body's linear and angular + * velocity. + * + * By applying a bodies damping factor the user will face a velocity reduction, + * with a force applied to it - like air resistance. The force is applied to + * slow it down. Different factors can be applied to angular and linear + * velocity to fine tune translation and rotation. + * + * The damping is a force synchronous with the velocity of the object but in + * opposite direction. + * + * Damping is specified as a value between 0 and 1, which is the proportion of + * velocity lost per second. If specified damping value - either for angular or + * linear - is greater or equal to 1, velocities are nulled(that means, will + * become 0 on every axis), resulting on a frozen body. + * + * Default linear damping is set to 0. The same is true for angular damping + * factor. + * + * @param body The physics body. + * @param linear_damping The linear damping force to apply on @p body. + * @param angular_damping The angular damping force to apply on @p body. + * + * @ingroup EPhysics_Body + */ +EAPI void ephysics_body_damping_set(EPhysics_Body *body, double linear_damping, double angular_damping); + /** * @brief * Update the evas object associated to the body. diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp index 0353212f8f..6ad5dd81e7 100644 --- a/legacy/ephysics/src/lib/ephysics_body.cpp +++ b/legacy/ephysics/src/lib/ephysics_body.cpp @@ -646,6 +646,19 @@ ephysics_body_stop(EPhysics_Body *body) DBG("Body %p stopped", body); } +EAPI void +ephysics_body_damping_set(EPhysics_Body *body, double linear_damping, double angular_damping) +{ + if (!body) + { + ERR("Can't set body damping, body is null."); + return; + } + + body->rigid_body->setDamping(btScalar(linear_damping), + btScalar(angular_damping)); +} + EAPI void ephysics_body_evas_object_update(EPhysics_Body *body) {