From 4a1a773d2710d005141feabecf40f53830e60ed6 Mon Sep 17 00:00:00 2001 From: Leandro Dorileo Date: Mon, 3 Dec 2012 21:29:03 +0000 Subject: [PATCH] EPhysics: force body update on light/perspective changes If light configuration has been changed or perspective changed or simply enabled/disabled force inactive bodies to update. --This line, and those below, will be ignored-- SVN revision: 80105 --- legacy/ephysics/src/lib/ephysics_camera.cpp | 2 ++ legacy/ephysics/src/lib/ephysics_private.h | 1 + legacy/ephysics/src/lib/ephysics_world.cpp | 14 +++++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/legacy/ephysics/src/lib/ephysics_camera.cpp b/legacy/ephysics/src/lib/ephysics_camera.cpp index f315f5d..e1d9566 100644 --- a/legacy/ephysics/src/lib/ephysics_camera.cpp +++ b/legacy/ephysics/src/lib/ephysics_camera.cpp @@ -228,6 +228,7 @@ ephysics_camera_perspective_set(EPhysics_Camera *camera, Evas_Coord px, Evas_Coo camera->perspective.py = py; camera->perspective.z0 = z0; camera->perspective.foc = foc; + ephysics_world_force_update_set(camera->world, EINA_TRUE); } EAPI void @@ -255,6 +256,7 @@ ephysics_camera_perspective_enabled_set(EPhysics_Camera *camera, Eina_Bool enabl } camera->perspective.enabled = !!enabled; + ephysics_world_force_update_set(camera->world, EINA_TRUE); } EAPI Eina_Bool diff --git a/legacy/ephysics/src/lib/ephysics_private.h b/legacy/ephysics/src/lib/ephysics_private.h index 8afeee7..0b96a6c 100644 --- a/legacy/ephysics/src/lib/ephysics_private.h +++ b/legacy/ephysics/src/lib/ephysics_private.h @@ -185,6 +185,7 @@ btSoftBodyWorldInfo *ephysics_world_info_get(const EPhysics_World *world); void ephysics_world_lock_take(EPhysics_World *world); void ephysics_world_lock_release(EPhysics_World *world); Eina_List *ephysics_world_constraints_get(EPhysics_World *world); +void ephysics_world_force_update_set(EPhysics_World *world, Eina_Bool force_update); /* Body */ Eina_Bool ephysics_body_filter_collision(EPhysics_Body *body0, EPhysics_Body *body1); diff --git a/legacy/ephysics/src/lib/ephysics_world.cpp b/legacy/ephysics/src/lib/ephysics_world.cpp index 2aef765..6c9ca35 100644 --- a/legacy/ephysics/src/lib/ephysics_world.cpp +++ b/legacy/ephysics/src/lib/ephysics_world.cpp @@ -99,6 +99,7 @@ struct _EPhysics_World { Eina_Bool outside_back:1; Eina_Bool pending_simulation:1; Eina_Bool stacking:1; + Eina_Bool force_update:1; }; static int _ephysics_world_init_count = 0; @@ -108,6 +109,12 @@ static Eina_List *_worlds_to_delete = NULL; static Ecore_Animator *_anim_simulate = NULL; static int _worlds_walking = 0; +void +ephysics_world_force_update_set(EPhysics_World *world, Eina_Bool force_update) +{ + world->force_update = force_update; +} + btSoftBodyWorldInfo * ephysics_world_info_get(const EPhysics_World *world) { @@ -235,7 +242,7 @@ _ephysics_world_tick(btDynamicsWorld *dynamics_world) else { ephysics_body_active_set(body, EINA_FALSE); - if (camera_moved) + if (camera_moved || world->force_update) ephysics_body_evas_object_update_select(body); } } @@ -243,6 +250,7 @@ _ephysics_world_tick(btDynamicsWorld *dynamics_world) if (world->stacking) ephysics_body_evas_objects_restack(world); + world->force_update = EINA_FALSE; if (camera_moved) { ephysics_camera_moved_set(world->camera, EINA_FALSE); @@ -1540,6 +1548,7 @@ ephysics_world_point_light_position_set(EPhysics_World *world, Evas_Coord lx, Ev world->light.lx = lx; world->light.ly = ly; world->light.lz = lz; + world->force_update = EINA_TRUE; } EAPI void @@ -1554,6 +1563,7 @@ ephysics_world_point_light_color_set(EPhysics_World *world, int lr, int lg, int world->light.lr = lr; world->light.lg = lg; world->light.lb = lb; + world->force_update = EINA_TRUE; } EAPI void @@ -1568,6 +1578,7 @@ ephysics_world_ambient_light_color_set(EPhysics_World *world, int ar, int ag, in world->light.ar = ar; world->light.ag = ag; world->light.ab = ab; + world->force_update = EINA_TRUE; } EAPI void @@ -1622,6 +1633,7 @@ ephysics_world_light_all_bodies_set(EPhysics_World *world, Eina_Bool enable) } world->light.all_bodies = !!enable; + world->force_update = EINA_TRUE; } EAPI Eina_Bool -- 2.7.4