physicsCollision.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _T3D_PHYSICS_PHYSICSCOLLISION_H_
  23. #define _T3D_PHYSICS_PHYSICSCOLLISION_H_
  24. #ifndef _REFBASE_H_
  25. #include "core/util/refBase.h"
  26. #endif
  27. class Point3F;
  28. #ifndef USE_TEMPLATE_MATRIX
  29. class MatrixF;
  30. #else
  31. template<typename DATA_TYPE, U32 rows, U32 cols> class Matrix;
  32. typedef Matrix<F32, 4, 4> MatrixF;
  33. #endif
  34. class PlaneF;
  35. /// The shared collision representation for a instance of a
  36. /// static or dynamic physics body.
  37. ///
  38. /// Note that making very big convex primitives can cause bad
  39. /// queries and collisions in some physics providers.
  40. ///
  41. /// @see PhysicsBody
  42. ///
  43. class PhysicsCollision : public StrongRefBase
  44. {
  45. public:
  46. /// Add an infinite plane to the collision shape.
  47. ///
  48. /// This shape is assumed to be static in some physics
  49. /// providers and will at times be faked with a large box.
  50. ///
  51. virtual void addPlane( const PlaneF &plane ) = 0;
  52. /// Add a box to the collision shape.
  53. virtual void addBox( const Point3F &halfWidth,
  54. const MatrixF &localXfm ) = 0;
  55. /// Add a sphere to the collision shape.
  56. virtual void addSphere( F32 radius,
  57. const MatrixF &localXfm ) = 0;
  58. /// Add a Y axis capsule to the collision shape.
  59. virtual void addCapsule( F32 radius,
  60. F32 height,
  61. const MatrixF &localXfm ) = 0;
  62. /// Add a point cloud convex hull to the collision shape.
  63. virtual bool addConvex( const Point3F *points,
  64. U32 count,
  65. const MatrixF &localXfm ) = 0;
  66. /// Add a triangle mesh to the collision shape.
  67. virtual bool addTriangleMesh( const Point3F *vert,
  68. U32 vertCount,
  69. const U32 *index,
  70. U32 triCount,
  71. const MatrixF &localXfm ) = 0;
  72. /// Add a heightfield to the collision shape.
  73. virtual bool addHeightfield( const U16 *heights,
  74. const bool *holes,
  75. U32 blockSize,
  76. F32 metersPerSample,
  77. const MatrixF &localXfm ) = 0;
  78. };
  79. #endif // _T3D_PHYSICS_PHYSICSCOLLISION_H_