From 64bc76ba49c73d16425d84317bfd38c1e697e901 Mon Sep 17 00:00:00 2001 From: Bruno Dilly Date: Thu, 18 Oct 2012 21:23:05 +0000 Subject: [PATCH] ephysics: expose volume getter useful to calculate density given a mass SVN revision: 78201 --- legacy/ephysics/src/lib/EPhysics.h | 17 +++++++++++++++++ legacy/ephysics/src/lib/ephysics_body.cpp | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h index 3f9035fe75..f81c3d76e2 100644 --- a/legacy/ephysics/src/lib/EPhysics.h +++ b/legacy/ephysics/src/lib/EPhysics.h @@ -3446,6 +3446,23 @@ EAPI void ephysics_body_density_set(EPhysics_Body *body, double density); */ EAPI double ephysics_body_density_get(const EPhysics_Body *body); +/** + * @brief + * Get body's volume. + * + * @note The unit of the returned value is meters ^ 3. Not pixels. Useful + * for calculation with mass and density. + * + * @param body The physics body. + * @return the @p body's volume, in meters ^ 3 or -1 on error. + * + * @see ephysics_body_geometry_set(). + * @see ephysics_body_geometry_get(). + * + * @ingroup EPhysics_Body + */ +EAPI double ephysics_body_volume_get(const EPhysics_Body *body); + /** * @brief * Set body's material. diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp index 0b25536eda..d50558eaf1 100644 --- a/legacy/ephysics/src/lib/ephysics_body.cpp +++ b/legacy/ephysics/src/lib/ephysics_body.cpp @@ -3142,6 +3142,16 @@ ephysics_body_light_get(const EPhysics_Body *body) return body->light_apply; } +EAPI double +ephysics_body_volume_get(const EPhysics_Body *body) +{ + if (!body) + { + ERR("No body, no volume."); + return -1; + } + return _ephysics_body_volume_get(body); +} #ifdef __cplusplus }