From 22b7c9dfa80d0f7abca40f061865c2ab3c136a74 Mon Sep 17 00:00:00 2001 From: Oussama Date: Thu, 3 Jan 2019 14:26:51 +0100 Subject: Update Bullet to the latest commit 126b676 --- .../shared/b3FindSeparatingAxis.h | 149 ++++++++++----------- 1 file changed, 70 insertions(+), 79 deletions(-) (limited to 'thirdparty/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3FindSeparatingAxis.h') diff --git a/thirdparty/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3FindSeparatingAxis.h b/thirdparty/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3FindSeparatingAxis.h index 332dbc278c..b4981ae654 100644 --- a/thirdparty/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3FindSeparatingAxis.h +++ b/thirdparty/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3FindSeparatingAxis.h @@ -1,28 +1,27 @@ #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) +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); + const b3Float4 localDir = b3QuatRotate(orn.inverse(), dir); - b3Scalar offset = b3Dot3F4(pos,dir); + b3Scalar offset = b3Dot3F4(pos, dir); - for(int i=0;i max) max = dp; + if (dp < min) min = dp; + if (dp > max) max = dp; } - if(min>max) + if (min > max) { b3Scalar tmp = min; min = max; @@ -32,44 +31,42 @@ inline void b3ProjectAxis(const b3ConvexPolyhedronData& hull, const b3Float4& p 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) +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); + 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); + b3Assert(d0 >= 0.0f); b3Scalar d1 = Max1 - Min0; - b3Assert(d1>=0.0f); - depth = d0= 0.0f); + depth = d0 < d1 ? d0 : d1; return true; } - -inline bool b3FindSeparatingAxis( const b3ConvexPolyhedronData& hullA, const b3ConvexPolyhedronData& hullB, - const b3Float4& posA1, - const b3Quaternion& ornA, - const b3Float4& posB1, - const b3Quaternion& ornB, - const b3AlignedObjectArray& verticesA, - const b3AlignedObjectArray& uniqueEdgesA, - const b3AlignedObjectArray& facesA, - const b3AlignedObjectArray& indicesA, - const b3AlignedObjectArray& verticesB, - const b3AlignedObjectArray& uniqueEdgesB, - const b3AlignedObjectArray& facesB, - const b3AlignedObjectArray& indicesB, - - b3Vector3& sep) +inline bool b3FindSeparatingAxis(const b3ConvexPolyhedronData& hullA, const b3ConvexPolyhedronData& hullB, + const b3Float4& posA1, + const b3Quaternion& ornA, + const b3Float4& posB1, + const b3Quaternion& ornB, + const b3AlignedObjectArray& 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"); @@ -77,42 +74,41 @@ inline bool b3FindSeparatingAxis( const b3ConvexPolyhedronData& hullA, const b3C posA.w = 0.f; b3Float4 posB = posB1; posB.w = 0.f; -//#ifdef TEST_INTERNAL_OBJECTS + //#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); + b3Float4 c1 = b3TransformPoint(c1local, posB, ornB); const b3Float4 deltaC2 = c0 - c1; -//#endif + //#endif b3Scalar dmin = FLT_MAX; - int curPlaneTests=0; + int curPlaneTests = 0; int numFacesA = hullA.m_numFaces; // Test normals from hullA - for(int i=0;i0.0f) + if ((b3Dot3F4(-deltaC2, (b3Float4&)sep)) > 0.0f) sep = -sep; return true; } -#endif //B3_FIND_SEPARATING_AXIS_H - +#endif //B3_FIND_SEPARATING_AXIS_H -- cgit v1.2.3