#ifndef B3_FIND_SEPARATING_AXIS_H #define B3_FIND_SEPARATING_AXIS_H inline void b3ProjectAxis(const b3ConvexPolyhedronData& hull, const b3Float4& pos, const b3Quaternion& orn, const b3Float4& dir, const b3AlignedObjectArray& vertices, b3Scalar& min, b3Scalar& max) { min = FLT_MAX; max = -FLT_MAX; int numVerts = hull.m_numVertices; const b3Float4 localDir = b3QuatRotate(orn.inverse(),dir); b3Scalar offset = b3Dot3F4(pos,dir); for(int i=0;i max) max = dp; } if(min>max) { b3Scalar tmp = min; min = max; max = tmp; } min += offset; max += offset; } inline bool b3TestSepAxis(const b3ConvexPolyhedronData& hullA, const b3ConvexPolyhedronData& hullB, const b3Float4& posA,const b3Quaternion& ornA, const b3Float4& posB,const b3Quaternion& ornB, const b3Float4& sep_axis, const b3AlignedObjectArray& verticesA,const b3AlignedObjectArray& verticesB,b3Scalar& depth) { b3Scalar Min0,Max0; b3Scalar Min1,Max1; b3ProjectAxis(hullA,posA,ornA,sep_axis,verticesA, Min0, Max0); b3ProjectAxis(hullB,posB,ornB, sep_axis,verticesB, Min1, Max1); if(Max0=0.0f); b3Scalar d1 = Max1 - Min0; b3Assert(d1>=0.0f); depth = d0& verticesA, const b3AlignedObjectArray& uniqueEdgesA, const b3AlignedObjectArray& facesA, const b3AlignedObjectArray& indicesA, const b3AlignedObjectArray& verticesB, const b3AlignedObjectArray& uniqueEdgesB, const b3AlignedObjectArray& facesB, const b3AlignedObjectArray& indicesB, b3Vector3& sep) { B3_PROFILE("findSeparatingAxis"); b3Float4 posA = posA1; posA.w = 0.f; b3Float4 posB = posB1; posB.w = 0.f; //#ifdef TEST_INTERNAL_OBJECTS b3Float4 c0local = (b3Float4&)hullA.m_localCenter; b3Float4 c0 = b3TransformPoint(c0local, posA, ornA); b3Float4 c1local = (b3Float4&)hullB.m_localCenter; b3Float4 c1 = b3TransformPoint(c1local,posB,ornB); const b3Float4 deltaC2 = c0 - c1; //#endif b3Scalar dmin = FLT_MAX; int curPlaneTests=0; int numFacesA = hullA.m_numFaces; // Test normals from hullA for(int i=0;i0.0f) sep = -sep; return true; } #endif //B3_FIND_SEPARATING_AXIS_H