active2staticIter crashing application

Official forum for the Chipmunk2D Physics Library.
teedr
Posts: 4
Joined: Sun Nov 08, 2009 6:31 pm
Contact:

Re: active2staticIter crashing application

Post by teedr »

Don't remove shapes in collision callbacks
OK...what is the best way to remove a shape upon collision then?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: active2staticIter crashing application

Post by slembcke »

You need to add them to a list or mark a boolean on your game objects to mark them for removal. Then after cpSpaceStep() returns it is safe to remove the objects. Be careful not to remove or free the same object twice.

Just this weekend, I was working on a callback system that runs just before cpSpaceStep() exits. It should make it easy to queue up removing/freeing chipmunk objects, and flexible enough to allow you to remove entire game objects from your game scene. It also nicely solves the problem of how to prevent removing/freeing an object more than once. Currently only available in the latest trunk code, it works great but is completely undocumented and I haven't quite settled on what the API should look like so I haven't put the function prototypes in the headers yet.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: active2staticIter crashing application

Post by slembcke »

See http://www.slembcke.net/forums/viewtopi ... 780&p=3467

Asking for feedback on the new API.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests