Should I do this to ContactAddedCallback?

Post Reply
thePoet
Posts: 17
Joined: Tue Apr 15, 2008 4:14 pm

Should I do this to ContactAddedCallback?

Post by thePoet »

I have a need to cancel the collision response once the collision has been detected (at the narrow phase, so after NeedsResponse). I'm looking for different ideas on the best way to do this.

One option would be to enhance the ContactAddedCallback to use the return value to remove the contact point from the manifold. Right now there is an unused bool return value (at least, I haven't seen it used in my research). Are there plans for this return value? I wouldn't want to change my internal version of bullet to use an unused variable that you may use in the near future. Or, is this something that others would want to use, in which case I could submit the code (which appears to be simple).

Are there other/better options? Perhaps I'm missing something really obvious.

** Edit: Changed title to better describe question.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Should I do this to ContactAddedCallback?

Post by Erwin Coumans »

Do you really want to disable collision response for a single contact point, or between two objects?

Have you considered to disable collision response for an object, by setting a collision flag 'CF_NO_CONTACT_RESPONSE'.

You have a good suggestion, but it breaks the API without any warning. So if we really want to go this route, we better change/improve the API so developers have to explicitly change their game code.

Thanks for the feedback,
Erwin
thePoet
Posts: 17
Joined: Tue Apr 15, 2008 4:14 pm

Re: Should I do this to ContactAddedCallback?

Post by thePoet »

Optimally I would stop the response at an object level, but I haven't found a way to do that, and allow full collision detection, without really tearing things apart. It appears that CF_NO_CONTACT_RESPONSE is checked in needsResponse (by calling hasContactResponse). I believe that the actual collision detection hasn't occurred at that point (only the bounding box). I'm currently using a custom needsResponse now to allow for a more flexible canceling method, so I'm actually ignoring CF_NO_CONTACT_RESPONSE for that custom set of checks. ContactAddedCallback appears to be the only place where I can currently hook into that will tell me that a collision occurred, and still be in a place where it is possible to kill the response (even if it was a minor bit of custom code).

Is there another place you would suggest I could build out this functionality on an object level? I've contemplated building in another no-response flag that would kill response after the collision process, but I haven't looked too deeply into where that would need to go. But if that existed, I think I could post process the collision manifold to detect which objects collided and not worry about the response.
rraallvv
Posts: 30
Joined: Thu Feb 09, 2012 2:39 am

Re: Should I do this to ContactAddedCallback?

Post by rraallvv »

thePoet wrote:I have a need to cancel the collision response once the collision has been detected (at the narrow phase, so after NeedsResponse). I'm looking for different ideas on the best way to do this.

One option would be to enhance the ContactAddedCallback to use the return value to remove the contact point from the manifold. Right now there is an unused bool return value (at least, I haven't seen it used in my research). Are there plans for this return value? I wouldn't want to change my internal version of bullet to use an unused variable that you may use in the near future. Or, is this something that others would want to use, in which case I could submit the code (which appears to be simple).

Are there other/better options? Perhaps I'm missing something really obvious.

** Edit: Changed title to better describe question.
Sorry for bumping this old post, but I'm trying to filter collisions at the shape level instead of at object level in a compound shape body.

I'm curently using a constraint to attach two bodies with different filter masks but your customization would allow me to filter collisions by shape too.

Would you mind posting your customization code?

Or, is some kind of filtering by shapes feature implemented in the latest bullet release?
Post Reply