2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
#ifndef B3_SUPPORT_MAPPINGS_H
|
|
|
|
#define B3_SUPPORT_MAPPINGS_H
|
|
|
|
|
|
|
|
#include "Bullet3Common/b3Transform.h"
|
|
|
|
#include "Bullet3Common/b3AlignedObjectArray.h"
|
|
|
|
#include "b3VectorFloat4.h"
|
|
|
|
|
|
|
|
struct b3GjkPairDetector;
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
inline b3Vector3 localGetSupportVertexWithMargin(const float4& supportVec, const struct b3ConvexPolyhedronData* hull,
|
|
|
|
const b3AlignedObjectArray<b3Vector3>& verticesA, b3Scalar margin)
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
b3Vector3 supVec = b3MakeVector3(b3Scalar(0.), b3Scalar(0.), b3Scalar(0.));
|
2017-08-01 12:30:58 +00:00
|
|
|
b3Scalar maxDot = b3Scalar(-B3_LARGE_FLOAT);
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
// Here we take advantage of dot(a, b*c) = dot(a*b, c). Note: This is true mathematically, but not numerically.
|
|
|
|
if (0 < hull->m_numVertices)
|
|
|
|
{
|
|
|
|
const b3Vector3 scaled = supportVec;
|
|
|
|
int index = (int)scaled.maxDot(&verticesA[hull->m_vertexOffset], hull->m_numVertices, maxDot);
|
|
|
|
return verticesA[hull->m_vertexOffset + index];
|
|
|
|
}
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
return supVec;
|
2017-08-01 12:30:58 +00:00
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
inline b3Vector3 localGetSupportVertexWithoutMargin(const float4& supportVec, const struct b3ConvexPolyhedronData* hull,
|
|
|
|
const b3AlignedObjectArray<b3Vector3>& verticesA)
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
return localGetSupportVertexWithMargin(supportVec, hull, verticesA, 0.f);
|
2017-08-01 12:30:58 +00:00
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
#endif //B3_SUPPORT_MAPPINGS_H
|