2 #ifndef B3_SUPPORT_MAPPINGS_H
3 #define B3_SUPPORT_MAPPINGS_H
5 #include "Bullet3Common/b3Transform.h"
6 #include "Bullet3Common/b3AlignedObjectArray.h"
7 #include "b3VectorFloat4.h"
9 struct b3GjkPairDetector;
11 inline b3Vector3 localGetSupportVertexWithMargin(const float4& supportVec, const struct b3ConvexPolyhedronData* hull,
12 const b3AlignedObjectArray<b3Vector3>& verticesA, b3Scalar margin)
14 b3Vector3 supVec = b3MakeVector3(b3Scalar(0.), b3Scalar(0.), b3Scalar(0.));
15 b3Scalar maxDot = b3Scalar(-B3_LARGE_FLOAT);
17 // Here we take advantage of dot(a, b*c) = dot(a*b, c). Note: This is true mathematically, but not numerically.
18 if (0 < hull->m_numVertices)
20 const b3Vector3 scaled = supportVec;
21 int index = (int)scaled.maxDot(&verticesA[hull->m_vertexOffset], hull->m_numVertices, maxDot);
22 return verticesA[hull->m_vertexOffset + index];
28 inline b3Vector3 localGetSupportVertexWithoutMargin(const float4& supportVec, const struct b3ConvexPolyhedronData* hull,
29 const b3AlignedObjectArray<b3Vector3>& verticesA)
31 return localGetSupportVertexWithMargin(supportVec, hull, verticesA, 0.f);
34 #endif //B3_SUPPORT_MAPPINGS_H