Sign in to follow this  

temporarily exclude a rigidBody from ray testing

This topic is 834 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 am using Bullet physics for ray testing and I want to exclude a rigidBody from the ray test for one call only.
Is there anyway to do this without calling removeBody and addBody?
I looked at using btOverlapFilterCallback, but that seems to be for preventing collisions, not ray testing.

Share this post


Link to post
Share on other sites

Just use non-default ray intersection callback and filter out your body manually.

That is, make derived class from btCollisionWorld::ClosestRayResultCallback and override virtual bool needsCollision(btBroadphaseProxy* proxy0) const.

http://bulletphysics.org/Bullet/BulletFull/btCollisionWorld_8h_source.html#l00231

Yeah, that seems to work. Thanks for the answer ;)

 

This is the code I used:

struct ExcludeRayResultCallback : public btCollisionWorld::ClosestRayResultCallback 
{
	ExcludeRayResultCallback(const btVector3& rayFromWorld,const btVector3&	rayToWorld)
		: btCollisionWorld::ClosestRayResultCallback(rayFromWorld, rayToWorld)
	{
		m_pExlude = NULL;
	}
		
	virtual bool needsCollision(btBroadphaseProxy* proxy0) const
	{
		btCollisionObject* pCollisionObject = (btCollisionObject*)proxy0->m_clientObject;
		assert(pCollisionObject->getInternalType() == btCollisionObject::CO_COLLISION_OBJECT ||
			pCollisionObject->getInternalType() == btCollisionObject::CO_RIGID_BODY);
		return pCollisionObject->getUserPointer() != m_pExlude;
	}
	void* m_pExlude;
};

Edited by Ed Welch

Share this post


Link to post
Share on other sites

This topic is 834 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