forked from enlightenment/efl
EPhysics: delete constraints if world is deleted
SVN revision: 75328
This commit is contained in:
parent
405c5affa1
commit
ebf3a282fb
|
@ -52,7 +52,8 @@ ephysics_constraint_slider_add(EPhysics_Body *body)
|
||||||
|
|
||||||
constraint->type = EPHYSICS_CONSTRAINT_SLIDER;
|
constraint->type = EPHYSICS_CONSTRAINT_SLIDER;
|
||||||
constraint->world = ephysics_body_world_get(body);
|
constraint->world = ephysics_body_world_get(body);
|
||||||
ephysics_world_constraint_add(constraint->world, constraint->bt_constraint);
|
ephysics_world_constraint_add(constraint->world, constraint,
|
||||||
|
constraint->bt_constraint);
|
||||||
|
|
||||||
INF("Constraint added.");
|
INF("Constraint added.");
|
||||||
return constraint;
|
return constraint;
|
||||||
|
@ -228,7 +229,8 @@ ephysics_constraint_p2p_add(EPhysics_Body *body1, EPhysics_Body *body2, Evas_Coo
|
||||||
|
|
||||||
constraint->type = EPHYSICS_CONSTRAINT_P2P;
|
constraint->type = EPHYSICS_CONSTRAINT_P2P;
|
||||||
constraint->world = ephysics_body_world_get(body1);
|
constraint->world = ephysics_body_world_get(body1);
|
||||||
ephysics_world_constraint_add(constraint->world, constraint->bt_constraint);
|
ephysics_world_constraint_add(constraint->world, constraint,
|
||||||
|
constraint->bt_constraint);
|
||||||
|
|
||||||
INF("Constraint added.");
|
INF("Constraint added.");
|
||||||
return constraint;
|
return constraint;
|
||||||
|
@ -243,7 +245,8 @@ ephysics_constraint_del(EPhysics_Constraint *constraint)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ephysics_world_constraint_del(constraint->world, constraint->bt_constraint);
|
ephysics_world_constraint_del(constraint->world, constraint,
|
||||||
|
constraint->bt_constraint);
|
||||||
delete constraint->bt_constraint;
|
delete constraint->bt_constraint;
|
||||||
free(constraint);
|
free(constraint);
|
||||||
|
|
||||||
|
|
|
@ -85,8 +85,8 @@ int ephysics_world_init(void);
|
||||||
int ephysics_world_shutdown(void);
|
int ephysics_world_shutdown(void);
|
||||||
Eina_Bool ephysics_world_body_add(EPhysics_World *world, EPhysics_Body *body);
|
Eina_Bool ephysics_world_body_add(EPhysics_World *world, EPhysics_Body *body);
|
||||||
Eina_Bool ephysics_world_body_del(EPhysics_World *world, EPhysics_Body *body);
|
Eina_Bool ephysics_world_body_del(EPhysics_World *world, EPhysics_Body *body);
|
||||||
void ephysics_world_constraint_add(EPhysics_World *world, btTypedConstraint *bt_constraint);
|
void ephysics_world_constraint_add(EPhysics_World *world, EPhysics_Constraint *constraint, btTypedConstraint *bt_constraint);
|
||||||
void ephysics_world_constraint_del(EPhysics_World *world, btTypedConstraint *bt_constraint);
|
void ephysics_world_constraint_del(EPhysics_World *world, EPhysics_Constraint *constraint, btTypedConstraint *bt_constraint);
|
||||||
void ephysics_body_world_boundaries_resize(EPhysics_World *world);
|
void ephysics_body_world_boundaries_resize(EPhysics_World *world);
|
||||||
void ephysics_world_boundary_set(EPhysics_World *world, EPhysics_World_Boundary boundary, EPhysics_Body *body);
|
void ephysics_world_boundary_set(EPhysics_World *world, EPhysics_World_Boundary boundary, EPhysics_Body *body);
|
||||||
EPhysics_Body *ephysics_world_boundary_get(const EPhysics_World *world, EPhysics_World_Boundary boundary);
|
EPhysics_Body *ephysics_world_boundary_get(const EPhysics_World *world, EPhysics_World_Boundary boundary);
|
||||||
|
|
|
@ -35,6 +35,7 @@ struct _EPhysics_World {
|
||||||
Eina_Inlist *bodies;
|
Eina_Inlist *bodies;
|
||||||
Eina_List *to_delete;
|
Eina_List *to_delete;
|
||||||
Eina_List *cb_to_delete;
|
Eina_List *cb_to_delete;
|
||||||
|
Eina_List *constraints;
|
||||||
int max_sub_steps;
|
int max_sub_steps;
|
||||||
int walking;
|
int walking;
|
||||||
int cb_walking;
|
int cb_walking;
|
||||||
|
@ -187,6 +188,7 @@ _ephysics_world_free(EPhysics_World *world)
|
||||||
{
|
{
|
||||||
EPhysics_World_Callback *cb;
|
EPhysics_World_Callback *cb;
|
||||||
EPhysics_Body *body;
|
EPhysics_Body *body;
|
||||||
|
void *constraint;
|
||||||
|
|
||||||
_worlds = eina_inlist_remove(_worlds, EINA_INLIST_GET(world));
|
_worlds = eina_inlist_remove(_worlds, EINA_INLIST_GET(world));
|
||||||
|
|
||||||
|
@ -206,6 +208,9 @@ _ephysics_world_free(EPhysics_World *world)
|
||||||
ephysics_orphan_body_del(body);
|
ephysics_orphan_body_del(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EINA_LIST_FREE(world->constraints, constraint)
|
||||||
|
ephysics_constraint_del((EPhysics_Constraint *)constraint);
|
||||||
|
|
||||||
ephysics_camera_del(world->camera);
|
ephysics_camera_del(world->camera);
|
||||||
/* FIXME uncomment lines above when dynamicsworld destructor is fixed
|
/* FIXME uncomment lines above when dynamicsworld destructor is fixed
|
||||||
on bullet. Right now looks like it will try to acess invalid memory.*/
|
on bullet. Right now looks like it will try to acess invalid memory.*/
|
||||||
|
@ -339,15 +344,17 @@ ephysics_world_body_del(EPhysics_World *world, EPhysics_Body *body)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ephysics_world_constraint_add(EPhysics_World *world, btTypedConstraint *bt_constraint)
|
ephysics_world_constraint_add(EPhysics_World *world, EPhysics_Constraint *constraint, btTypedConstraint *bt_constraint)
|
||||||
{
|
{
|
||||||
world->dynamics_world->addConstraint(bt_constraint);
|
world->dynamics_world->addConstraint(bt_constraint);
|
||||||
|
world->constraints = eina_list_append(world->constraints, constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ephysics_world_constraint_del(EPhysics_World *world, btTypedConstraint *bt_constraint)
|
ephysics_world_constraint_del(EPhysics_World *world, EPhysics_Constraint *constraint, btTypedConstraint *bt_constraint)
|
||||||
{
|
{
|
||||||
world->dynamics_world->removeConstraint(bt_constraint);
|
world->dynamics_world->removeConstraint(bt_constraint);
|
||||||
|
world->constraints = eina_list_remove(world->constraints, constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in New Issue