27#define USE_PERSISTENT_CONTACTS 1
36 m_manifoldPtr = m_dispatcher->getNewManifold(obj0Wrap->getCollisionObject(), obj1Wrap->getCollisionObject());
86#define b2Dot(a, b) (a).dot(b)
87#define b2Mul(a, b) (a) * (b)
88#define b2MulT(a, b) (a).transpose() * (b)
89#define b2Cross(a, b) (a).cross(b)
90#define btCrossS(a, s) btVector3(s* a.getY(), -s* a.getX(), 0.f)
105 if (distance0 <= 0.0f) vOut[numOut++] = vIn[0];
106 if (distance1 <= 0.0f) vOut[numOut++] = vIn[1];
109 if (distance0 * distance1 < 0.0f)
113 vOut[numOut].
v = vIn[0].
v +
interp * (vIn[1].
v - vIn[0].
v);
114 if (distance0 > 0.0f)
116 vOut[numOut].
id = vIn[0].
id;
120 vOut[numOut].
id = vIn[1].
id;
132 const btVector3* vertices1 = poly1->getVertices();
133 const btVector3* normals1 = poly1->getNormals();
135 int count2 = poly2->getVertexCount();
136 const btVector3* vertices2 = poly2->getVertices();
149 index = (int)normal1.minDot(vertices2, count2,
minDot);
162 int count1 = poly1->getVertexCount();
163 const btVector3* normals1 = poly1->getNormals();
173 edge = (int)dLocal1.maxDot(normals1, count1,
maxDot);
183 int prevEdge = edge - 1 >= 0 ? edge - 1 : count1 - 1;
191 int nextEdge = edge + 1 < count1 ? edge + 1 : 0;
202 if (sPrev > s && sPrev > sNext)
206 bestSeparation = sPrev;
212 bestSeparation = sNext;
224 edge = bestEdge - 1 >= 0 ? bestEdge - 1 : count1 - 1;
226 edge = bestEdge + 1 < count1 ? bestEdge + 1 : 0;
234 if (s > bestSeparation)
245 *edgeIndex = bestEdge;
246 return bestSeparation;
253 const btVector3* normals1 = poly1->getNormals();
255 int count2 = poly2->getVertexCount();
256 const btVector3* vertices2 = poly2->getVertices();
257 const btVector3* normals2 = poly2->getNormals();
267 for (
int i = 0;
i < count2; ++
i)
279 int i2 = i1 + 1 < count2 ? i1 + 1 : 0;
281 c[0].
v =
b2Mul(xf2, vertices2[i1]);
286 c[1].
v =
b2Mul(xf2, vertices2[i2]);
305 if (separationA > 0.0f)
310 if (separationB > 0.0f)
318 const btScalar k_relativeTol = 0.98f;
319 const btScalar k_absoluteTol = 0.001f;
322 if (separationB > k_relativeTol * separationA + k_absoluteTol)
344 int count1 = poly1->getVertexCount();
345 const btVector3* vertices1 = poly1->getVertices();
348 btVector3 v12 = edge1 + 1 < count1 ? vertices1[edge1 + 1] : vertices1[0];
352 sideNormal.normalize();
355 v11 =
b2Mul(xf1, v11);
356 v12 =
b2Mul(xf1, v12);
364 clipPoints1[0].
v.setValue(0, 0, 0);
365 clipPoints1[1].
v.setValue(0, 0, 0);
368 clipPoints2[0].
v.setValue(0, 0, 0);
369 clipPoints2[1].
v.setValue(0, 0, 0);
388 btVector3 manifoldNormal = flip ? -frontNormal : frontNormal;
393 btScalar separation =
b2Dot(frontNormal, clipPoints2[
i].
v) - frontOffset;
395 if (separation <= 0.0f)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
static int ClipSegmentToLine(ClipVertex vOut[2], ClipVertex vIn[2], const btVector3 &normal, btScalar offset)
static btScalar EdgeSeparation(const btBox2dShape *poly1, const btTransform &xf1, int edge1, const btBox2dShape *poly2, const btTransform &xf2)
static void FindIncidentEdge(ClipVertex c[2], const btBox2dShape *poly1, const btTransform &xf1, int edge1, const btBox2dShape *poly2, const btTransform &xf2)
static btScalar FindMaxSeparation(int *edgeIndex, const btBox2dShape *poly1, const btTransform &xf1, const btBox2dShape *poly2, const btTransform &xf2)
void b2CollidePolygons(btManifoldResult *manifold, const btBox2dShape *polyA, const btTransform &xfA, const btBox2dShape *polyB, const btTransform &xfB)
btBox2dShape(const btVector3 &boxHalfExtents)
a btBox2dShape is a flat 2D box in the X-Y plane (Z extents are zero)
int getVertexCount() const
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
SIMD_FORCE_INLINE long minDot(const btVector3 *array, long array_count, btScalar &dotOut) const
returns index of minimum dot product between this and vectors in array[]
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
SIMD_FORCE_INLINE long maxDot(const btVector3 *array, long array_count, btScalar &dotOut) const
returns index of maximum dot product between this and vectors in array[]
btActivatingCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo &ci)
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
virtual ~btBox2dBox2dCollisionAlgorithm()
virtual btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
btBox2dBox2dCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo &ci)
btDispatcher * m_dispatcher
btManifoldResult is a helper class to manage contact results.
void setPersistentManifold(btPersistentManifold *manifoldPtr)
SIMD_FORCE_INLINE void refreshContactPoints()
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)
dot(value.rgb, luminance_coefficients)") DEFINE_VALUE("REDUCE(lhs
ccl_device_inline float interp(const float a, const float b, const float t)
SIMD_FORCE_INLINE const btCollisionShape * getCollisionShape() const
SIMD_FORCE_INLINE const btTransform & getWorldTransform() const
SIMD_FORCE_INLINE const btCollisionObject * getCollisionObject() const