From 2afffbd809307cd9c291317e749cf0ae33b1d63d Mon Sep 17 00:00:00 2001 From: Leandro Dorileo Date: Thu, 5 Jul 2012 22:52:53 +0000 Subject: [PATCH] EPhysics: body damping set This patch introduces a function for rigid body damping. Patch by: Leandro Dorileo SVN revision: 73382 --- legacy/ephysics/src/lib/EPhysics.h | 31 +++++++++++++++++++++++++++++++ legacy/ephysics/src/lib/ephysics_body.cpp | 13 +++++++++++++ 2 files changed, 44 insertions(+) diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h index 1c966ce..a4c9cf7 100644 --- a/legacy/ephysics/src/lib/EPhysics.h +++ b/legacy/ephysics/src/lib/EPhysics.h @@ -1247,6 +1247,37 @@ 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. * * This function should be called to update position and rotation of diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp index 0353212..6ad5dd8 100644 --- a/legacy/ephysics/src/lib/ephysics_body.cpp +++ b/legacy/ephysics/src/lib/ephysics_body.cpp @@ -647,6 +647,19 @@ ephysics_body_stop(EPhysics_Body *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) { if (!body) -- 2.7.4