summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2012-11-09 18:58:51 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-11-09 18:58:51 +0000
commitd0f93b0aaaf70cd94a4d83c3b5030cd238f34289 (patch)
tree096839f43909f7f9a21a9160c4aaf2dbe7e3b95d /legacy
parentbe9c5adb457842e4ea9515d92e722d58894fedca (diff)
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 <dorileo@profusion.mobi> SVN revision: 79057
Diffstat (limited to 'legacy')
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp1
-rw-r--r--legacy/ephysics/src/lib/ephysics_private.h1
-rw-r--r--legacy/ephysics/src/lib/ephysics_world.cpp36
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
2467 if (!body) 2467 if (!body)
2468 return NULL; 2468 return NULL;
2469 2469
2470 body->boundary = EINA_TRUE;
2470 ephysics_body_mass_set(body, 0); 2471 ephysics_body_mass_set(body, 0);
2471 ephysics_world_boundary_set(world, boundary, body); 2472 ephysics_world_boundary_set(world, boundary, body);
2472 ephysics_body_geometry_set(body, x, y, z, w, h, d); 2473 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 {
150 Eina_Bool light_apply:1; 150 Eina_Bool light_apply:1;
151 Eina_Bool back_face_culling:1; 151 Eina_Bool back_face_culling:1;
152 Eina_Bool clockwise:1; 152 Eina_Bool clockwise:1;
153 Eina_Bool boundary:1;
153}; 154};
154 155
155extern int _ephysics_log_dom; 156extern 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)
316 ephysics_orphan_body_del(body); 316 ephysics_orphan_body_del(body);
317} 317}
318 318
319static void
320_ephysics_world_boundary_del(EPhysics_World *world, EPhysics_Body *body)
321{
322 int i;
323
324 for (i = 0; i < EPHYSICS_WORLD_BOUNDARY_LAST; i++)
325 {
326 if (world->boundaries[i] == body)
327 {
328 world->boundaries[i] = NULL;
329 return;
330 }
331 }
332}
333
319Eina_Bool 334Eina_Bool
320ephysics_world_body_del(EPhysics_World *world, EPhysics_Body *body) 335ephysics_world_body_del(EPhysics_World *world, EPhysics_Body *body)
321{ 336{
322 EPhysics_Body *bd; 337 EPhysics_Body *bd;
323 338
339 if (body->boundary)
340 _ephysics_world_boundary_del(world, body);
341
324 if (world->pending_ticks) 342 if (world->pending_ticks)
325 { 343 {
326 world->to_delete = eina_list_append(world->to_delete, body); 344 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)
448 return EINA_TRUE; 466 return EINA_TRUE;
449} 467}
450 468
451static void
452_ephysics_world_boundary_del_cb(void *data, EPhysics_Body *body, void *event_info __UNUSED__)
453{
454 EPhysics_World *world = (EPhysics_World *) data;
455 int i;
456
457 for (i = 0; i < EPHYSICS_WORLD_BOUNDARY_LAST; i++)
458 {
459 if (world->boundaries[i] == body)
460 {
461 world->boundaries[i] = NULL;
462 return;
463 }
464 }
465}
466
467Eina_Bool 469Eina_Bool
468ephysics_world_body_add(EPhysics_World *world, EPhysics_Body *body) 470ephysics_world_body_add(EPhysics_World *world, EPhysics_Body *body)
469{ 471{
@@ -554,8 +556,6 @@ void
554ephysics_world_boundary_set(EPhysics_World *world, EPhysics_World_Boundary boundary, EPhysics_Body *body) 556ephysics_world_boundary_set(EPhysics_World *world, EPhysics_World_Boundary boundary, EPhysics_Body *body)
555{ 557{
556 world->boundaries[boundary] = body; 558 world->boundaries[boundary] = body;
557 ephysics_body_event_callback_add(body, EPHYSICS_CALLBACK_BODY_DEL,
558 _ephysics_world_boundary_del_cb, world);
559} 559}
560 560
561EPhysics_Body * 561EPhysics_Body *