I'm not using cpShape_New/ cpBodyNew functions, and allocating things with my own with wrapper structs holding a cpBody / cpShape (non pointer). So i'm not relying on cpSpaceFreeChildren.
The crash occurs when the game is shutting down a level (removing stuff) and seems to only happen when i have a sleeping body. It happens in cpSpaceRemoveShape where then it calls cpBodyActivate and somewhere in
Code: Select all
static inline cpBody *
componentNodeRoot(cpBody *body)
actually just now going over this i took a look at cpSpaceFreeChildren and notice that it starts off with
Code: Select all
cpArray *components = space->sleepingComponents;
while(components->num) cpBodyActivate((cpBody *)components->arr[0]);
So i guess I'm wondering if that's the best approach?
Also i'm removing the shapes from the space prior to the body i figure that's how to go about it. But maybe that's the problem?