diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h index 5b48fffdef..748dab279c 100644 --- a/legacy/ephysics/src/lib/EPhysics.h +++ b/legacy/ephysics/src/lib/EPhysics.h @@ -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. diff --git a/legacy/ephysics/src/lib/ephysics_world.cpp b/legacy/ephysics/src/lib/ephysics_world.cpp index ee74844806..235f60e15d 100644 --- a/legacy/ephysics/src/lib/ephysics_world.cpp +++ b/legacy/ephysics/src/lib/ephysics_world.cpp @@ -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) {