void CCollisionManager::ClipLinePlane( const vec3* verts0, // 2 verts const int* vertIndexs0, CCube* cube1, const vec3* verts1, // 4 verts int* vertIndexs1, CCube* cube2, vec3* vertsX, int &numVertX) { ClosestPtPointOBB(verts0[0], cube2, &vertsX[0]); ClosestPtPointOBB(verts0[1], cube2, &vertsX[1]); numVertX = 2; }
// Returns true if sphere s intersects OBB b, false otherwise. // The point p on the OBB closest to the sphere center is also returned bool TestSphereOBB(Sphere& s, OBB& box, Vec* out_p) { // Find point p on OBB closest to sphere center ClosestPtPointOBB(s.c, box, out_p); // Sphere and OBB intersect if the (squared) distance from sphere // center to point p is less than the (squared) sphere radius //Vec v = p - s.c; Vec v ; guVecSub(out_p, &s.c, &v); return dot(&v, &v) <= s.r * s.r; }