btSoftSoftCollisionAlgorithm.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. Bullet Continuous Collision Detection and Physics Library
  3. Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
  4. This software is provided 'as-is', without any express or implied warranty.
  5. In no event will the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it freely,
  8. subject to the following restrictions:
  9. 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.
  10. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  11. 3. This notice may not be removed or altered from any source distribution.
  12. */
  13. #ifndef BT_SOFT_SOFT_COLLISION_ALGORITHM_H
  14. #define BT_SOFT_SOFT_COLLISION_ALGORITHM_H
  15. #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
  16. #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
  17. #include "BulletCollision/BroadphaseCollision/btDispatcher.h"
  18. #include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
  19. class btPersistentManifold;
  20. class btSoftBody;
  21. ///collision detection between two btSoftBody shapes
  22. class btSoftSoftCollisionAlgorithm : public btCollisionAlgorithm
  23. {
  24. bool m_ownManifold;
  25. btPersistentManifold* m_manifoldPtr;
  26. // btSoftBody* m_softBody0;
  27. // btSoftBody* m_softBody1;
  28. public:
  29. btSoftSoftCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
  30. : btCollisionAlgorithm(ci) {}
  31. virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
  32. virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
  33. virtual void getAllContactManifolds(btManifoldArray& manifoldArray)
  34. {
  35. if (m_manifoldPtr && m_ownManifold)
  36. manifoldArray.push_back(m_manifoldPtr);
  37. }
  38. btSoftSoftCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap);
  39. virtual ~btSoftSoftCollisionAlgorithm();
  40. struct CreateFunc :public btCollisionAlgorithmCreateFunc
  41. {
  42. virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
  43. {
  44. int bbsize = sizeof(btSoftSoftCollisionAlgorithm);
  45. void* ptr = ci.m_dispatcher1->allocateCollisionAlgorithm(bbsize);
  46. return new(ptr) btSoftSoftCollisionAlgorithm(0,ci,body0Wrap,body1Wrap);
  47. }
  48. };
  49. };
  50. #endif //BT_SOFT_SOFT_COLLISION_ALGORITHM_H