Sensors and default collision handlers
Posted: Fri Oct 15, 2010 7:41 am
I'm quite new to Chipmunk, so I apologize if this is a foolish question, but today I ran into what to me seems an odd design decision in the engine.
I set up a sensor in the usual fashion, and added it to a space's static body. I also added a couple of normal bodies and shapes to float around. I set some default collision callbacks, then ran my program. The sensors never registered a collision.
Some investigation and confusion later, I found a line inside the implementation of cpSpace which jumps out of collision handling if either object involved is a sensor and the collision handler is the default for the space.
I eventually realized that my design for the specific situation was flawed and that I could make the sensors work with a specific collision type, but I couldn't make sense of why the code does this. It seems to make it impossible to use a sensor that detects collisions with all shapes in the space, unless I've misunderstood that there seems to be no wildcard value for collision types. Can someone explain to me why this is?
The offending code is in cpSpaceStep.c, line 161 (as of version 5.3.2, though I looked in SVN and it appears to go all the way back to the original implementation of sensors).
I set up a sensor in the usual fashion, and added it to a space's static body. I also added a couple of normal bodies and shapes to float around. I set some default collision callbacks, then ran my program. The sensors never registered a collision.
Some investigation and confusion later, I found a line inside the implementation of cpSpace which jumps out of collision handling if either object involved is a sensor and the collision handler is the default for the space.
I eventually realized that my design for the specific situation was flawed and that I could make the sensors work with a specific collision type, but I couldn't make sense of why the code does this. It seems to make it impossible to use a sensor that detects collisions with all shapes in the space, unless I've misunderstood that there seems to be no wildcard value for collision types. Can someone explain to me why this is?
The offending code is in cpSpaceStep.c, line 161 (as of version 5.3.2, though I looked in SVN and it appears to go all the way back to the original implementation of sensors).