Can collision CallBacks called only once?

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
ptLeng
Posts: 4
Joined: Sat May 17, 2014 4:12 am

Can collision CallBacks called only once?

Post by ptLeng »

Hi
I'm using the bullet for the collision detection. So I set up a collision world and built two objects with btGImpactMeshShape. I've registered the btGImpactCollisionAlgorithm already. I used the contactPairTest to test the two objects. But I found that the bullet callback function is called too frequently. I only want to know if the two object is collision or not, Is there some way to call the callback function only once in my project?
I've read a document of the bullet collision from wiki. The site is:"http://www.bulletphysics.org/mediawiki- ... d_Triggers". In this paper, some words called my attention:
Be careful when using contact callbacks: They may be called too frequently for your purposes. Bullet supports custom callbacks at various points in the collision system. The callbacks themselves are very simply implemented as global variables that you set to point at appropriate functions. Before you can expect them to be called you must set an appropriate flag in your rigid body
I test all the method the enum CollisionFlags, but it didn't work.
My code is:

Code: Select all

      btGImpactMeshShape * trimesh1 = new btGImpactMeshShape(triangleIndex);
      trimesh1->updateBound();
      btCollisionShape* collisionshape1 = trimesh1;

      btGImpactMeshShape * trimesh2 = new btGImpactMeshShape(triangleIndex);
      trimesh2->updateBound();
      btCollisionShape* collisionshape2 = trimesh2;

      objects[0].setCollisionShape(collisionshape1);
      objects[1].setCollisionShape(collisionshape2);

      objects[0].setCollisionFlags(objects[0].getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
      objects[1].setCollisionFlags(objects[1].getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);

      btDrawingResult renderCallback;
      collisionWorld->contactPairTest(&objects[0], &objects[1], renderCallback);
The renderCallback can be found in Demo/CollisionInterfaceDemo.

Any comment on this would be much appreciated :D
Post Reply