Hi!
I'm struggling with getting my collision detection working and need to ask a question about collision flags.
The short version:
I need a collision callback when body A collides with body B without getting a collision response while body A and body C should result in a collision response.
I have a landscape with a character running on it. I want to add water to it and want the water to ad a force to the character if the character is located in the water. So the character should not get any collision response from the water. I want to add that force myself. But I want to keep the collision response for the landscape that is solids. I've tried to set no_collision_response to the water, which is a box collisionshape connected to a ghostobject. My problem is that the character still get a collision response when it collides the water. I looked at the documentation for collision flags. I'm not sure if I have got this working properly. But I need to get a callback from when the character hits the water and then apply my force, which from what I understand will not happen if I use the collision flags. Could someone have any suggestion to give me? I'm hoping that my explanation is not too weird. I'm just really confused.
collision flags and collision callback
-
- Posts: 168
- Joined: Tue Jan 04, 2011 11:47 pm
Re: collision flags and collision callback
I suppose the collision masks will handle this task, but as to this situation, you should be careful in designing the corresponding masks.pwr wrote:Hi!
I'm struggling with getting my collision detection working and need to ask a question about collision flags.
The short version:
I need a collision callback when body A collides with body B without getting a collision response while body A and body C should result in a collision response.
-
- Posts: 12
- Joined: Sat Sep 24, 2011 4:58 pm
Re: collision flags and collision callback
Hi!
The problem is that I need a collision, but not the collision response. I think that collision masks can't solve this problem. All body types A, B and C should collide. But I want to do the collision response myself and not let Bullet do this.
I think that my explanation above wasn't good enough. This is a second attempt to explain what I try to do:
Character should collide and get collision response when walking on Land. When the character is in the water Bullet should do collision detection to notify when the character is located in the water. But I want to add a force myself so the character floats in the water. So I don't want to let Bullet do the collision response. Because then the character isn't let into the water. It is walking on the water.
I can't find anyway to ovverride the collisionresponse. Only how to override collisionfiltering which doesn't help me since I do want both of the collision combination above to collide. I only want to change the result of the actual collision.
The problem is that I need a collision, but not the collision response. I think that collision masks can't solve this problem. All body types A, B and C should collide. But I want to do the collision response myself and not let Bullet do this.
I think that my explanation above wasn't good enough. This is a second attempt to explain what I try to do:
Character should collide and get collision response when walking on Land. When the character is in the water Bullet should do collision detection to notify when the character is located in the water. But I want to add a force myself so the character floats in the water. So I don't want to let Bullet do the collision response. Because then the character isn't let into the water. It is walking on the water.
I can't find anyway to ovverride the collisionresponse. Only how to override collisionfiltering which doesn't help me since I do want both of the collision combination above to collide. I only want to change the result of the actual collision.
-
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: collision flags and collision callback
You don't seem to have found a suitable answer in your previous thread (http://www.bulletphysics.org/Bullet/php ... n+response)... and the problem is that they all seem good answers to me:?pwr wrote:I've tried to set no_collision_response to the water, which is a box collisionshape connected to a ghostobject. My problem is that the character still get a collision response when it collides the water.
If I've understood your problem correctly, I've managed to do what you're trying to achieve (but only if it isn't a btCharacterController issue, cause I'm not familiar with this class: so from now on I will consider your character being a btRigidBody).
Using a ghost object without contact response should be the most logical solution indeed and should work (no particular collision flag should be needed).
Anyway the fact that an object marked with the no collision response flag behaves like a "solid" body simply shouldn't happen (again: if it's not a btCharacterController issue). Could you check if normal rigid bodies can "enter" it or not? You may check an example I've made in this thread http://www.bulletphysics.org/Bullet/php ... bject+demo.
Another quick method to check for collisions are aabb/pair queries: you build the water collision shape on the stack and use it inside contact queries.
Aside from the problem of the "solid" ghost object with no collision response (that shouldn't happen), you may be upset because you want callbacks when the object enters or exit the water shape, and don't want to check for collisions every frame. In this case you can look here for possible solutions: http://www.bulletphysics.org/Bullet/php ... lisionStop
Hope it helps, but I'm not sure about it...

-
- Posts: 12
- Joined: Sat Sep 24, 2011 4:58 pm
Re: collision flags and collision callback
Hi! Thanks for your answer. I have finally realized why the collisionflags doesn't work with my setup. btKinematicCharacterController contains logic for handling collisions and I found a part of the code that didn't take the collisionflags in concideration. So by create a subclass, I have managed to be able have the collision callbacks while the character walks threw a body. Thanks for your help Flix!
pwr
pwr