FCL supports broadphase collision/distance between two groups of objects and can avoid the n square complexity. For collision, broadphase algorithm can return all the collision pairs. For distance, it can return the pair with the minimum distance. FCL uses a CollisionManager structure to manage all the objects involving the collision or distance operations.
```cpp
// Initialize the collision manager for the first group of objects.
// FCL provides various different implementations of CollisionManager.
// Generally, the DynamicAABBTreeCollisionManager would provide the best performance.
// To add objects into the collision manager, using BroadPhaseCollisionManager::registerObject() function to add one object
std::vector<CollisionObject*>objects1=...
for(std::size_ti=0;i<objects1.size();++i)
manager1->registerObject(objects1[i]);
// Another choose is to use BroadPhaseCollisionManager::registerObjects() function to add a set of objects
std::vector<CollisionObject*>objects2=...
manager2->registerObjects(objects2);
// In order to collect the information during broadphase, CollisionManager requires two settings:
// a) a callback to collision or distance;
// b) an intermediate data to store the information generated during the broadphase computation
// For a), FCL provides the default callbacks for both collision and distance.
// For b), FCL uses the CollisionData structure for collision and DistanceData structure for distance. CollisionData/DistanceData is just a container including both the CollisionRequest/DistanceRequest and CollisionResult/DistanceResult structures mentioned above.
CollisionDatacollision_data;
DistanceDatadistance_data;
// Setup the managers, which is related with initializing the broadphase acceleration structure according to objects input
manager1->setup();
manager2->setup();
// Examples for various queries
// 1. Collision query between two object groups and get collision numbers