btConvexCast.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_CONVEX_CAST_H
  14. #define BT_CONVEX_CAST_H
  15. #include "bullet/LinearMath/btTransform.h"
  16. #include "bullet/LinearMath/btVector3.h"
  17. #include "bullet/LinearMath/btScalar.h"
  18. class btMinkowskiSumShape;
  19. #include "bullet/LinearMath/btIDebugDraw.h"
  20. /// btConvexCast is an interface for Casting
  21. class btConvexCast
  22. {
  23. public:
  24. virtual ~btConvexCast();
  25. ///RayResult stores the closest result
  26. /// alternatively, add a callback method to decide about closest/all results
  27. struct CastResult
  28. {
  29. //virtual bool addRayResult(const btVector3& normal,btScalar fraction) = 0;
  30. virtual void DebugDraw(btScalar fraction) {(void)fraction;}
  31. virtual void drawCoordSystem(const btTransform& trans) {(void)trans;}
  32. virtual void reportFailure(int errNo, int numIterations) {(void)errNo;(void)numIterations;}
  33. CastResult()
  34. :m_fraction(btScalar(BT_LARGE_FLOAT)),
  35. m_debugDrawer(0),
  36. m_allowedPenetration(btScalar(0))
  37. {
  38. }
  39. virtual ~CastResult() {};
  40. btTransform m_hitTransformA;
  41. btTransform m_hitTransformB;
  42. btVector3 m_normal;
  43. btVector3 m_hitPoint;
  44. btScalar m_fraction; //input and output
  45. btIDebugDraw* m_debugDrawer;
  46. btScalar m_allowedPenetration;
  47. };
  48. /// cast a convex against another convex object
  49. virtual bool calcTimeOfImpact(
  50. const btTransform& fromA,
  51. const btTransform& toA,
  52. const btTransform& fromB,
  53. const btTransform& toB,
  54. CastResult& result) = 0;
  55. };
  56. #endif //BT_CONVEX_CAST_H