From: Enlightenment S. <no-...@en...> - 2012-07-05 22:53:00
|
Log: EPhysics: body damping set This patch introduces a function for rigid body damping. Patch by: Leandro Dorileo <do...@pr...> Author: bdilly Date: 2012-07-05 15:52:53 -0700 (Thu, 05 Jul 2012) New Revision: 73382 Trac: http://trac.enlightenment.org/e/changeset/73382 Modified: trunk/ephysics/src/lib/EPhysics.h trunk/ephysics/src/lib/ephysics_body.cpp Modified: trunk/ephysics/src/lib/EPhysics.h =================================================================== --- trunk/ephysics/src/lib/EPhysics.h 2012-07-05 21:07:15 UTC (rev 73381) +++ trunk/ephysics/src/lib/EPhysics.h 2012-07-05 22:52:53 UTC (rev 73382) @@ -1247,6 +1247,37 @@ /** * @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 Modified: trunk/ephysics/src/lib/ephysics_body.cpp =================================================================== --- trunk/ephysics/src/lib/ephysics_body.cpp 2012-07-05 21:07:15 UTC (rev 73381) +++ trunk/ephysics/src/lib/ephysics_body.cpp 2012-07-05 22:52:53 UTC (rev 73382) @@ -647,6 +647,19 @@ } 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) |