EPhysics: constraint solver iterations

Functions to get and set the constraint solver number of iterations.

Patch by Leandro Dorileo <dorileo@profusion.mobi>



SVN revision: 73249
This commit is contained in:
Bruno Dilly 2012-07-03 23:24:27 +00:00
parent dc3455c888
commit d1ba36f4ba
2 changed files with 60 additions and 0 deletions

View File

@ -442,6 +442,42 @@ EAPI Eina_Bool ephysics_world_running_get(const EPhysics_World *world);
*/
EAPI void ephysics_world_gravity_set(EPhysics_World *world, double gx, double gy);
/**
* @brief
* Set the number of iterations the constraint solver will have for contact and
* joint constraints.
*
* The default value is set to 10. The greater number of iterations more
* quality and precise the result but with performance penalty.
*
* By default, the Projected Gauss Seidel constraint solver is used for contact
* and joint constraints. The algorithm is an iterative LCP solver, informally
* known as 'sequential impulse'.
*
* A reasonable range of iterations is from 4 (low quality, good performance)
* to 20 (good quality, less but still reasonable performance).
*
* @param world The world to be set.
* @param iterations The number of iterations to be set.
*
* @see ephysics_world_constraint_solver_iterations_get().
* @ingroup EPhysics_World
*/
EAPI void ephysics_world_constraint_solver_iterations_set(EPhysics_World *world, int iterations);
/**
* @brief
* Get the number of iterations the constraint solver will have for contact and
* joint constraints.
*
* @param world The world to get number of iterations from.
* @return the number of iterations set to @p world, or 0 on failure.
*
* @see ephysics_world_constraint_solver_iterations_set() for its meaning.
* @ingroup EPhysics_World
*/
EAPI int ephysics_world_constraint_solver_iterations_get(EPhysics_World *world);
/**
* @brief
* Get world gravity values for axis x and y.

View File

@ -471,6 +471,30 @@ ephysics_world_gravity_set(EPhysics_World *world, double gx, double gy)
DBG("World %p gravity set to X:%lf, Y:%lf.", world, gx, gy);
}
EAPI void
ephysics_world_constraint_solver_iterations_set(EPhysics_World *world, int iterations)
{
if (!world)
{
ERR("Can't set constraint solver iterations, world is null.");
return;
}
world->dynamics_world->getSolverInfo().m_numIterations = iterations;
}
EAPI int
ephysics_world_constraint_solver_iterations_get(EPhysics_World *world)
{
if (!world)
{
ERR("Can't get constraint solver iterations, world is null.");
return 0;
}
return world->dynamics_world->getSolverInfo().m_numIterations;
}
EAPI void
ephysics_world_gravity_get(const EPhysics_World *world, double *gx, double *gy)
{