////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * Checks the sphere completely contains the box. In which case we can end the query sooner. * \param bc [in] box center * \param be [in] box extents * \return true if the sphere contains the whole bo
| 308 | */ |
| 309 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 310 | inline_ BOOL SphereCollider::SphereContainsBox(const Point& bc, const Point& be) |
| 311 | { |
| 312 | // I assume if all 8 box vertices are inside the sphere, so does the whole box. |
| 313 | // Sounds ok but maybe there's a better way? |
| 314 | Point p; |
| 315 | p.x=bc.x+be.x; p.y=bc.y+be.y; p.z=bc.z+be.z; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE; |
| 316 | p.x=bc.x-be.x; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE; |
| 317 | p.x=bc.x+be.x; p.y=bc.y-be.y; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE; |
| 318 | p.x=bc.x-be.x; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE; |
| 319 | p.x=bc.x+be.x; p.y=bc.y+be.y; p.z=bc.z-be.z; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE; |
| 320 | p.x=bc.x-be.x; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE; |
| 321 | p.x=bc.x+be.x; p.y=bc.y-be.y; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE; |
| 322 | p.x=bc.x-be.x; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE; |
| 323 | |
| 324 | return TRUE; |
| 325 | } |
| 326 | |
| 327 | #define TEST_BOX_IN_SPHERE(center, extents) \ |
| 328 | if(SphereContainsBox(center, extents)) \ |
nothing calls this directly
no test coverage detected