diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h index 2a1a2cd933..9a8f368313 100644 --- a/legacy/ephysics/src/lib/EPhysics.h +++ b/legacy/ephysics/src/lib/EPhysics.h @@ -968,6 +968,33 @@ EAPI void ephysics_body_mass_set(EPhysics_Body *body, double mass); */ EAPI double ephysics_body_mass_get(const EPhysics_Body *body); +/** + * @brief + * Get 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. + * + * @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 + * Get body's angular velocity on z axis. + * + * @param body The physics body. + * @param z The angular velocity on axis z. + * + * @see ephysics_body_linear_velocity_get(). + * + * @ingroup EPhysics_Body + */ +EAPI void ephysics_body_angular_velocity_get(const EPhysics_Body *body, double *z); + /** * @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 b179c3a14e..cdb32a8909 100644 --- a/legacy/ephysics/src/lib/ephysics_body.cpp +++ b/legacy/ephysics/src/lib/ephysics_body.cpp @@ -547,6 +547,31 @@ ephysics_body_mass_get(const EPhysics_Body *body) return 1 / body->rigid_body->getInvMass(); } +EAPI void +ephysics_body_linear_velocity_get(const EPhysics_Body *body, double *x, double *y) +{ + if (!body) + { + ERR("Can't get body linear velocity, body is null."); + return; + } + + if (x) *x = body->rigid_body->getLinearVelocity().getX(); + if (y) *y = body->rigid_body->getLinearVelocity().getY(); +} + +EAPI void +ephysics_body_angular_velocity_get(const EPhysics_Body *body, double *z) +{ + if (!body) + { + ERR("Can't get body linear velocity, body is null."); + return; + } + + if (z) *z = body->rigid_body->getAngularVelocity().getZ(); +} + EAPI void ephysics_body_evas_object_update(EPhysics_Body *body) {