I’m using Physx 3.2.3, trying to add a trigger to the scene, and catch trigger events with onTrigger()
The program crashes at scene->fetchResults(true);
here’s a brief code :
creating the scene :
class phx_events : public PxSimulationEventCallback
{
public:
void onConstraintBreak(PxConstraintInfo* constraints, PxU32 count) {}
void onWake(PxActor** actors, PxU32 count) {}
void onSleep(PxActor** actors, PxU32 count) {}
void onContact(const PxContactPairHeader& pair_header, const PxContactPair* pairs,
PxU32 pair_cnt) {}
void onTrigger(PxTriggerPair* pairs, PxU32 count)
{
printf("trigger\n");
}
};
PxSceneDesc sdesc(g_phxdev.sdk->getTolerancesScale());
sdesc.gravity = PxVec3(0, -9.81f, 0);
sdesc.limits.setToDefault();
sdesc.flags = PxSceneFlag::eENABLE_ACTIVETRANSFORMS;
sdesc.cpuDispatcher = PxDefaultCpuDispatcherCreate(1);
sdesc.filterShader = PxDefaultSimulationFilterShader;
sdesc.simulationEventCallback = new phx_events();
PxScene* scene = g_phxdev.sdk->createScene(sdesc);
and creating trigger …
PxRigidDynamic* rbody = sdk->createRigidDynamic(PxTransform::createIdentity());
rbody->setActorFlag(PxActorFlag::eDISABLE_GRAVITY, true);
PxMaterial* mtl = sdk->createMaterial(0.5f, 0.5f, 0.1f);
PxShape* shape = rbody->createShape(PxBoxGeometry(1.0f, 1.0f, 1.0f), *mtl);
shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
shape->setFlag(PxShapeFlag::eTRIGGER_SHAPE, true);
scene->addActor(rbody);
when there is no trigger object (only normal rigid bodies), simulation runs without problems, but when I add the trigger (not in the middle of sim of course), it crashes on fetchResults() function from PhysX3_x86.dll. There is no entry to onTrigger function. Also when I set the simulationEventCallback to NULL, the crash doesn’t happen. So I guess it happens when fetchResults is trying to invoke callback functions or something.
Could any one give me a hint, or figure out where is the problem ?
thanks