summaryrefslogtreecommitdiff
path: root/legacy/ephysics
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
parentd435db293105f9319fc8865558bd0edac104d318 (diff)
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')
-rw-r--r--legacy/ephysics/src/bin/test_flip_page.c1
-rw-r--r--legacy/ephysics/src/lib/EPhysics.h47
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp39
3 files changed, 87 insertions, 0 deletions
diff --git a/legacy/ephysics/src/bin/test_flip_page.c b/legacy/ephysics/src/bin/test_flip_page.c
index 32d68d7aad..2003d41768 100644
--- a/legacy/ephysics/src/bin/test_flip_page.c
+++ b/legacy/ephysics/src/bin/test_flip_page.c
@@ -163,6 +163,7 @@ _page_add(Test_Data *test_data, EPhysics_Body *anchor, const char *img, Evas_Coo
163 evas_object_geometry_get(evas_obj, &page_data->x, NULL, NULL, NULL); 163 evas_object_geometry_get(evas_obj, &page_data->x, NULL, NULL, NULL);
164 164
165 body = ephysics_body_cloth_add(test_data->world, 10, 20); 165 body = ephysics_body_cloth_add(test_data->world, 10, 20);
166 ephysics_body_soft_body_drag_coefficient_set(body, 0.0008);
166 ephysics_body_soft_body_position_iterations_set(body, 6); 167 ephysics_body_soft_body_position_iterations_set(body, 6);
167 ephysics_body_soft_body_bending_constraints_add(body, 1); 168 ephysics_body_soft_body_bending_constraints_add(body, 1);
168 ephysics_body_restitution_set(body, 0); 169 ephysics_body_restitution_set(body, 0);
diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h
index 5a3f9b124f..5647134982 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);
2372 2372
2373/** 2373/**
2374 * @brief 2374 * @brief
2375 * Set the drag coefficient of a soft body.
2376 *
2377 * Drag coefficient is a dimensionless quantity used to quantify an objects drag
2378 * or resistance in the environment - like air or water resistance. It is used in
2379 * the drag equation, where a lower drag coefficient indicates the object will
2380 * have less aerodynamic or hydrodynamic drag.
2381 *
2382 * The drag coefficient is defined as:
2383 *
2384 * cd = 2Fd / (pv ^ 2)A
2385 *
2386 * Where:
2387 *
2388 * - @c Fd is the drag force, which is by definition the force component in the
2389 * direction of the flow velocity;
2390 * - @c p is the mass density;
2391 * - @c v is the speed;
2392 * - @c A is the reference area;
2393 *
2394 * The reference area depends on what type of drag coefficient is being measured.
2395 *
2396 * @note default value set to 0.
2397 *
2398 * @param body The body to be set.
2399 * @param coefficient The drag coefficient.
2400 *
2401 * @see ephysics_body_soft_body_drag_coefficient_get().
2402 *
2403 * @ingroup EPhysics_Body
2404 */
2405EAPI void ephysics_body_soft_body_drag_coefficient_set(EPhysics_Body *body, double coefficient);
2406
2407/**
2408 * @brief
2409 * Get the drag coefficient of a soft body.
2410 *
2411 * @param body The body to get the drag coefficient from.
2412 * @return The drag coefficient set to @p body on success, -1 on failure.
2413 *
2414 * @see ephysics_body_soft_body_drag_coefficient_set().
2415 *
2416 * @ingroup EPhysics_Body
2417 */
2418EAPI double ephysics_body_soft_body_drag_coefficient_get(const EPhysics_Body *body);
2419
2420/**
2421 * @brief
2375 * Set the soft body dragging status. 2422 * Set the soft body dragging status.
2376 * 2423 *
2377 * While dragging a soft body the user may want to freeze a specific trimesh 2424 * 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 f6b63e8ecf..ed35f83b98 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)
1806 return body->soft_body->m_cfg.kAHR * 100; 1806 return body->soft_body->m_cfg.kAHR * 100;
1807} 1807}
1808 1808
1809EAPI void
1810ephysics_body_soft_body_drag_coefficient_set(EPhysics_Body *body, double coefficient)
1811{
1812 if (!body)
1813 {
1814 ERR("Can't set soft body's drag coefficient, body is null.");
1815 return;
1816 }
1817
1818 if (!body->soft_body)
1819 {
1820 ERR("Can't set soft body's drag coefficient, body seems not to be a soft"
1821 " body.");
1822 return;
1823 }
1824
1825 body->soft_body->m_cfg.kDG = coefficient;
1826 DBG("Soft body drag coefficient set to: %lf", coefficient);
1827}
1828
1829EAPI double
1830ephysics_body_soft_body_drag_coefficient_get(const EPhysics_Body *body)
1831{
1832 if (!body)
1833 {
1834 ERR("Can't get soft body's drag coefficient, body is null.");
1835 return -1;
1836 }
1837
1838 if (!body->soft_body)
1839 {
1840 ERR("Can't get soft body's drag coefficient, body seems not to be a soft"
1841 " body.");
1842 return -1;
1843 }
1844
1845 return body->soft_body->m_cfg.kDG;
1846}
1847
1809static void 1848static void
1810_ephysics_body_soft_body_hardness_set(EPhysics_Body *body, double hardness) 1849_ephysics_body_soft_body_hardness_set(EPhysics_Body *body, double hardness)
1811{ 1850{