void addOneObstacle (void)
 {
     
     // pick a random center and radius,
     // loop until no overlap with other obstacles and the home base
     float r;
     Vec3 c;
     float minClearance;
     const float requiredClearance = gWanderAround->radius() * 4; // 2 x diameter
     do
     {
         r = frandom2 (1.5, 4);
         c = randomVectorOnUnitRadiusXZDisk () * gMaxStartRadius * 1.1f;
         minClearance = FLT_MAX;
         
         for (SOI so = allObstacles.begin(); so != allObstacles.end(); so++)
         {
             testOneObstacleOverlap ((**so).radius, (**so).center);
         }
     }
     while (minClearance < requiredClearance);
     
     // add new non-overlapping obstacle to registry
     allObstacles.push_back (new SphericalObstacle (r, c));
     obstacleCount++;
 }
void GroupBase::addOneObstacle (void)
{
    if (obstacleCount < maxObstacleCount)
    {
        // pick a random center and radius,
        // loop until no overlap with other obstacles and the home base
        float r;
        float3 c;
        float minClearance;
        const float requiredClearance = gSeeker->radius() * 4; // 2 x diameter
        do
        {
            r = frandom2 (1.5, 4);
            c = float3_scalar_multiply(float3_randomVectorOnUnitRadiusXZDisk(), gMaxStartRadius * 1.1f);
            minClearance = FLT_MAX;

            for (SOI so = allObstacles.begin(); so != allObstacles.end(); so++)
            {
                testOneObstacleOverlap ((**so).radius, (**so).center);
            }

            testOneObstacleOverlap (gHomeBaseRadius - requiredClearance,
                                    gHomeBaseCenter);
        }
        while (minClearance < requiredClearance);

        // add new non-overlapping obstacle to registry
        allObstacles.push_back (new SphericalObstacle (r, c));
        obstacleCount++;
    }
}
float GroupBase::minDistanceToObstacle (const float3 point)
{
    float r = 0;
    float3 c = point;
    float minClearance = FLT_MAX;
    for (SOI so = allObstacles.begin(); so != allObstacles.end(); so++)
    {
        testOneObstacleOverlap ((**so).radius, (**so).center);
    }
    return minClearance;
}
void GroupBase::removeOneObstacle (void)
{
    if (obstacleCount > 0)
    {
        obstacleCount--;
        allObstacles.pop_back();
    }
}
 void close (void)
 {
     theVehicles.clear ();
     delete (gWanderAround);
     gWanderAround = NULL;
     allObstacles.clear();
     
     // reset MemoryBackend of SimpleVehicleMB
     SimpleVehicleMB::resetBackend();
 }