master
ブランチ master
VulkanExample / dep / include / glm / gtx / intersect.hpp
3.3 KB、90行 生 Blame 履歴
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
14#pragma once
15
16// Dependency:
17#include <cfloat>
18#include <limits>
19#include "../glm.hpp"
20#include "../geometric.hpp"
21#include "../gtx/closest_point.hpp"
22#include "../gtx/vector_query.hpp"
23
24#ifndef GLM_ENABLE_EXPERIMENTAL
25# 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."
26#elif GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
27# pragma message("GLM: GLM_GTX_closest_point extension included")
28#endif
29
30namespace glm
31{
32 /// @addtogroup gtx_intersect
33 /// @{
34
35 //! Compute the intersection of a ray and a plane.
36 //! Ray direction and plane normal must be unit length.
37 //! From GLM_GTX_intersect extension.
38 template<typename genType>
39 GLM_FUNC_DECL bool intersectRayPlane(
40 genType const& orig, genType const& dir,
41 genType const& planeOrig, genType const& planeNormal,
42 typename genType::value_type & intersectionDistance);
43
44 //! Compute the intersection of a ray and a triangle.
45 /// Based om Tomas Möller implementation http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/raytri/
46 //! From GLM_GTX_intersect extension.
47 template<typename T, qualifier Q>
48 GLM_FUNC_DECL bool intersectRayTriangle(
49 vec<3, T, Q> const& orig, vec<3, T, Q> const& dir,
50 vec<3, T, Q> const& v0, vec<3, T, Q> const& v1, vec<3, T, Q> const& v2,
51 vec<2, T, Q>& baryPosition, T& distance);
52
53 //! Compute the intersection of a line and a triangle.
54 //! From GLM_GTX_intersect extension.
55 template<typename genType>
56 GLM_FUNC_DECL bool intersectLineTriangle(
57 genType const& orig, genType const& dir,
58 genType const& vert0, genType const& vert1, genType const& vert2,
59 genType & position);
60
61 //! Compute the intersection distance of a ray and a sphere.
62 //! The ray direction vector is unit length.
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, typename genType::value_type const sphereRadiusSquared,
68 typename genType::value_type & intersectionDistance);
69
70 //! Compute the intersection of a ray and a sphere.
71 //! From GLM_GTX_intersect extension.
72 template<typename genType>
73 GLM_FUNC_DECL bool intersectRaySphere(
74 genType const& rayStarting, genType const& rayNormalizedDirection,
75 genType const& sphereCenter, const typename genType::value_type sphereRadius,
76 genType & intersectionPosition, genType & intersectionNormal);
77
78 //! Compute the intersection of a line and a sphere.
79 //! From GLM_GTX_intersect extension
80 template<typename genType>
81 GLM_FUNC_DECL bool intersectLineSphere(
82 genType const& point0, genType const& point1,
83 genType const& sphereCenter, typename genType::value_type sphereRadius,
84 genType & intersectionPosition1, genType & intersectionNormal1,
85 genType & intersectionPosition2 = genType(), genType & intersectionNormal2 = genType());
86
87 /// @}
88}//namespace glm
89
90#include "intersect.inl"