Jump to content
  • Advertisement
Sign in to follow this  
Ed Welch

temporarily exclude a rigidBody from ray testing

This topic is 1143 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
Advertisement

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
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!