From a3f12a0ae084787c101e7dbffa7066ff7ba39795 Mon Sep 17 00:00:00 2001 From: Bruno Dilly Date: Thu, 16 Aug 2012 21:35:20 +0000 Subject: [PATCH] EPhysics: fix rate set implementation Update everything that depends on rate: - worlds - bodies - constraints SVN revision: 75335 --- legacy/ephysics/src/lib/ephysics_world.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/legacy/ephysics/src/lib/ephysics_world.cpp b/legacy/ephysics/src/lib/ephysics_world.cpp index 4975146685..292a42c1b6 100644 --- a/legacy/ephysics/src/lib/ephysics_world.cpp +++ b/legacy/ephysics/src/lib/ephysics_world.cpp @@ -752,6 +752,11 @@ ephysics_world_gravity_get(const EPhysics_World *world, double *gx, double *gy) EAPI void ephysics_world_rate_set(EPhysics_World *world, double rate) { + EPhysics_Body *body; + void *constraint; + double gx, gy; + Eina_List *l; + if (!world) { ERR("No world, can't set rate."); @@ -765,7 +770,16 @@ ephysics_world_rate_set(EPhysics_World *world, double rate) return; } - /* FIXME update objects considering new rate */ + /* Force to recalculate sizes, velocities and accelerations with new rate */ + ephysics_world_gravity_get(world, &gx, &gy); + _ephysics_world_gravity_set(world, gx, gy, rate); + + EINA_INLIST_FOREACH(world->bodies, body) + ephysics_body_recalc(body, rate); + + EINA_LIST_FOREACH(world->constraints, l, constraint) + ephysics_constraint_recalc((EPhysics_Constraint *)constraint, rate); + world->rate = rate; }