btRayShape.h 4.1 KB

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