1 #include "ClosestNotMeConvexResultCallback.h"
2
ClosestNotMeConvexResultCallback(btCollisionObject * me,const btVector3 & fromA,const btVector3 & toA)3 ClosestNotMeConvexResultCallback::ClosestNotMeConvexResultCallback (btCollisionObject* me,const btVector3& fromA,const btVector3& toA) :
4 ClosestConvexResultCallback(fromA,toA),
5 m_me(me),
6 m_allowedPenetration(0.0f) {}
7
addSingleResult(btCollisionWorld::LocalConvexResult & convexResult,bool normalInWorldSpace)8 btScalar ClosestNotMeConvexResultCallback::addSingleResult(btCollisionWorld::LocalConvexResult& convexResult,bool normalInWorldSpace)
9 {
10 if (convexResult.m_hitCollisionObject == m_me)
11 return 1.0f;
12
13 //ignore result if there is no contact response
14 if(!convexResult.m_hitCollisionObject->hasContactResponse())
15 return 1.0f;
16
17 btVector3 linVelA,linVelB;
18 linVelA = m_convexToWorld-m_convexFromWorld;
19 linVelB = btVector3(0,0,0);//toB.getOrigin()-fromB.getOrigin();
20
21 btVector3 relativeVelocity = (linVelA-linVelB);
22 //don't report time of impact for motion away from the contact normal (or causes minor penetration)
23 if (convexResult.m_hitNormalLocal.dot(relativeVelocity)>=-m_allowedPenetration)
24 return 1.f;
25
26 return ClosestConvexResultCallback::addSingleResult (convexResult, normalInWorldSpace);
27 }
28
needsCollision(btBroadphaseProxy * proxy0)29 bool ClosestNotMeConvexResultCallback::needsCollision(btBroadphaseProxy* proxy0)
30 {
31 //don't collide with itself
32 if (proxy0->m_clientObject == m_me)
33 return false;
34
35 ///don't do CCD when the collision filters are not matching
36 if (!ClosestConvexResultCallback::needsCollision(proxy0))
37 return false;
38
39 btCollisionObject* otherObj = (btCollisionObject*) proxy0->m_clientObject;
40
41 return false;
42 }
43