Change collision filtering behavior without recreating scene

I have a scene with a reasonably complex collision filtering system. At the time the scene is created the exact required behavior of the filtering system is not known (It is known before the first tick). As such I need a way to alter the behavior of the collision filter after scene creation. I had two ideas as to how to do this:

  1. Pass in a new collision filter replacing the old one.
  2. Update the constant filter data block for the scene to tell the filter how to act.

However as far as I can tell once the scene is created it’s not possible to set the filter shader and it’s not possible to change the filter data block (You can only access a const pointer to it).

Am I overlooking a method which allows me to do one of these two things? Is there some alternative way I can dynamically alter the filter behavior?

I’m currently using 3.2.0 but I’d be interested in solutions for later versions (that don’t involve modifying physx source) as well.

I’m wondering if you need a scene at all before the first tick. A simple way around this would be to make all the physx actors as usual and store them in an array until you know how to construct the filter shader. After you have made the scene you could then add all the actors from your array. An alternative would be to create a scene as you do now, get all the actors using scene->getActors(), delete the original scene and and add all the actors to a second scene that you used to tick the game world. Do either of these work for you?

Cheers,

Gordon

Either solution will, in principle, work I believe. It will require a significant refactoring to the way I handle the world creation. If this is the best way then I’ll do it that way. Thanks.