1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
use crate::;
pub use *;
pub use *;
pub use *;
/// New type alias for [`sys::RTCRay`] that provides some convenience
/// methods.
///
/// The ray contains the origin ([`org_x`](`sys::RTCRay::org_x`),
/// [`org_y`](`sys::RTCRay::org_y`), [`org_z`](`sys::RTCRay::org_z`) members),
/// the direction vector ([`dir_x`](`sys::RTCRay::dir_x`),
/// [`dir_y`](`sys::RTCRay::dir_y`), [`dir_z`](`sys::RTCRay::dir_z`) members),
/// the ray segment ([`tnear`](`sys::RTCRay::tnear`) and
/// [`tfar`](`sys::RTCRay::tfar`) members). The ray direction does NOT need
/// to be normalized, and only the parameter range specified by
/// [`tnear`](`sys::RTCRay::tnear`) and [`tfar`](`sys::RTCRay::tfar`) is
/// considered valid.
///
/// The ray segment must be in the range \[0, \inf\], thus ranges start
/// behind the ray origin are not allowed, but ranges can reach to infinity.
/// For rays inside a ray stream, `tfar` < `tnear` identifies an *inactive*
/// ray.
///
/// Ray identifiers are used to identify rays inside a callback function,
/// event if the order of rays inside a ray packet or stream has changed.
///
/// [`packet`](`crate::ray::packet`) defines types in SOA (structure of array)
/// layout for ray packets of size 4 ([`Ray4`]), size 8 ([`Ray8`]),
/// and size 16 ([`Ray16`]).
///
/// See [`sys::RTCRay`] for more details.
pub type Ray = RTCRay;
/// New type alias for [`sys::RTCHit`] that provides some convenience
/// methods.
///
/// [`Hit`] defines the type of a ray/primitive intersection result. The
/// hit contains the un-normalized geometric normal in object space at the
/// hit location ([`Ng_x`]([`sys::RTCHit::Ng_x`]),
/// [`Ng_y`]([`sys::RTCHit::Ng_y`]), [`Ng_z`]([`sys::RTCHit::Ng_z`]) members),
/// the barycentric u/v coordinates of the hit ([`u`]([`sys::RTCHit::u`]) and
/// [`v`]([`sys::RTCHit::v`]) members), as well as the primitive ID
/// ([`primID`]([`sys::RTCHit::primID`]) member), geometry ID
/// (`geomID`, [`sys::RTCHit::geomID`] member), and instance ID
/// stack (`instID`, [`sys::RTCHit::instID`] member) of the hit.
/// The parametric intersection distance is not stored inside the hit,
/// but stored inside the `tfar`([`sys::RTCRay::tfar`]) member of the ray.
///
/// # Triangle UV convention
///
/// For a triangle with vertices `p0`, `p1`, `p2` (in index-buffer order), `u`
/// and `v` are barycentric coordinates that reconstruct the hit point as
///
/// ```text
/// P = (1 - u - v) * p0 + u * p1 + v * p2
/// ```
///
/// so `u` is the weight of `p1`, `v` the weight of `p2`, and `1 - u - v` the
/// weight of `p0`. Hence `(u, v) = (0, 0)` is `p0`, `(1, 0)` is `p1`, and
/// `(0, 1)` is `p2`, and `u + v <= 1` inside the triangle. The same `(u, v)`
/// interpolate any per-vertex attribute through
/// [`Geometry::interpolate`](crate::Geometry::interpolate). Other geometry
/// types (quads, subdivision surfaces, curves) define their own `u`/`v`
/// parametrization.
///
/// There exists structures in SOA (structure of array) layout for hit packets
/// of size 4 ([`Hit4`]), size 8 ([`Hit8`]), and size 16 ([`Hit16`]).
///
/// See [`sys::RTCHit`] for more details.
pub type Hit = RTCHit;
/// New type alias for [`sys::RTCRayHit`] that provides some convenience
/// methods.
///
/// A combined single ray/hit structure. This structure is used as input
/// for the `intersect-type` functions and stores the ray to intersect
/// and some hit fields that hold the intersection result afterwards.
///
/// [`packet`](`crate::ray::packet`) defines types in SOA (structure of array)
/// layout for ray/hit packets of size 4 [`RayHit4`], size 8 [`RayHit8`], and
/// size 16 [`RayHit16`].
///
/// See [`sys::RTCRayHit`] for more details.
pub type RayHit = RTCRayHit;