Rejecting collisions from begin() callback considered a bug?
Posted: Wed Jan 06, 2010 4:40 pm
I got an email from somebody this morning that made me think a bit about how rejecting collisions from the begin callback works.
As it is currently, if you reject a collision from begin(), preSolve() and postSolve() will not be called in the same step. However, the next step, begin() will not be called again and Chipmunk will go and call preSolve() and postSolve(). The default version of preSolve() simply accepts all collisions. This means that rejecting a collision from begin() only rejects the collision for the first step, and if you wanted to permanently reject a collision, you would have to do so by storing the value somewhere else and return false from ever call to preSolve(). Pretty much makes the return value of the begin() callback useless...
Having thought about it a little more now, it makes immensely more sense to make the rejection by begin() be permanent. Rejecting a collision from begin() means that preSolve() and postSolve() will never get called for as long as the collision collision and separate() would still be called when the shapes stop touching. Rejecting a collision from preSolve() should continue to be done for an individual frame, and a new function should be introduced to allow you to permanently reject a collision like begin() would.
Does this make sense, and should the current behavior be considered a bug needing to be fixed? Otherwise I will just add the function to permanently reject a collision and let people call that from begin() if that is what they want to happen.
As it is currently, if you reject a collision from begin(), preSolve() and postSolve() will not be called in the same step. However, the next step, begin() will not be called again and Chipmunk will go and call preSolve() and postSolve(). The default version of preSolve() simply accepts all collisions. This means that rejecting a collision from begin() only rejects the collision for the first step, and if you wanted to permanently reject a collision, you would have to do so by storing the value somewhere else and return false from ever call to preSolve(). Pretty much makes the return value of the begin() callback useless...
Having thought about it a little more now, it makes immensely more sense to make the rejection by begin() be permanent. Rejecting a collision from begin() means that preSolve() and postSolve() will never get called for as long as the collision collision and separate() would still be called when the shapes stop touching. Rejecting a collision from preSolve() should continue to be done for an individual frame, and a new function should be introduced to allow you to permanently reject a collision like begin() would.
Does this make sense, and should the current behavior be considered a bug needing to be fixed? Otherwise I will just add the function to permanently reject a collision and let people call that from begin() if that is what they want to happen.