forked from enlightenment/efl
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
This commit is contained in:
parent
d435db2931
commit
4640e5cdca
|
@ -163,6 +163,7 @@ _page_add(Test_Data *test_data, EPhysics_Body *anchor, const char *img, Evas_Coo
|
|||
evas_object_geometry_get(evas_obj, &page_data->x, NULL, NULL, NULL);
|
||||
|
||||
body = ephysics_body_cloth_add(test_data->world, 10, 20);
|
||||
ephysics_body_soft_body_drag_coefficient_set(body, 0.0008);
|
||||
ephysics_body_soft_body_position_iterations_set(body, 6);
|
||||
ephysics_body_soft_body_bending_constraints_add(body, 1);
|
||||
ephysics_body_restitution_set(body, 0);
|
||||
|
|
|
@ -2370,6 +2370,53 @@ EAPI void ephysics_body_soft_body_anchor_hardness_set(EPhysics_Body *body, doubl
|
|||
*/
|
||||
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.
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue