I am having an issue using chipmunk/ccphysics for collision detection in my project. The issue is that my scene contains lots of overlapping objects that and they all need to generate collision callbacks.
For example, I have two types of ccphysicsbody, R1 and R2, each with very small graphical nodes but large ccphysicsbody. Collision categories and masks are setup such that R1 and R2 only generate collisions between different groups but not within same group.
The problem is when a large amount of those ccphysicsbodies are generated at once (30 for each group so 60 in total), physics simulation becomes very slow ~10 fps because they generate exact 1800 collision callbacks at once. 1800 is expected because it is 30*30*2 but it is basically the O(n^2) of all the objects.
I also tried to use pointQueryAt() from ccphysicsnode but it cannot specify the collision category thus it also generate 1800 ccphysicsbody found (59+58+57+....+1) so it is no better way off.
Is there any better way to fix this issue? I am thinking of adding a queue to hold the pointQueryAt() request so for each update(), only a few of them are called.