24 m_contactBreakingThreshold(contactBreakingThreshold)
47 btVector3 pointOnA = transformB * point + normalOnB * depth;
48 output.addContactPoint(normalOnA, pointOnA, depth);
52 output.addContactPoint(transformB.
getBasis() * normal, transformB * point, depth);
84 nearest = from + t * v;
85 return diff.
dot(diff);
101 btScalar radiusWithThreshold = radius + contactBreakingThreshold;
103 btVector3 normal = (vertices[1] - vertices[0]).cross(vertices[2] - vertices[0]);
106 bool hasContact =
false;
113 btVector3 p1ToCentre = sphereCenter - vertices[0];
114 btScalar distanceFromPlane = p1ToCentre.
dot(normal);
116 if (distanceFromPlane <
btScalar(0.))
123 bool isInsideContactPlane = distanceFromPlane < radiusWithThreshold;
127 if (isInsideContactPlane)
133 contactPoint = sphereCenter - normal * distanceFromPlane;
138 btScalar contactCapsuleRadiusSqr = radiusWithThreshold * radiusWithThreshold;
139 btScalar minDistSqr = contactCapsuleRadiusSqr;
149 if (distanceSqr < minDistSqr)
152 minDistSqr = distanceSqr;
154 contactPoint = nearestOnEdge;
163 btVector3 contactToCentre = sphereCenter - contactPoint;
166 if (distanceSqr < radiusWithThreshold * radiusWithThreshold)
171 resultNormal = contactToCentre;
173 point = contactPoint;
174 depth = -(radius - distance);
178 resultNormal = normal;
179 point = contactPoint;
208 r1 = edge1_normal.
dot(p1_to_p);
209 r2 = edge2_normal.
dot(p2_to_p);
210 r3 = edge3_normal.
dot(p3_to_p);
211 if ((r1 > 0 && r2 > 0 && r3 > 0) ||
212 (r1 <= 0 && r2 <= 0 && r3 <= 0))
btScalar SegmentSqrDistance(const btVector3 &from, const btVector3 &to, const btVector3 &p, btVector3 &nearest)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btScalar btSqrt(btScalar y)
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
The btSphereShape implements an implicit sphere, centered around a local origin with radius.
btScalar getRadius() const
virtual void getEdge(int i, btVector3 &pa, btVector3 &pb) const
virtual int getNumEdges() const
btVector3 & getVertexPtr(int index)
btVector3 can be used to represent 3D points and vectors.
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
btScalar dot(const btVector3 &v) const
Return the dot product.
btScalar length2() const
Return the length of the vector squared.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
btTriangleShape * m_triangle
bool collide(const btVector3 &sphereCenter, btVector3 &point, btVector3 &resultNormal, btScalar &depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold)
SphereTriangleDetector(btSphereShape *sphere, btTriangleShape *triangle, btScalar contactBreakingThreshold)
bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p)
bool facecontains(const btVector3 &p, const btVector3 *vertices, btVector3 &normal)
virtual void getClosestPoints(const ClosestPointInput &input, Result &output, class btIDebugDraw *debugDraw, bool swapResults=false)
btScalar m_contactBreakingThreshold