Collision only (no dynamics/kinematics)?
Posted: Tue Feb 19, 2013 12:49 am
Hi all,
I'm trying to implement simple collision detection using Bullet, where the world contains static objects, and the collision query is also a static object. I'm very new to using physics engines, so I'm not well versed on the terminologies and techniques of such engines. I do have a working demo using Bullet, however I'd like to know if I'm doing it correctly, and also if there is a better way to go about it. Apologies if this has been covered before; I tried following the wiki and the demos to get to my current situation.
This is what I have so far:
1) The world is a btCollisionWorld with a btAxisSweep3 broadphase and a btDefaultCollisionConfiguration
2) New btCollisionObjects that are added to the world AS WELL AS the collision query btCollisionObject are either:
- btBoxShape
- btGImpactMeshShape (This represents a bag of triangles. I tried using btBvhTriangleMeshShape, but apparently btBvhTriangleMeshShape vs. btBvhTriangleMeshShape does not work. I followed the advice in this thread: http://code.google.com/p/bullet/issues/detail?id=682)
3) btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher); - so that GImpact shapes worked
4) All btCollisionObjects are set to btCollisionObject::CF_STATIC_OBJECT
5) Collision querying is done using a btCollisionWorld::ContactResultCallback
I don't perform any explicit ticking/processing of the world. What I listed is *it*.
Also regarding the btCollisionWorld::ContactResultCallback's addSingleResult callback, I have the following questions:
1) What exactly does the return value do?
2) Why would there be a pair if btManifoldPoint::getDistance() > 0? I am under the assumption that a value < 0 means that there is overlap, thus a collision.
3) Is colObj0Wrap always the collision query btCollisionObject? It seems that way so far..
All I really care (currently) is whether the collision query is colliding with other objects in the world, not the collision points. Is there an easier method, or am I expected to use btCollisionWorld::ContactResultCallback?
When building a contiguous path and adding each piece to the btCollisionWorld, I noticed that right after I add a btCollisionObject (GImpact shape) for a new piece and test against a new query, the previous btCollisionObject added is returned in addition to the new one - even though logically only the new piece's btCollisionObject should be returned via the btCollisionWorld::ContactResultCallback. (The collision query is a ghost object that is connected to the end of the last piece of the path). But this anomaly only shows up in the query right after the addition, but subsequent queries return the expected values - just the new btCollisionObject that was added. I don't understand what's happening here.. The only thing I can theorize is that I am not updating the collision pairs in the world right after the addition. If so, what exactly do I need to call to update the world?
Thanks in advance.
I'm trying to implement simple collision detection using Bullet, where the world contains static objects, and the collision query is also a static object. I'm very new to using physics engines, so I'm not well versed on the terminologies and techniques of such engines. I do have a working demo using Bullet, however I'd like to know if I'm doing it correctly, and also if there is a better way to go about it. Apologies if this has been covered before; I tried following the wiki and the demos to get to my current situation.
This is what I have so far:
1) The world is a btCollisionWorld with a btAxisSweep3 broadphase and a btDefaultCollisionConfiguration
2) New btCollisionObjects that are added to the world AS WELL AS the collision query btCollisionObject are either:
- btBoxShape
- btGImpactMeshShape (This represents a bag of triangles. I tried using btBvhTriangleMeshShape, but apparently btBvhTriangleMeshShape vs. btBvhTriangleMeshShape does not work. I followed the advice in this thread: http://code.google.com/p/bullet/issues/detail?id=682)
3) btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher); - so that GImpact shapes worked
4) All btCollisionObjects are set to btCollisionObject::CF_STATIC_OBJECT
5) Collision querying is done using a btCollisionWorld::ContactResultCallback
I don't perform any explicit ticking/processing of the world. What I listed is *it*.
Also regarding the btCollisionWorld::ContactResultCallback's addSingleResult callback, I have the following questions:
1) What exactly does the return value do?
2) Why would there be a pair if btManifoldPoint::getDistance() > 0? I am under the assumption that a value < 0 means that there is overlap, thus a collision.
3) Is colObj0Wrap always the collision query btCollisionObject? It seems that way so far..
All I really care (currently) is whether the collision query is colliding with other objects in the world, not the collision points. Is there an easier method, or am I expected to use btCollisionWorld::ContactResultCallback?
When building a contiguous path and adding each piece to the btCollisionWorld, I noticed that right after I add a btCollisionObject (GImpact shape) for a new piece and test against a new query, the previous btCollisionObject added is returned in addition to the new one - even though logically only the new piece's btCollisionObject should be returned via the btCollisionWorld::ContactResultCallback. (The collision query is a ghost object that is connected to the end of the last piece of the path). But this anomaly only shows up in the query right after the addition, but subsequent queries return the expected values - just the new btCollisionObject that was added. I don't understand what's happening here.. The only thing I can theorize is that I am not updating the collision pairs in the world right after the addition. If so, what exactly do I need to call to update the world?
Thanks in advance.