Setting the flag to get getActiveTransforms to work

So, it took me some time to figure out how to get getActiveTransforms() NOT to return NULL because of how I was setting the flag eENABLE_ACTIVETRANSFORMS.

Here’s what I did in the setup phase of the scene:

//scene initialization stuff
scene = gPhysics->createScene(sceneDesc);
scene->setFlag(PxSceneFlag::eENABLE_ACTIVETRANSFORMS, true);

And in the loop:

scene->simulate(1 / 60.0f);

PxU32 nbActiveTransforms;
const PxActiveTransform* activeTransforms = scene->getActiveTransforms(nbActiveTransforms);

But activeTransforms was always NULL. To get it to work I had to change the setup phase like this:

//scene initialization stuff
sceneDesc.flags |= PxSceneFlag::eENABLE_ACTIVETRANSFORMS;
scene = gPhysics->createScene(sceneDesc);
//scene->setFlag(PxSceneFlag::eENABLE_ACTIVETRANSFORMS, true);

So here are my questions. Was I doing something wrong? And if not, what is the difference between setting the flag in sceneDesc (PxSceneDesc) and setting it in scene (PxScene)?

P.S. I’m using PhysX-3.3.4.

Thanks in advance.

This is a bug in PhysX. We shall do our best to fix this in the next release.

In debug and checked configs we test input values to PxScene::setFlag and immediately return with a warning message if any function arguments are illegal. The test for legality in PxScene::setFlag is incorrect, I’m afraid, and this means that the function does nothing at all in checked and debug when you pass in a legal value. If you look at the error stream you should find an error there - “NpScene::setFlag: This flag is not mutable - you can only set it once in PxSceneDesc at startup!”.

It is a simple change to fix this locally. Take a look at the function PxScene::setFlag in NpScene.cpp. You just need to change the legality check to the following code:

										PxSceneFlag::eENABLE_PCM)),"NpScene::setFlag: This flag is not mutable - you can only set it once in PxSceneDesc at startup!");