forked from enlightenment/efl
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
This commit is contained in:
parent
be9c5adb45
commit
d0f93b0aaa
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 *
|
||||
|
|
Loading…
Reference in New Issue