25 m_contactBreakingThreshold(contactBreakingThreshold)
50 btVector3 pointOnA = transformB*point+normalOnB*depth;
84 return diff.
dot(diff);
100 btScalar radiusWithThreshold = radius + contactBreakingThreshold;
102 btVector3 normal = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]);
105 bool hasContact =
false;
112 btVector3 p1ToCentre = sphereCenter - vertices[0];
113 btScalar distanceFromPlane = p1ToCentre.
dot(normal);
115 if (distanceFromPlane <
btScalar(0.))
122 bool isInsideContactPlane = distanceFromPlane < radiusWithThreshold;
126 if (isInsideContactPlane) {
130 contactPoint = sphereCenter - normal*distanceFromPlane;
134 btScalar contactCapsuleRadiusSqr = radiusWithThreshold*radiusWithThreshold;
144 if (distanceSqr < contactCapsuleRadiusSqr) {
147 contactPoint = nearestOnEdge;
156 btVector3 contactToCentre = sphereCenter - contactPoint;
159 if (distanceSqr < radiusWithThreshold*radiusWithThreshold)
161 if (distanceSqr>SIMD_EPSILON)
164 resultNormal = contactToCentre;
166 point = contactPoint;
167 depth = -(radius-distance);
170 resultNormal = normal;
171 point = contactPoint;
201 r1 = edge1_normal.
dot( p1_to_p );
202 r2 = edge2_normal.dot( p2_to_p );
203 r3 = edge3_normal.dot( p3_to_p );
204 if ( ( r1 > 0 && r2 > 0 && r3 > 0 ) ||
205 ( r1 <= 0 && r2 <= 0 && r3 <= 0 ) )
btScalar m_contactBreakingThreshold
btScalar length2() const
Return the length of the vector squared.
btScalar btSqrt(btScalar y)
btTriangleShape * m_triangle
The btSphereShape implements an implicit sphere, centered around a local origin with radius...
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
bool facecontains(const btVector3 &p, const btVector3 *vertices, btVector3 &normal)
virtual void getClosestPoints(const ClosestPointInput &input, Result &output, class btIDebugDraw *debugDraw, bool swapResults=false)
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 getRadius() const
btVector3 & getVertexPtr(int index)
bool collide(const btVector3 &sphereCenter, btVector3 &point, btVector3 &resultNormal, btScalar &depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold)
SphereTriangleDetector(btSphereShape *sphere, btTriangleShape *triangle, btScalar contactBreakingThreshold)
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p)
btVector3 can be used to represent 3D points and vectors.
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)=0
virtual void getEdge(int i, btVector3 &pa, btVector3 &pb) const
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...
virtual int getNumEdges() const