I added some boxes in a collision world, then use btCollisionWorld::contactTest to test if any box contact with a given sphere. Below is the code:
int SpacePhysics::SphereContactTest(const btVector3 ¢er, btScalar radius) {
btSphereShape *sphere_shape = new btSphereShape(radius);
btCollisionObject *sphere = new btCollisionObject();
sphere->setCollisionShape(sphere_shape);
sphere->setWorldTransform(btTransform(btQuaternion(), center));
collision_world_->contactTest(sphere, result_callback);
delete sphere;
delete sphere_shape;
return result_callback.hit_count;
}
However no contact can be detected(when it should), if I use btCollisionWorld::contactPairTest to test the sphere with all the collision objects in the world, the contacts can be detected. But using btCollisionWorld::contactTest
nothing can be detected. What's the proper way to use btCollisionWorld::contactTest
?