btRayShape.h 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*************************************************************************/
  2. /* btRayShape.h */
  3. /* Author: AndreaCatania */
  4. /*************************************************************************/
  5. /* This file is part of: */
  6. /* GODOT ENGINE */
  7. /* http://www.godotengine.org */
  8. /*************************************************************************/
  9. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  10. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  11. /* */
  12. /* Permission is hereby granted, free of charge, to any person obtaining */
  13. /* a copy of this software and associated documentation files (the */
  14. /* "Software"), to deal in the Software without restriction, including */
  15. /* without limitation the rights to use, copy, modify, merge, publish, */
  16. /* distribute, sublicense, and/or sell copies of the Software, and to */
  17. /* permit persons to whom the Software is furnished to do so, subject to */
  18. /* the following conditions: */
  19. /* */
  20. /* The above copyright notice and this permission notice shall be */
  21. /* included in all copies or substantial portions of the Software. */
  22. /* */
  23. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  24. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  25. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  26. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  27. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  28. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  29. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  30. /*************************************************************************/
  31. /// IMPORTANT The class name and filename was created by following Bullet writing rules for an easy (eventually ) porting to bullet
  32. /// This shape is a custom shape that is not present to Bullet physics engine
  33. #ifndef BTRAYSHAPE_H
  34. #define BTRAYSHAPE_H
  35. #include "BulletCollision/CollisionShapes/btConvexInternalShape.h"
  36. /// Ray shape around z axis
  37. ATTRIBUTE_ALIGNED16(class)
  38. btRayShape : public btConvexInternalShape {
  39. btScalar m_length;
  40. /// The default axis is the z
  41. btVector3 m_shapeAxis;
  42. btTransform m_cacheSupportPoint;
  43. btScalar m_cacheScaledLength;
  44. public:
  45. BT_DECLARE_ALIGNED_ALLOCATOR();
  46. btRayShape(btScalar length);
  47. virtual ~btRayShape();
  48. void setLength(btScalar p_length);
  49. btScalar getLength() const { return m_length; }
  50. const btTransform &getSupportPoint() const { return m_cacheSupportPoint; }
  51. const btScalar &getScaledLength() const { return m_cacheScaledLength; }
  52. virtual btVector3 localGetSupportingVertex(const btVector3 &vec) const;
  53. #ifndef __SPU__
  54. virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3 &vec) const;
  55. #endif //#ifndef __SPU__
  56. virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3 *vectors, btVector3 *supportVerticesOut, int numVectors) const;
  57. ///getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
  58. virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const;
  59. #ifndef __SPU__
  60. virtual void calculateLocalInertia(btScalar mass, btVector3 & inertia) const;
  61. virtual const char *getName() const {
  62. return "RayZ";
  63. }
  64. #endif //__SPU__
  65. virtual int getNumPreferredPenetrationDirections() const;
  66. virtual void getPreferredPenetrationDirection(int index, btVector3 &penetrationVector) const;
  67. private:
  68. void reload_cache();
  69. };
  70. #endif // BTRAYSHAPE_H