Dynamically adding Collision filtering on rigid bodies

jchen114
Posts: 12
Joined: Wed Jun 08, 2016 1:39 am

Dynamically adding Collision filtering on rigid bodies

Post by jchen114 »

Hello,

For my purposes, I would like to be able to dynamically set when a rigid body should collide with another body. From what I've seen, the body has to be created with the desired collision filtering(?)

I'd like to change the body's collision flags depending on the scenario.

I've tried setting the collisionflags of the body to other values but it doesn't seem to work. The body is suspended and does not react to anything.

Thanks for the help.
kermado
Posts: 20
Joined: Tue Jan 12, 2016 11:20 am

Re: Dynamically adding Collision filtering on rigid bodies

Post by kermado »

You need to remove and re-add the rigid body to the world.
veio
Posts: 9
Joined: Sun Aug 21, 2016 6:04 pm

Re: Dynamically adding Collision filtering on rigid bodies

Post by veio »

We did this by inheriting from btCollisionDispatcher and overwriting needsCollision and needsResponse. And returning false or calling the base implementation whether a check is needed between two bodies or not.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland

Re: Dynamically adding Collision filtering on rigid bodies

Post by benelot »

veio wrote:We did this by inheriting from btCollisionDispatcher and overwriting needsCollision and needsResponse. And returning false or calling the base implementation whether a check is needed between two bodies or not.
Cool idea, I was also about to propose the readding option, but this one is way better to make it work properly. Especially because some people have high lags when they remove and readd larger/more complex objects just for this.