b3SupportMappings.h 1.2 KB

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