[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / Bullet3OpenCL / NarrowphaseCollision / b3SupportMappings.h
1
2 #ifndef B3_SUPPORT_MAPPINGS_H
3 #define B3_SUPPORT_MAPPINGS_H
4
5 #include "Bullet3Common/b3Transform.h"
6 #include "Bullet3Common/b3AlignedObjectArray.h"
7 #include "b3VectorFloat4.h"
8
9 struct b3GjkPairDetector;
10
11 inline b3Vector3 localGetSupportVertexWithMargin(const float4& supportVec, const struct b3ConvexPolyhedronData* hull,
12                                                                                                  const b3AlignedObjectArray<b3Vector3>& verticesA, b3Scalar margin)
13 {
14         b3Vector3 supVec = b3MakeVector3(b3Scalar(0.), b3Scalar(0.), b3Scalar(0.));
15         b3Scalar maxDot = b3Scalar(-B3_LARGE_FLOAT);
16
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)
19         {
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];
23         }
24
25         return supVec;
26 }
27
28 inline b3Vector3 localGetSupportVertexWithoutMargin(const float4& supportVec, const struct b3ConvexPolyhedronData* hull,
29                                                                                                         const b3AlignedObjectArray<b3Vector3>& verticesA)
30 {
31         return localGetSupportVertexWithMargin(supportVec, hull, verticesA, 0.f);
32 }
33
34 #endif  //B3_SUPPORT_MAPPINGS_H