physicsCollision.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. class MatrixF;
  29. class PlaneF;
  30. /// The shared collision representation for a instance of a
  31. /// static or dynamic physics body.
  32. ///
  33. /// Note that making very big convex primitives can cause bad
  34. /// queries and collisions in some physics providers.
  35. ///
  36. /// @see PhysicsBody
  37. ///
  38. class PhysicsCollision : public StrongRefBase
  39. {
  40. public:
  41. /// Add an infinite plane to the collision shape.
  42. ///
  43. /// This shape is assumed to be static in some physics
  44. /// providers and will at times be faked with a large box.
  45. ///
  46. virtual void addPlane( const PlaneF &plane ) = 0;
  47. /// Add a box to the collision shape.
  48. virtual void addBox( const Point3F &halfWidth,
  49. const MatrixF &localXfm ) = 0;
  50. /// Add a sphere to the collision shape.
  51. virtual void addSphere( F32 radius,
  52. const MatrixF &localXfm ) = 0;
  53. /// Add a Y axis capsule to the collision shape.
  54. virtual void addCapsule( F32 radius,
  55. F32 height,
  56. const MatrixF &localXfm ) = 0;
  57. /// Add a point cloud convex hull to the collision shape.
  58. virtual bool addConvex( const Point3F *points,
  59. U32 count,
  60. const MatrixF &localXfm ) = 0;
  61. /// Add a triangle mesh to the collision shape.
  62. virtual bool addTriangleMesh( const Point3F *vert,
  63. U32 vertCount,
  64. const U32 *index,
  65. U32 triCount,
  66. const MatrixF &localXfm ) = 0;
  67. /// Add a heightfield to the collision shape.
  68. virtual bool addHeightfield( const U16 *heights,
  69. const bool *holes,
  70. U32 blockSize,
  71. F32 metersPerSample,
  72. const MatrixF &localXfm ) = 0;
  73. };
  74. #endif // _T3D_PHYSICS_PHYSICSCOLLISION_H_