23 #include <Box2D/Common/b2Math.h>
29 struct b2DistanceProxy
31 b2DistanceProxy() : m_vertices(NULL), m_count(0), m_radius(0.0f) {}
35 void Set(
const b2Shape* shape, int32 index);
38 int32 GetSupport(
const b2Vec2& d)
const;
44 int32 GetVertexCount()
const;
47 const b2Vec2& GetVertex(int32 index)
const;
68 struct b2DistanceInput
70 b2DistanceProxy proxyA;
71 b2DistanceProxy proxyB;
78 struct b2DistanceOutput
89 void b2Distance(b2DistanceOutput* output,
90 b2SimplexCache* cache,
91 const b2DistanceInput* input);
96 inline int32 b2DistanceProxy::GetVertexCount()
const
101 inline const b2Vec2& b2DistanceProxy::GetVertex(int32 index)
const
103 b2Assert(0 <= index && index < m_count);
104 return m_vertices[index];
107 inline int32 b2DistanceProxy::GetSupport(
const b2Vec2& d)
const
110 float32 bestValue = b2Dot(m_vertices[0], d);
111 for (int32 i = 1; i < m_count; ++i)
113 float32 value = b2Dot(m_vertices[i], d);
114 if (value > bestValue)
124 inline const b2Vec2& b2DistanceProxy::GetSupportVertex(
const b2Vec2& d)
const
127 float32 bestValue = b2Dot(m_vertices[0], d);
128 for (int32 i = 1; i < m_count; ++i)
130 float32 value = b2Dot(m_vertices[i], d);
131 if (value > bestValue)
138 return m_vertices[bestIndex];