My app crashes, telling me this error
File: ScRigidSim.cpp Line: 92
Expression: ScRigidSim.cpp(92) Assertion failed: 0
I think it worked well in previous release (3.3.0) but I may be wrong…
It happens at “setGeometry” call.
I’ve checked and the type of the geometry is correct (I’m setting new dimensions for an already created shape, i.e. new dimensions for a box or a sphere already created with createShape)
What I’m trying to do is replacing a box shape with a sphere shape by :
1- creating a new sphere shape for an actor
2- detaching the box shape from the actor
3- setting new geometry for the sphere shape when user changes the radius
So it crashes in step 3
Any idea why I can’t do that ?
If I dont detach and create shapes, the setGeometry works well.
I may have found why but I don’t really understand why I can’t do that.
Actually my app is in pause mode, so no simulate is executed.
It looks like when I’m switching to play mode, I can do anything without crash.
Is this normal behavior that I can’t detach/create actors and then change geometry without simulate ?
If so, how can I ask PhysX to take into account my changes but without simulating (because I dont want my objects to start moving) ?
EDIT : So to quickly fix this I execute a simulate with dt = 0, but the documentation says it could lead to undefined behaviour, so this is probably risky …
It does sound like it could be a PhysX bug, you should be able to add/remove/change without calling the simulation step, but I can see how this might lead to trouble because it is not a typical use case. A repro snippet would help us.
Thanks for your answer Mike.
I’ve tried to extract the code from my app, which was not very easy, but here it is.
So as you will see in the code below I add a new sphere shape to my actor which already has a box shape, then I detach the old box shape from the same actor and then I try to modify the sphere geometry for the remaining sphere shape and the app crashes :
// I have a box shape that I want to turn to a sphere shape
float rad = max(max(boxGeom.halfExtents.x, boxGeom.halfExtents.y), boxGeom.halfExtents.z) * 2.0f;
// Then I create a new shape, which is added to the list of shapes for my actor
PxShape *sphereShape = actor->is<PxRigidActor>()->createShape(PxSphereGeometry(rad), *defaultMaterial);
//Then after in my code I search for my old box shape to detach it (it is shapes[i]) :
//I’ve looked closer and it is the correct shape that is deleted, not the new sphereShape
// This is where I need to execute a blank simulate (simulate(0)) if I want my app to not crash
//Then later I want to change the sphere geometry, which is the only shape left for this actor
PxU32 nbShapes = actor->is<PxRigidActor>()->getNbShapes();
PxShape** shapes = (PxShape**)defaultAllocator.allocate(sizeof (PxShape*)* nbShapes, 0, __FILE__, __LINE__);
PxU32 nb = actor->is<PxRigidActor>()->getShapes(shapes, nbShapes);
// This is where the app crashes :
// I've checked and shape is my sphere shape so I don't understand what's going on