intersect.hpp 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /// @ref gtx_intersect
  2. /// @file glm/gtx/intersect.hpp
  3. ///
  4. /// @see core (dependence)
  5. /// @see gtx_closest_point (dependence)
  6. ///
  7. /// @defgroup gtx_intersect GLM_GTX_intersect
  8. /// @ingroup gtx
  9. ///
  10. /// Include <glm/gtx/intersect.hpp> to use the features of this extension.
  11. ///
  12. /// Add intersection functions
  13. #pragma once
  14. // Dependency:
  15. #include <cfloat>
  16. #include <limits>
  17. #include "../glm.hpp"
  18. #include "../geometric.hpp"
  19. #include "../gtx/closest_point.hpp"
  20. #include "../gtx/vector_query.hpp"
  21. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  22. # ifndef GLM_ENABLE_EXPERIMENTAL
  23. # pragma message("GLM: GLM_GTX_closest_point is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.")
  24. # else
  25. # pragma message("GLM: GLM_GTX_closest_point extension included")
  26. # endif
  27. #endif
  28. namespace glm
  29. {
  30. /// @addtogroup gtx_intersect
  31. /// @{
  32. //! Compute the intersection of a ray and a plane.
  33. //! Ray direction and plane normal must be unit length.
  34. //! From GLM_GTX_intersect extension.
  35. template<typename genType>
  36. GLM_FUNC_DECL bool intersectRayPlane(
  37. genType const& orig, genType const& dir,
  38. genType const& planeOrig, genType const& planeNormal,
  39. typename genType::value_type & intersectionDistance);
  40. //! Compute the intersection of a ray and a triangle.
  41. /// Based om Tomas Möller implementation http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/raytri/
  42. //! From GLM_GTX_intersect extension.
  43. template<typename T, qualifier Q>
  44. GLM_FUNC_DECL bool intersectRayTriangle(
  45. vec<3, T, Q> const& orig, vec<3, T, Q> const& dir,
  46. vec<3, T, Q> const& v0, vec<3, T, Q> const& v1, vec<3, T, Q> const& v2,
  47. vec<2, T, Q>& baryPosition, T& distance);
  48. //! Compute the intersection of a line and a triangle.
  49. //! From GLM_GTX_intersect extension.
  50. template<typename genType>
  51. GLM_FUNC_DECL bool intersectLineTriangle(
  52. genType const& orig, genType const& dir,
  53. genType const& vert0, genType const& vert1, genType const& vert2,
  54. genType & position);
  55. //! Compute the intersection distance of a ray and a sphere.
  56. //! The ray direction vector is unit length.
  57. //! From GLM_GTX_intersect extension.
  58. template<typename genType>
  59. GLM_FUNC_DECL bool intersectRaySphere(
  60. genType const& rayStarting, genType const& rayNormalizedDirection,
  61. genType const& sphereCenter, typename genType::value_type const sphereRadiusSquered,
  62. typename genType::value_type & intersectionDistance);
  63. //! Compute the intersection of a ray and a sphere.
  64. //! From GLM_GTX_intersect extension.
  65. template<typename genType>
  66. GLM_FUNC_DECL bool intersectRaySphere(
  67. genType const& rayStarting, genType const& rayNormalizedDirection,
  68. genType const& sphereCenter, const typename genType::value_type sphereRadius,
  69. genType & intersectionPosition, genType & intersectionNormal);
  70. //! Compute the intersection of a line and a sphere.
  71. //! From GLM_GTX_intersect extension
  72. template<typename genType>
  73. GLM_FUNC_DECL bool intersectLineSphere(
  74. genType const& point0, genType const& point1,
  75. genType const& sphereCenter, typename genType::value_type sphereRadius,
  76. genType & intersectionPosition1, genType & intersectionNormal1,
  77. genType & intersectionPosition2 = genType(), genType & intersectionNormal2 = genType());
  78. /// @}
  79. }//namespace glm
  80. #include "intersect.inl"