Hey all, first time poster.
Right now I've got some critters wandering around made up of convex shapes via a btCompoundShape. What I want to simulate is 'antennae' on their heads, so they can detect each other by touch before they collide.
The best method I can think of is to have a sphere added at the 'head' of the compound shape, which detects collisions and thus triggers a callback (e.g. gContactProcessedCallback), but then disable that child object's interaction with the dynamics engine. However, I can't find any way to do this.
It would be very beneficial if I could make use of Bullet's callbacks etc, rather than having to write my own routine, which would probably be far less efficient.
Any ideas how best to handle this problem would be much appreciated...?
btCompoundShape with a non-dynamic child as a sensor
-
- Posts: 14
- Joined: Mon Jun 07, 2010 5:37 am
-
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: btCompoundShape with a non-dynamic child as a sensor
Well, just some ideas here...The best method I can think of is to have a sphere added at the 'head' of the compound shape, which detects collisions and thus triggers a callback (e.g. gContactProcessedCallback), but then disable that child object's interaction with the dynamics engine. However, I can't find any way to do this.
1) You could use a ghost object to detect collisions (you can place it manually at each timestep in front of your body).
2) You can use a "normal" rigidBody without collision response (there must be a flag somewhere called NO_COLLISION_RESPONSE or something similiar): that way the body won't interect with any other objects, but its contact manifolds will be still present. The main problem is that you need a whole rigid body and not a simple sub shape of a compound shape, so you probably need to derive a "btFixedDof6Constraint" to connect the two bodies.
3) You can use the recently added contact query system (basically you create your sphere shaped body and without even adding it to the world, you just place it somewhere and make queries to the engine for colliding bodies). I've never used this before, but see this post: http://bulletphysics.org/Bullet/phpBB3/ ... est#p18791.
4) You can just use ray tests to detect other "creatures" in front of each body (once at each timestep or so).
Hope this helps.
-
- Posts: 14
- Joined: Mon Jun 07, 2010 5:37 am
Re: btCompoundShape with a non-dynamic child as a sensor
Thanks a lot for the response.
I ended up using approach (3), the new contactTest() functionality, in pretty much exactly the way you mentioned.
I'm wary about the scalability of the approach in terms of culling objects via the broadphase for such arbitrarily placed objects. I don't fully understand how the various broadphase methods work, or their benefits w.r.t each other (any pointers to info much appreciated..?). I'm currently using btDbvtBroadphase. I would think any tree-based algorithm may have to do a lot of work to keep repositioning an object arbitrarily within the broadphase data structure...?
However, for the time being in my small demo app this solution is working out fine. I'll deal with the repercussions later
.
I ended up using approach (3), the new contactTest() functionality, in pretty much exactly the way you mentioned.
I'm wary about the scalability of the approach in terms of culling objects via the broadphase for such arbitrarily placed objects. I don't fully understand how the various broadphase methods work, or their benefits w.r.t each other (any pointers to info much appreciated..?). I'm currently using btDbvtBroadphase. I would think any tree-based algorithm may have to do a lot of work to keep repositioning an object arbitrarily within the broadphase data structure...?
However, for the time being in my small demo app this solution is working out fine. I'll deal with the repercussions later
