Jump to content
  • Advertisement
Sign in to follow this  

PhysX - StartTouch/EndTouch/Trigger Events?

This topic is 1499 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using PhysX 3.3.0.

I need to know when two actors have started touching and ended touching, but can't figure out how to properly implement that.


This is my filter shader for testing purposes:

static physx::PxFilterFlags testFilterShader(
		physx::PxFilterObjectAttributes attributes0,physx::PxFilterData filterData0,
		physx::PxFilterObjectAttributes attributes1,physx::PxFilterData filterData1,
		physx::PxPairFlags &pairFlags,const void *constantBlock,physx::PxU32 constantBlockSize
	if(physx::PxFilterObjectIsTrigger(attributes0) || physx::PxFilterObjectIsTrigger(attributes1))
		pairFlags = physx::PxPairFlag::eTRIGGER_DEFAULT;
		return physx::PxFilterFlag::eDEFAULT;
	pairFlags = physx::PxPairFlag::eCONTACT_DEFAULT;
	if(((filterData0.word0 &filterData1.word1) == 0) || ((filterData1.word0 &filterData0.word1) == 0))
		return physx::PxFilterFlag::eKILL;
	if(filterData0.word2 || filterData1.word2)
		pairFlags |= physx::PxPairFlag::eNOTIFY_TOUCH_FOUND;
	return physx::PxFilterFlag::eDEFAULT;

If word2 is set to anything but 0 (Which is the case for my test-actors), the PxPairFlag::eNOTIFY_TOUCH_FOUND flag is set. According to the physx documentation, this should invoke the 'onContact' method of my event callback:

class WVPxEventCallback : public physx::PxSimulationEventCallback
	virtual void onContact(const physx::PxContactPairHeader &pairHeader,const physx::PxContactPair *pairs,physx::PxU32 nbPairs);
	virtual void onTrigger(physx::PxTriggerPair *pairs,physx::PxU32 count);
	virtual void onConstraintBreak(physx::PxConstraintInfo *constraints,physx::PxU32 count);
	virtual void onWake(physx::PxActor **actors,physx::PxU32 count);
	virtual void onSleep(physx::PxActor **actors,physx::PxU32 count);

However 'onContact' is never called, no matter what.

In case of a trigger, it's calling the 'onTrigger' event if an object is touching it, as it should, but it's also called at seemingly random times while the object (capsule controller) is moving around within the trigger.


I've set both the PxSceneFlag::eENABLE_KINEMATIC_PAIRS and PxSceneFlag::eENABLE_KINEMATIC_STATIC_PAIRS flags for the scene.

Is there anything else I forgot/need?


I'd also like to know if there's a way to check if two actors are touching at any time, or if I have to keep track of that myself?



Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!