intersect.hpp 3.3 KB

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