aboutsummaryrefslogtreecommitdiffstats
path: root/legacy/ephysics/src/lib
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2012-12-05 13:50:20 +0000
committerLeandro Dorileo <dorileo@profusion.mobi>2012-12-05 13:50:20 +0000
commit4640e5cdca1987d96fa755af676a0f07b32be98e (patch)
treed1fc4a7a19617d5c9a7822f461ea0fe93b297955 /legacy/ephysics/src/lib
parentd435db293105f9319fc8865558bd0edac104d318 (diff)
downloadefl-4640e5cdca1987d96fa755af676a0f07b32be98e.tar.gz
efl-4640e5cdca1987d96fa755af676a0f07b32be98e.tar.xz
efl-4640e5cdca1987d96fa755af676a0f07b32be98e.zip
EPhysics: soft body drag coefficient
Add API for handling with soft body drag coefficient. --This line, and those below, will be ignored-- SVN revision: 80249
Diffstat (limited to 'legacy/ephysics/src/lib')
-rw-r--r--legacy/ephysics/src/lib/EPhysics.h47
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp39
2 files changed, 86 insertions, 0 deletions
diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h
index 5a3f9b124..564713498 100644
--- a/legacy/ephysics/src/lib/EPhysics.h
+++ b/legacy/ephysics/src/lib/EPhysics.h
@@ -2372,6 +2372,53 @@ EAPI double ephysics_body_soft_body_anchor_hardness_get(EPhysics_Body *body);
/**
* @brief
+ * Set the drag coefficient of a soft body.
+ *
+ * Drag coefficient is a dimensionless quantity used to quantify an objects drag
+ * or resistance in the environment - like air or water resistance. It is used in
+ * the drag equation, where a lower drag coefficient indicates the object will
+ * have less aerodynamic or hydrodynamic drag.
+ *
+ * The drag coefficient is defined as:
+ *
+ * cd = 2Fd / (pv ^ 2)A
+ *
+ * Where:
+ *
+ * - @c Fd is the drag force, which is by definition the force component in the
+ * direction of the flow velocity;
+ * - @c p is the mass density;
+ * - @c v is the speed;
+ * - @c A is the reference area;
+ *
+ * The reference area depends on what type of drag coefficient is being measured.
+ *
+ * @note default value set to 0.
+ *
+ * @param body The body to be set.
+ * @param coefficient The drag coefficient.
+ *
+ * @see ephysics_body_soft_body_drag_coefficient_get().
+ *
+ * @ingroup EPhysics_Body
+ */
+EAPI void ephysics_body_soft_body_drag_coefficient_set(EPhysics_Body *body, double coefficient);
+
+/**
+ * @brief
+ * Get the drag coefficient of a soft body.
+ *
+ * @param body The body to get the drag coefficient from.
+ * @return The drag coefficient set to @p body on success, -1 on failure.
+ *
+ * @see ephysics_body_soft_body_drag_coefficient_set().
+ *
+ * @ingroup EPhysics_Body
+ */
+EAPI double ephysics_body_soft_body_drag_coefficient_get(const EPhysics_Body *body);
+
+/**
+ * @brief
* Set the soft body dragging status.
*
* While dragging a soft body the user may want to freeze a specific trimesh
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index f6b63e8ec..ed35f83b9 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -1806,6 +1806,45 @@ ephysics_body_soft_body_anchor_hardness_get(EPhysics_Body *body)
return body->soft_body->m_cfg.kAHR * 100;
}
+EAPI void
+ephysics_body_soft_body_drag_coefficient_set(EPhysics_Body *body, double coefficient)
+{
+ if (!body)
+ {
+ ERR("Can't set soft body's drag coefficient, body is null.");
+ return;
+ }
+
+ if (!body->soft_body)
+ {
+ ERR("Can't set soft body's drag coefficient, body seems not to be a soft"
+ " body.");
+ return;
+ }
+
+ body->soft_body->m_cfg.kDG = coefficient;
+ DBG("Soft body drag coefficient set to: %lf", coefficient);
+}
+
+EAPI double
+ephysics_body_soft_body_drag_coefficient_get(const EPhysics_Body *body)
+{
+ if (!body)
+ {
+ ERR("Can't get soft body's drag coefficient, body is null.");
+ return -1;
+ }
+
+ if (!body->soft_body)
+ {
+ ERR("Can't get soft body's drag coefficient, body seems not to be a soft"
+ " body.");
+ return -1;
+ }
+
+ return body->soft_body->m_cfg.kDG;
+}
+
static void
_ephysics_body_soft_body_hardness_set(EPhysics_Body *body, double hardness)
{