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;
135 btScalar minDistSqr = contactCapsuleRadiusSqr;
145 if (distanceSqr < minDistSqr) {
147 minDistSqr = distanceSqr;
149 contactPoint = nearestOnEdge;
158 btVector3 contactToCentre = sphereCenter - contactPoint;
161 if (distanceSqr < radiusWithThreshold*radiusWithThreshold)
163 if (distanceSqr>SIMD_EPSILON)
166 resultNormal = contactToCentre;
168 point = contactPoint;
169 depth = -(radius-distance);
172 resultNormal = normal;
173 point = contactPoint;
203 r1 = edge1_normal.
dot( p1_to_p );
204 r2 = edge2_normal.dot( p2_to_p );
205 r3 = edge3_normal.dot( p3_to_p );
206 if ( ( r1 > 0 && r2 > 0 && r3 > 0 ) ||
207 ( r1 <= 0 && r2 <= 0 && r3 <= 0 ) )
btScalar m_contactBreakingThreshold
btScalar btSqrt(btScalar y)
btTriangleShape * m_triangle
The btSphereShape implements an implicit sphere, centered around a local origin with radius...
btScalar dot(const btVector3 &v) const
Return the dot product.
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 & getVertexPtr(int index)
bool collide(const btVector3 &sphereCenter, btVector3 &point, btVector3 &resultNormal, btScalar &depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold)
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
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)
virtual int getNumEdges() const
btVector3 can be used to represent 3D points and vectors.
btScalar length2() const
Return the length of the vector squared.
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)=0
virtual void getEdge(int i, btVector3 &pa, btVector3 &pb) const
btScalar getRadius() 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...