| 38 | static void PostStepDoNothing(cpSpace *space, void *obj, void *data){} |
| 39 | |
| 40 | cpBool |
| 41 | cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *key, void *data) |
| 42 | { |
| 43 | cpAssertWarn(space->locked, |
| 44 | "Adding a post-step callback when the space is not locked is unnecessary. " |
| 45 | "Post-step callbacks will not called until the end of the next call to cpSpaceStep() or the next query."); |
| 46 | |
| 47 | if(!cpSpaceGetPostStepCallback(space, key)){ |
| 48 | cpPostStepCallback *callback = (cpPostStepCallback *)cpcalloc(1, sizeof(cpPostStepCallback)); |
| 49 | callback->func = (func ? func : PostStepDoNothing); |
| 50 | callback->key = key; |
| 51 | callback->data = data; |
| 52 | |
| 53 | cpArrayPush(space->postStepCallbacks, callback); |
| 54 | return cpTrue; |
| 55 | } else { |
| 56 | return cpFalse; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | //MARK: Locking Functions |
| 61 | |