* Performant method to intersect box with a sphere. The box is defined * by (min,max) corners; the sphere by (center,radius**2). Inspired by * Graphics Gems 1. */
| 203 | * Graphics Gems 1. |
| 204 | */ |
| 205 | static bool IntersectsSphere( |
| 206 | const double min[3], const double max[3], const double center[3], double r2) |
| 207 | { |
| 208 | double d2 = 0.0; |
| 209 | for (int i = 0; i < 3; ++i) |
| 210 | { |
| 211 | if (center[i] < min[i]) |
| 212 | { |
| 213 | d2 += (center[i] - min[i]) * (center[i] - min[i]); |
| 214 | } |
| 215 | else if (center[i] > max[i]) |
| 216 | { |
| 217 | d2 += (center[i] - max[i]) * (center[i] - max[i]); |
| 218 | } |
| 219 | } |
| 220 | return (d2 <= r2); |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * Intersect this box with a sphere. Parameters involve the |
no outgoing calls
no test coverage detected