EPhysics: soft body position solver iterations

This patch introduces getters and setters API for setting the
soft body position solver iterations.


Patch by: Leandro Dorileo <dorileo@profusion.mobi>



SVN revision: 78486
This commit is contained in:
Leandro Dorileo 2012-10-25 21:54:37 +00:00 committed by Bruno Dilly
parent a360657718
commit b0bd7beac3
2 changed files with 77 additions and 0 deletions

View File

@ -1912,6 +1912,42 @@ EAPI void ephysics_body_soft_body_dragging_unset(EPhysics_Body *body);
*/
EAPI int ephysics_body_soft_body_triangle_index_get(EPhysics_Body *body, Evas_Coord x, Evas_Coord y);
/**
* @brief
* Set the soft body number of position iterations.
*
* Both soft body and cloth can have its number of position iterations changed.
* The number of position iterations will change how many time the physics engine
* will iterate the position solver, a greater value will change deformation
* behaves and how hard the soft body looks like. The greater position iterations
* the harder the soft body will be.
*
* @node For soft bodies the default value is set to 1, and for cloth it's set to
* the number of rows / 5;
*
* @param body The body to be set.
* @param iterations The number of iterations.
*
* @see ephysics_body_cloth_add() for more informations about cloth.
* @see ephysics_body_soft_body_position_iterations_get().
*
* @ingroup EPhysics_Body
*/
EAPI void ephysics_body_soft_body_position_iterations_set(EPhysics_Body *body, int iterations);
/**
* @brief
* Get the soft body number of position iterations.
*
* @param body The body to get the number os position iterations from.
* @return The number of position solver iterations of a soft @p body.
*
* @see ephysics_body_soft_body_position_iterations_set().
*
* @ingroup EPhysics_Body
*/
EAPI int ephysics_body_soft_body_position_iterations_get(EPhysics_Body *body);
/**
* @brief
* Move a body's triangle.

View File

@ -1571,6 +1571,47 @@ _ephysics_body_slices_add(EPhysics_Body *body, double delta, double max)
return EINA_TRUE;
}
EAPI void
ephysics_body_soft_body_position_iterations_set(EPhysics_Body *body, int iterations)
{
if (!body)
{
ERR("Could not set the number of iterations for position solver, body "
"is null.");
return;
}
if (body->type == EPHYSICS_BODY_TYPE_RIGID)
{
ERR("Could not set the number of iterations for position solver, body "
"must be a soft body or a cloth");
return;
}
body->soft_body->m_cfg.piterations = iterations;
DBG("Soft body position solver iterations set to: %d", iterations);
}
EAPI int
ephysics_body_soft_body_position_iterations_get(EPhysics_Body *body)
{
if (!body)
{
ERR("Could not get the number of iterations for position solver, body "
"is null.");
return 0;
}
if (body->type == EPHYSICS_BODY_TYPE_RIGID)
{
ERR("Could not get the number of iterations for position solver, body "
"must be a soft body or a cloth");
return 0;
}
return body->soft_body->m_cfg.piterations;
}
EAPI EPhysics_Body *
ephysics_body_cloth_add(EPhysics_World *world, unsigned short granularity)
{