| 1 | /* | 
|---|
| 2 | Bullet Continuous Collision Detection and Physics Library | 
|---|
| 3 | Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/ | 
|---|
| 4 |  | 
|---|
| 5 | This software is provided 'as-is', without any express or implied warranty. | 
|---|
| 6 | In no event will the authors be held liable for any damages arising from the use of this software. | 
|---|
| 7 | Permission is granted to anyone to use this software for any purpose,  | 
|---|
| 8 | including commercial applications, and to alter it and redistribute it freely,  | 
|---|
| 9 | subject to the following restrictions: | 
|---|
| 10 |  | 
|---|
| 11 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. | 
|---|
| 12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. | 
|---|
| 13 | 3. This notice may not be removed or altered from any source distribution. | 
|---|
| 14 | */ | 
|---|
| 15 |  | 
|---|
| 16 |  | 
|---|
| 17 | #ifndef MANIFOLD_RESULT_H | 
|---|
| 18 | #define MANIFOLD_RESULT_H | 
|---|
| 19 |  | 
|---|
| 20 | class btCollisionObject; | 
|---|
| 21 | #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" | 
|---|
| 22 | class btManifoldPoint; | 
|---|
| 23 |  | 
|---|
| 24 | #include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h" | 
|---|
| 25 |  | 
|---|
| 26 | #include "LinearMath/btTransform.h" | 
|---|
| 27 |  | 
|---|
| 28 | typedef bool (*ContactAddedCallback)(btManifoldPoint& cp,       const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1); | 
|---|
| 29 | extern ContactAddedCallback             gContactAddedCallback; | 
|---|
| 30 |  | 
|---|
| 31 |  | 
|---|
| 32 |  | 
|---|
| 33 | ///btManifoldResult is a helper class to manage  contact results. | 
|---|
| 34 | class btManifoldResult : public btDiscreteCollisionDetectorInterface::Result | 
|---|
| 35 | { | 
|---|
| 36 |         btPersistentManifold* m_manifoldPtr; | 
|---|
| 37 |  | 
|---|
| 38 |         //we need this for compounds | 
|---|
| 39 |         btTransform     m_rootTransA; | 
|---|
| 40 |         btTransform     m_rootTransB; | 
|---|
| 41 |  | 
|---|
| 42 |         btCollisionObject* m_body0; | 
|---|
| 43 |         btCollisionObject* m_body1; | 
|---|
| 44 |         int     m_partId0; | 
|---|
| 45 |         int m_partId1; | 
|---|
| 46 |         int m_index0; | 
|---|
| 47 |         int m_index1; | 
|---|
| 48 | public: | 
|---|
| 49 |  | 
|---|
| 50 |         btManifoldResult() | 
|---|
| 51 |         { | 
|---|
| 52 |         } | 
|---|
| 53 |  | 
|---|
| 54 |         btManifoldResult(btCollisionObject* body0,btCollisionObject* body1); | 
|---|
| 55 |  | 
|---|
| 56 |         virtual ~btManifoldResult() {}; | 
|---|
| 57 |  | 
|---|
| 58 |         void    setPersistentManifold(btPersistentManifold* manifoldPtr) | 
|---|
| 59 |         { | 
|---|
| 60 |                 m_manifoldPtr = manifoldPtr; | 
|---|
| 61 |         } | 
|---|
| 62 |  | 
|---|
| 63 |         const btPersistentManifold*     getPersistentManifold() const | 
|---|
| 64 |         { | 
|---|
| 65 |                 return m_manifoldPtr; | 
|---|
| 66 |         } | 
|---|
| 67 |         btPersistentManifold*   getPersistentManifold() | 
|---|
| 68 |         { | 
|---|
| 69 |                 return m_manifoldPtr; | 
|---|
| 70 |         } | 
|---|
| 71 |  | 
|---|
| 72 |         virtual void setShapeIdentifiers(int partId0,int index0,        int partId1,int index1) | 
|---|
| 73 |         { | 
|---|
| 74 |                         m_partId0=partId0; | 
|---|
| 75 |                         m_partId1=partId1; | 
|---|
| 76 |                         m_index0=index0; | 
|---|
| 77 |                         m_index1=index1;                 | 
|---|
| 78 |         } | 
|---|
| 79 |  | 
|---|
| 80 |         virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth); | 
|---|
| 81 |  | 
|---|
| 82 |         SIMD_FORCE_INLINE       void refreshContactPoints() | 
|---|
| 83 |         { | 
|---|
| 84 |                 btAssert(m_manifoldPtr); | 
|---|
| 85 |                 if (!m_manifoldPtr->getNumContacts()) | 
|---|
| 86 |                         return; | 
|---|
| 87 |  | 
|---|
| 88 |                 bool isSwapped = m_manifoldPtr->getBody0() != m_body0; | 
|---|
| 89 |  | 
|---|
| 90 |                 if (isSwapped) | 
|---|
| 91 |                 { | 
|---|
| 92 |                         m_manifoldPtr->refreshContactPoints(m_rootTransB,m_rootTransA); | 
|---|
| 93 |                 } else | 
|---|
| 94 |                 { | 
|---|
| 95 |                         m_manifoldPtr->refreshContactPoints(m_rootTransA,m_rootTransB); | 
|---|
| 96 |                 } | 
|---|
| 97 |         } | 
|---|
| 98 |  | 
|---|
| 99 |  | 
|---|
| 100 | }; | 
|---|
| 101 |  | 
|---|
| 102 | #endif //MANIFOLD_RESULT_H | 
|---|