Sign in to follow this  

PhysX - StartTouch/EndTouch/Trigger Events?

This topic is 1282 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
{
public:
	WVPxEventCallback();
	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?

 

Thanks.

Share this post


Link to post
Share on other sites

This topic is 1282 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this