PxFilterData setting problem

Hi to everyone,
I have a problem with the setSimulationFilterData method of a PxShape. I’m trying to modifiy the PxFilterData word0 in order to manage the Collision Group (as shown in the Migrating document from Physix 2.X to 3.X http://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/MigrationFrom28.html) but somehow it doesn’t work, when i call the getSimulationFilterData the PxFilterData that I’ve tried to modify it remains unchanged. I’m using Physx SDK 3.3.1.
Here is my code:

PxShape *shape = NULL;
... //Get the PxShape from a PxActor
PxFilterData d = PxFilterData();
d.word0 = collisionGroup; //collisionGroup is unsigned int, but I've also tried with PxU32
shape->setSimulationFilterData(data);
PxFilterData d2 = shape->getSimulationFilterData();
if (d.word0 == d2.word0){
	cout << "ok";  //It never arrives here!!!
}

I also checked on the Physx pre-built Snippets and Samples, but it doesn’t seem to me that there are some differences between mine and them.
Any suggestions?
Thanks in advance,
Fabio

Hi,

Your code doesn’t look quite right:

if (d.word0 == d2.word0){
cout << “ok”; //It never arrives here!!!
}

I can see where you define d2 but not where you define d.

Should your code be

if (data.word0 == d2.word0){
cout << “ok”; //It never arrives here!!!
}

Cheers,

Gordon

Thanks sorry, but that’s a Paste and Copy error. I’ll modify my message. The problem is not that one, I checked also with the Debug.

Hi,
I have the same problem. I followed the given pre-built snippets and I tried to modify the PxFilterData for a PxShape, but Physix seems didn’t work.
Is there some option that must be activated? Or some dependencies to specify?
Thanks.

Your code still doesn’t look quite right. In addition to having as mix of d, d2 and data, you seem to have two shape pointers: one you write to and one you read from:

s->setSimulationFilterData(data);
PxFilterData d2 = shape->getSimulationFilterData();

Even if you were addressing the same shape pointer and comparing the correct PxFilterData instances, you can only call setSimulationFilterData on an exclusive shape. Take a look at the documentation for PxPhysics::createShape to ensure that you have set the exclusive flag to true. If the exclusive flag is false and you have added that shape to multiple actors then you can’t modify the filter data. You can only set the filter data on a non-exclusive shape if it is referenced only once by an actor. As soon as multiple actors are referencing the shape (or a single actor is referencing it multiple times) it is not allowed to set some fundamental properties of the shape because it is undefined how to propagate that change.

The crucial code here is the code that creates the shape. It’s also important to know how many times that shape has been added to actors.

Hope this helps,

Gordon

Oh, I really have to check my messages before to write them. It was another Copy and Paste error, sorry.
By the way, the shape is referenced only to one actor, but I will follow your advice.
I’ve tried to set the FilterData before to attach the shape on the actor with the attachShape method of the PxActor, and that it works. If I do the same after the attachShape method, it doesn’t work.

It was that one. Thanks Gordon, now it works!

Excellent. Glad it worked out.