b3GjkEpa.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 B3_GJK_EPA2_H
  23. #define B3_GJK_EPA2_H
  24. #include "Bullet3Common/b3AlignedObjectArray.h"
  25. #include "Bullet3Common/b3Transform.h"
  26. #include "Bullet3Collision/NarrowPhaseCollision/shared/b3ConvexPolyhedronData.h"
  27. ///btGjkEpaSolver contributed under zlib by Nathanael Presson
  28. struct b3GjkEpaSolver2
  29. {
  30. struct sResults
  31. {
  32. enum eStatus
  33. {
  34. Separated, /* Shapes doesnt penetrate */
  35. Penetrating, /* Shapes are penetrating */
  36. GJK_Failed, /* GJK phase fail, no big issue, shapes are probably just 'touching' */
  37. EPA_Failed /* EPA phase fail, bigger problem, need to save parameters, and debug */
  38. } status;
  39. b3Vector3 witnesses[2];
  40. b3Vector3 normal;
  41. b3Scalar distance;
  42. };
  43. static int StackSizeRequirement();
  44. static bool Distance(const b3Transform& transA, const b3Transform& transB,
  45. const b3ConvexPolyhedronData* hullA, const b3ConvexPolyhedronData* hullB,
  46. const b3AlignedObjectArray<b3Vector3>& verticesA,
  47. const b3AlignedObjectArray<b3Vector3>& verticesB,
  48. const b3Vector3& guess,
  49. sResults& results);
  50. static bool Penetration(const b3Transform& transA, const b3Transform& transB,
  51. const b3ConvexPolyhedronData* hullA, const b3ConvexPolyhedronData* hullB,
  52. const b3AlignedObjectArray<b3Vector3>& verticesA,
  53. const b3AlignedObjectArray<b3Vector3>& verticesB,
  54. const b3Vector3& guess,
  55. sResults& results,
  56. bool usemargins = true);
  57. #if 0
  58. static b3Scalar SignedDistance( const b3Vector3& position,
  59. b3Scalar margin,
  60. const btConvexShape* shape,
  61. const btTransform& wtrs,
  62. sResults& results);
  63. static bool SignedDistance( const btConvexShape* shape0,const btTransform& wtrs0,
  64. const btConvexShape* shape1,const btTransform& wtrs1,
  65. const b3Vector3& guess,
  66. sResults& results);
  67. #endif
  68. };
  69. #endif //B3_GJK_EPA2_H