b3GjkPairDetector.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef B3_GJK_PAIR_DETECTOR_H
  2. #define B3_GJK_PAIR_DETECTOR_H
  3. #include "Bullet3Common/b3Vector3.h"
  4. #include "Bullet3Common/b3AlignedObjectArray.h"
  5. class b3Transform;
  6. struct b3GjkEpaSolver2;
  7. class b3VoronoiSimplexSolver;
  8. struct b3ConvexPolyhedronData;
  9. B3_ATTRIBUTE_ALIGNED16(struct) b3GjkPairDetector
  10. {
  11. b3Vector3 m_cachedSeparatingAxis;
  12. b3GjkEpaSolver2* m_penetrationDepthSolver;
  13. b3VoronoiSimplexSolver* m_simplexSolver;
  14. bool m_ignoreMargin;
  15. b3Scalar m_cachedSeparatingDistance;
  16. public:
  17. //some debugging to fix degeneracy problems
  18. int m_lastUsedMethod;
  19. int m_curIter;
  20. int m_degenerateSimplex;
  21. int m_catchDegeneracies;
  22. int m_fixContactNormalDirection;
  23. b3GjkPairDetector(b3VoronoiSimplexSolver* simplexSolver,b3GjkEpaSolver2* penetrationDepthSolver);
  24. virtual ~b3GjkPairDetector() {};
  25. //void getClosestPoints(,Result& output);
  26. void setCachedSeperatingAxis(const b3Vector3& seperatingAxis)
  27. {
  28. m_cachedSeparatingAxis = seperatingAxis;
  29. }
  30. const b3Vector3& getCachedSeparatingAxis() const
  31. {
  32. return m_cachedSeparatingAxis;
  33. }
  34. b3Scalar getCachedSeparatingDistance() const
  35. {
  36. return m_cachedSeparatingDistance;
  37. }
  38. void setPenetrationDepthSolver(b3GjkEpaSolver2* penetrationDepthSolver)
  39. {
  40. m_penetrationDepthSolver = penetrationDepthSolver;
  41. }
  42. ///don't use setIgnoreMargin, it's for Bullet's internal use
  43. void setIgnoreMargin(bool ignoreMargin)
  44. {
  45. m_ignoreMargin = ignoreMargin;
  46. }
  47. };
  48. bool getClosestPoints(b3GjkPairDetector* gjkDetector, const b3Transform& transA, const b3Transform& transB,
  49. const b3ConvexPolyhedronData& hullA, const b3ConvexPolyhedronData& hullB,
  50. const b3AlignedObjectArray<b3Vector3>& verticesA,
  51. const b3AlignedObjectArray<b3Vector3>& verticesB,
  52. b3Scalar maximumDistanceSquared,
  53. b3Vector3& resultSepNormal,
  54. float& resultSepDistance,
  55. b3Vector3& resultPointOnB);
  56. #endif //B3_GJK_PAIR_DETECTOR_H