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]);
104 btVector3 p1ToCentre = sphereCenter - vertices[0];
105 btScalar distanceFromPlane = p1ToCentre.
dot(normal);
107 if (distanceFromPlane <
btScalar(0.))
114 bool isInsideContactPlane = distanceFromPlane < radiusWithThreshold;
117 bool hasContact =
false;
119 if (isInsideContactPlane) {
123 contactPoint = sphereCenter - normal*distanceFromPlane;
126 btScalar contactCapsuleRadiusSqr = radiusWithThreshold*radiusWithThreshold;
136 if (distanceSqr < contactCapsuleRadiusSqr) {
139 contactPoint = nearestOnEdge;
147 btVector3 contactToCentre = sphereCenter - contactPoint;
150 if (distanceSqr < radiusWithThreshold*radiusWithThreshold)
155 resultNormal = contactToCentre;
157 point = contactPoint;
158 depth = -(radius-distance);
161 resultNormal = normal;
162 point = contactPoint;
192 r1 = edge1_normal.
dot( p1_to_p );
193 r2 = edge2_normal.dot( p2_to_p );
194 r3 = edge3_normal.dot( p3_to_p );
195 if ( ( r1 > 0 && r2 > 0 && r3 > 0 ) ||
196 ( 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
static float4 cross(const float4 &a, const float4 &b)
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...