From d0f93b0aaaf70cd94a4d83c3b5030cd238f34289 Mon Sep 17 00:00:00 2001 From: Leandro Dorileo Date: Fri, 9 Nov 2012 18:58:51 +0000 Subject: [PATCH] EPhysics: do not wait to disassociate a boundary If a user has asked for a boundary deletion do not wait until body_del callback to clean it up to avoid returning a body marked for deletion case the user decided to add it again. Patch by: Leandro Dorileo SVN revision: 79057 --- legacy/ephysics/src/lib/ephysics_body.cpp | 1 + legacy/ephysics/src/lib/ephysics_private.h | 1 + legacy/ephysics/src/lib/ephysics_world.cpp | 36 +++++++++++----------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp index 7459f6012b..f2cdc8e1eb 100644 --- a/legacy/ephysics/src/lib/ephysics_body.cpp +++ b/legacy/ephysics/src/lib/ephysics_body.cpp @@ -2467,6 +2467,7 @@ _ephysics_body_boundary_add(EPhysics_World *world, EPhysics_World_Boundary bound if (!body) return NULL; + body->boundary = EINA_TRUE; ephysics_body_mass_set(body, 0); ephysics_world_boundary_set(world, boundary, body); ephysics_body_geometry_set(body, x, y, z, w, h, d); diff --git a/legacy/ephysics/src/lib/ephysics_private.h b/legacy/ephysics/src/lib/ephysics_private.h index fd21f28cd0..f7757301bf 100644 --- a/legacy/ephysics/src/lib/ephysics_private.h +++ b/legacy/ephysics/src/lib/ephysics_private.h @@ -150,6 +150,7 @@ struct _EPhysics_Body { Eina_Bool light_apply:1; Eina_Bool back_face_culling:1; Eina_Bool clockwise:1; + Eina_Bool boundary:1; }; extern int _ephysics_log_dom; diff --git a/legacy/ephysics/src/lib/ephysics_world.cpp b/legacy/ephysics/src/lib/ephysics_world.cpp index 68054e2ad4..15538feb82 100644 --- a/legacy/ephysics/src/lib/ephysics_world.cpp +++ b/legacy/ephysics/src/lib/ephysics_world.cpp @@ -316,11 +316,29 @@ _ephysics_world_body_del(EPhysics_World *world, EPhysics_Body *body) ephysics_orphan_body_del(body); } +static void +_ephysics_world_boundary_del(EPhysics_World *world, EPhysics_Body *body) +{ + int i; + + for (i = 0; i < EPHYSICS_WORLD_BOUNDARY_LAST; i++) + { + if (world->boundaries[i] == body) + { + world->boundaries[i] = NULL; + return; + } + } +} + Eina_Bool ephysics_world_body_del(EPhysics_World *world, EPhysics_Body *body) { EPhysics_Body *bd; + if (body->boundary) + _ephysics_world_boundary_del(world, body); + if (world->pending_ticks) { world->to_delete = eina_list_append(world->to_delete, body); @@ -448,22 +466,6 @@ _ephysics_world_contact_processed_cb(btManifoldPoint &cp, void *b0, void *b1) return EINA_TRUE; } -static void -_ephysics_world_boundary_del_cb(void *data, EPhysics_Body *body, void *event_info __UNUSED__) -{ - EPhysics_World *world = (EPhysics_World *) data; - int i; - - for (i = 0; i < EPHYSICS_WORLD_BOUNDARY_LAST; i++) - { - if (world->boundaries[i] == body) - { - world->boundaries[i] = NULL; - return; - } - } -} - Eina_Bool ephysics_world_body_add(EPhysics_World *world, EPhysics_Body *body) { @@ -554,8 +556,6 @@ void ephysics_world_boundary_set(EPhysics_World *world, EPhysics_World_Boundary boundary, EPhysics_Body *body) { world->boundaries[boundary] = body; - ephysics_body_event_callback_add(body, EPHYSICS_CALLBACK_BODY_DEL, - _ephysics_world_boundary_del_cb, world); } EPhysics_Body *