btGjkEpa2.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. Bullet Continuous Collision Detection and Physics Library
  3. Copyright (c) 2003-2008 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
  6. 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
  9. freely,
  10. subject to the following restrictions:
  11. 1. The origin of this software must not be misrepresented; you must not
  12. claim that you wrote the original software. If you use this software in a
  13. product, an acknowledgment in the product documentation would be appreciated
  14. but is not required.
  15. 2. Altered source versions must be plainly marked as such, and must not be
  16. misrepresented as being the original software.
  17. 3. This notice may not be removed or altered from any source distribution.
  18. */
  19. /*
  20. GJK-EPA collision solver by Nathanael Presson, 2008
  21. */
  22. #ifndef BT_GJK_EPA2_H
  23. #define BT_GJK_EPA2_H
  24. #include "BulletCollision/CollisionShapes/btConvexShape.h"
  25. ///btGjkEpaSolver contributed under zlib by Nathanael Presson
  26. struct btGjkEpaSolver2
  27. {
  28. struct sResults
  29. {
  30. enum eStatus
  31. {
  32. Separated, /* Shapes doesnt penetrate */
  33. Penetrating, /* Shapes are penetrating */
  34. GJK_Failed, /* GJK phase fail, no big issue, shapes are probably just 'touching' */
  35. EPA_Failed /* EPA phase fail, bigger problem, need to save parameters, and debug */
  36. } status;
  37. btVector3 witnesses[2];
  38. btVector3 normal;
  39. btScalar distance;
  40. };
  41. static int StackSizeRequirement();
  42. static bool Distance(const btConvexShape* shape0, const btTransform& wtrs0,
  43. const btConvexShape* shape1, const btTransform& wtrs1,
  44. const btVector3& guess,
  45. sResults& results);
  46. static bool Penetration(const btConvexShape* shape0, const btTransform& wtrs0,
  47. const btConvexShape* shape1, const btTransform& wtrs1,
  48. const btVector3& guess,
  49. sResults& results,
  50. bool usemargins = true);
  51. #ifndef __SPU__
  52. static btScalar SignedDistance(const btVector3& position,
  53. btScalar margin,
  54. const btConvexShape* shape,
  55. const btTransform& wtrs,
  56. sResults& results);
  57. static bool SignedDistance(const btConvexShape* shape0, const btTransform& wtrs0,
  58. const btConvexShape* shape1, const btTransform& wtrs1,
  59. const btVector3& guess,
  60. sResults& results);
  61. #endif //__SPU__
  62. };
  63. #endif //BT_GJK_EPA2_H