I use the ChipmunkHastySpace with no changes.
I can't really debug because the problem is so rare. So I print out the properties of all added objects and check if they are added to the space or not. I looks normal in this respect.
The problem is hard to grasp and replicate. The best setup to replicate it is to have a static body.
On that body I add a chipmunk object. Cube A. I add another cube B
inside the static object and it moves up into the previous cube without any collision. If I add a third cube it will collide with both the first and second cube.
I added a special check in my CollisionHandler:
Code: Select all
if(object1.type == CUBE && object2.type == CUBE){
NSLog(@"CUBE COLLISION");
return YES;
}
The first two objects A and B doesn't collide with each other. But with all other objects. They can share the same space and if I delete A, all other cubes will interact normally with B.
The problem probably hasn't anything to do with the static body. It can be replicated by just adding objects on top of each other but it takes a random number of objects to make it fail or a massive burst of added objects in the same region in space.
The cubes are made in a factory class and share creation process with more complex objects. I wonder if this has anything to do with it. They are added by using the following method:
Code: Select all
@synchronized(self.space){
id obj = [self.space smartAdd:object];
}