bdilly pushed a commit to branch master.
Author: Bruno Dilly <bdi...@profusion.mobi>
Date: Mon Oct 17 15:14:47 2016 -0200
Fix abortion on bodies deletion
Fix issues when deleting static bodies (when you change levels
or presse menu option).
It was leading to the following error:
Aborting due to Chipmunk error: Cannot remove a body that was not
added to the space. (Removed twice maybe?)
Failed condition: cpSpaceContainsBody(space, body)
Static bodies shouldn't be added to space on Chipmunk, and that's correct.
But for some reason we're trying to remove them from space under
src/bin/physic_object.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/bin/physic_object.c b/src/bin/physic_object.c
index 1f365e5..387768a 100644
@@ -520,7 +520,10 @@ void physic_object_del(PhysicObject *pobj)
- cpSpaceRemoveBody(space, pobj->body);
+ // But don't try to remove static bodies, since they're not
+ // added to space (otherwise they would be simulated).
+ if (!pobj->static_body)
+ cpSpaceRemoveBody(space, pobj->body);
physic_objects = eina_list_remove(physic_objects, pobj);