intersect.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #ifndef GLM_ENABLE_EXPERIMENTAL
  22. # error "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."
  23. #elif GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  24. # pragma message("GLM: GLM_GTX_closest_point extension included")
  25. #endif
  26. namespace glm
  27. {
  28. /// @addtogroup gtx_intersect
  29. /// @{
  30. //! Compute the intersection of a ray and a plane.
  31. //! Ray direction and plane normal must be unit length.
  32. //! From GLM_GTX_intersect extension.
  33. template<typename genType>
  34. GLM_FUNC_DECL bool intersectRayPlane(
  35. genType const& orig, genType const& dir,
  36. genType const& planeOrig, genType const& planeNormal,
  37. typename genType::value_type & intersectionDistance);
  38. //! Compute the intersection of a ray and a triangle.
  39. /// Based om Tomas Möller implementation http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/raytri/
  40. //! From GLM_GTX_intersect extension.
  41. template<typename T, qualifier Q>
  42. GLM_FUNC_DECL bool intersectRayTriangle(
  43. vec<3, T, Q> const& orig, vec<3, T, Q> const& dir,
  44. vec<3, T, Q> const& v0, vec<3, T, Q> const& v1, vec<3, T, Q> const& v2,
  45. vec<2, T, Q>& baryPosition, T& distance);
  46. //! Compute the intersection of a line and a triangle.
  47. //! From GLM_GTX_intersect extension.
  48. template<typename genType>
  49. GLM_FUNC_DECL bool intersectLineTriangle(
  50. genType const& orig, genType const& dir,
  51. genType const& vert0, genType const& vert1, genType const& vert2,
  52. genType & position);
  53. //! Compute the intersection distance of a ray and a sphere.
  54. //! The ray direction vector is unit length.
  55. //! From GLM_GTX_intersect extension.
  56. template<typename genType>
  57. GLM_FUNC_DECL bool intersectRaySphere(
  58. genType const& rayStarting, genType const& rayNormalizedDirection,
  59. genType const& sphereCenter, typename genType::value_type const sphereRadiusSquared,
  60. typename genType::value_type & intersectionDistance);
  61. //! Compute the intersection of a ray and a sphere.
  62. //! From GLM_GTX_intersect extension.
  63. template<typename genType>
  64. GLM_FUNC_DECL bool intersectRaySphere(
  65. genType const& rayStarting, genType const& rayNormalizedDirection,
  66. genType const& sphereCenter, const typename genType::value_type sphereRadius,
  67. genType & intersectionPosition, genType & intersectionNormal);
  68. //! Compute the intersection of a line and a sphere.
  69. //! From GLM_GTX_intersect extension
  70. template<typename genType>
  71. GLM_FUNC_DECL bool intersectLineSphere(
  72. genType const& point0, genType const& point1,
  73. genType const& sphereCenter, typename genType::value_type sphereRadius,
  74. genType & intersectionPosition1, genType & intersectionNormal1,
  75. genType & intersectionPosition2 = genType(), genType & intersectionNormal2 = genType());
  76. /// @}
  77. }//namespace glm
  78. #include "intersect.inl"