ephysics: free overlap filter callback

This patch makes sure the overlap filter callback instance is removed
on world removal.


Patch by: Leandro Dorileo <dorileo@profusion.mobi>



SVN revision: 77454
This commit is contained in:
Leandro Dorileo 2012-10-04 22:38:00 +00:00 committed by Bruno Dilly
parent 62f7b42c3b
commit cfdd39c2d7
1 changed files with 6 additions and 4 deletions

View File

@ -31,6 +31,7 @@ struct _EPhysics_World {
btSoftRigidDynamicsWorld* dynamics_world; btSoftRigidDynamicsWorld* dynamics_world;
btSoftBodyWorldInfo* world_info; btSoftBodyWorldInfo* world_info;
btSoftBodySolver* soft_solver; btSoftBodySolver* soft_solver;
btOverlapFilterCallback *filter_cb;
EPhysics_Body *boundaries[4]; EPhysics_Body *boundaries[4];
EPhysics_Camera *camera; EPhysics_Camera *camera;
@ -276,6 +277,7 @@ _ephysics_world_free(EPhysics_World *world)
ephysics_camera_del(world->camera); ephysics_camera_del(world->camera);
delete world->filter_cb;
delete world->dynamics_world; delete world->dynamics_world;
delete world->solver; delete world->solver;
delete world->broadphase; delete world->broadphase;
@ -487,7 +489,6 @@ EAPI EPhysics_World *
ephysics_world_new(void) ephysics_world_new(void)
{ {
EPhysics_World *world; EPhysics_World *world;
btOverlapFilterCallback *filter_cb;
world = (EPhysics_World *) calloc(1, sizeof(EPhysics_World)); world = (EPhysics_World *) calloc(1, sizeof(EPhysics_World));
if (!world) if (!world)
@ -570,11 +571,12 @@ ephysics_world_new(void)
EPHYSICS_WORLD_SOLVER_SIMD; EPHYSICS_WORLD_SOLVER_SIMD;
world->dynamics_world->setGravity(DEFAULT_GRAVITY); world->dynamics_world->setGravity(DEFAULT_GRAVITY);
filter_cb = new _ephysics_world_ovelap_filter_cb(); world->filter_cb = new _ephysics_world_ovelap_filter_cb();
if (!filter_cb) if (!world->filter_cb)
INF("Couldn't initialize the collision filter."); INF("Couldn't initialize the collision filter.");
else else
world->dynamics_world->getPairCache()->setOverlapFilterCallback(filter_cb); world->dynamics_world->getPairCache()->setOverlapFilterCallback(
world->filter_cb);
world->rate = 30; world->rate = 30;
world->max_sub_steps = 3; world->max_sub_steps = 3;