Exclude some btCollisionObjects from raytest

Charlie
Posts: 3
Joined: Tue Feb 02, 2010 2:15 pm

Exclude some btCollisionObjects from raytest

Post by Charlie »

Hi,

everything is in the title.
I suppose the solution is very simple but I just can't find it (I'm going crazy right now :evil: ).
I tried activate(false), setCollisionFlag, setActivationState, the object is still detected (I'm in a btCollisionWorld).
So what is the good procedure ??

Thanks

Charlie
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Exclude some btCollisionObjects from raytest

Post by Erwin Coumans »

There are 2 ways to filter collision objects for the rayTest:
  • You can derive your own version of RayResultCallback, and override the virtual 'needsCollision'
  • using filter flags in RayResultCallback, m_collisionFilterGroup and m_collisionFilterMask
Can you try one of those?
Thanks,
Erwin
Charlie
Posts: 3
Joined: Tue Feb 02, 2010 2:15 pm

Re: Exclude some btCollisionObjects from raytest

Post by Charlie »

Thank for your answer, it works great :D
I've used the needsCollision method.
Correct me if I'm wrong but you can't do a detailed per object filter with m_CollisionFilterGroup and m_CollisionFilterMask ?! It just filter the basic type (static,...).

I have another question about rays. Is there a possibility to do a ray on a volume ??
Like in a rts, selecting every units in a selection rectangle.

++
chbfiv
Posts: 10
Joined: Thu Jan 20, 2011 9:36 pm

Re: Exclude some btCollisionObjects from raytest

Post by chbfiv »

•using filter flags in RayResultCallback, m_collisionFilterGroup and m_collisionFilterMask
I'm having an issue,

I have a RigidBody that is part of the CF_UI group with a collision mask of CF_STATIC

Now I setup a RayTest (using closest callback) and set both
m_collisionFilterGroup and m_collisionFilterMask to CF_UI

Then I run the RayTest and Hit fails.

I can run the same Test and just place the Rigidbody in CF_DEFAULT with a mask of CF_ALL
and set m_collisionFilterGroup and m_collisionFilterMask to CF_DEFAULT and CF_ALL respectivally and a Hit is successful.

My goal is that my RayTest is optimized to only look through the CF_UI only.

I suspect I'm misusing the RayTest w/ ClosestRayCallback or that I'm overlooking something. Thanks!