TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
G3D::Intersect Class Reference

#include <Intersect.h>

Static Public Member Functions

static bool __fastcall rayAABox (const Ray &ray, const AABox &box)
 Returns true if the intersection of the ray and the solid box is non-empty. More...
 
static bool __fastcall rayAABox (const Ray &ray, const AABox &box, float &time)
 Returns true if the intersection of the ray and the solid box is non-empty. More...
 

Detailed Description

Member Function Documentation

bool __fastcall G3D::Intersect::rayAABox ( const Ray ray,
const AABox box 
)
static

Returns true if the intersection of the ray and the solid box is non-empty.

[Fast] Ray / Axis-Aligned Bounding Box Overlap Tests using Ray Slopes" by Martin Eisemann, Thorsten Grosch, Stefan M�ller and Marcus Magnor Computer Graphics Lab, TU Braunschweig, Germany and University of Koblenz-Landau, Germany

28  {
29  switch (ray.classification) {
30  case Ray::MMM:
31 
32  if ((ray.m_origin.x < box.lo.x) || (ray.m_origin.y < box.lo.y) || (ray.m_origin.z < box.lo.z)
33  || (ray.jbyi * box.lo.x - box.hi.y + ray.c_xy > 0)
34  || (ray.ibyj * box.lo.y - box.hi.x + ray.c_yx > 0)
35  || (ray.jbyk * box.lo.z - box.hi.y + ray.c_zy > 0)
36  || (ray.kbyj * box.lo.y - box.hi.z + ray.c_yz > 0)
37  || (ray.kbyi * box.lo.x - box.hi.z + ray.c_xz > 0)
38  || (ray.ibyk * box.lo.z - box.hi.x + ray.c_zx > 0)
39  )
40  return false;
41  else
42  return true;
43 
44  case Ray::MMP:
45 
46  if ((ray.m_origin.x < box.lo.x) || (ray.m_origin.y < box.lo.y) || (ray.m_origin.z > box.hi.z)
47  || (ray.jbyi * box.lo.x - box.hi.y + ray.c_xy > 0)
48  || (ray.ibyj * box.lo.y - box.hi.x + ray.c_yx > 0)
49  || (ray.jbyk * box.hi.z - box.hi.y + ray.c_zy > 0)
50  || (ray.kbyj * box.lo.y - box.lo.z + ray.c_yz < 0)
51  || (ray.kbyi * box.lo.x - box.lo.z + ray.c_xz < 0)
52  || (ray.ibyk * box.hi.z - box.hi.x + ray.c_zx > 0)
53  )
54  return false;
55  else
56  return true;
57 
58  case Ray::MPM:
59 
60  if ((ray.m_origin.x < box.lo.x) || (ray.m_origin.y > box.hi.y) || (ray.m_origin.z < box.lo.z)
61  || (ray.jbyi * box.lo.x - box.lo.y + ray.c_xy < 0)
62  || (ray.ibyj * box.hi.y - box.hi.x + ray.c_yx > 0)
63  || (ray.jbyk * box.lo.z - box.lo.y + ray.c_zy < 0)
64  || (ray.kbyj * box.hi.y - box.hi.z + ray.c_yz > 0)
65  || (ray.kbyi * box.lo.x - box.hi.z + ray.c_xz > 0)
66  || (ray.ibyk * box.lo.z - box.hi.x + ray.c_zx > 0)
67  )
68  return false;
69  else
70  return true;
71 
72  case Ray::MPP:
73 
74  if ((ray.m_origin.x < box.lo.x) || (ray.m_origin.y > box.hi.y) || (ray.m_origin.z > box.hi.z)
75  || (ray.jbyi * box.lo.x - box.lo.y + ray.c_xy < 0)
76  || (ray.ibyj * box.hi.y - box.hi.x + ray.c_yx > 0)
77  || (ray.jbyk * box.hi.z - box.lo.y + ray.c_zy < 0)
78  || (ray.kbyj * box.hi.y - box.lo.z + ray.c_yz < 0)
79  || (ray.kbyi * box.lo.x - box.lo.z + ray.c_xz < 0)
80  || (ray.ibyk * box.hi.z - box.hi.x + ray.c_zx > 0)
81  )
82  return false;
83  else
84  return true;
85 
86  case Ray::PMM:
87 
88  if ((ray.m_origin.x > box.hi.x) || (ray.m_origin.y < box.lo.y) || (ray.m_origin.z < box.lo.z)
89  || (ray.jbyi * box.hi.x - box.hi.y + ray.c_xy > 0)
90  || (ray.ibyj * box.lo.y - box.lo.x + ray.c_yx < 0)
91  || (ray.jbyk * box.lo.z - box.hi.y + ray.c_zy > 0)
92  || (ray.kbyj * box.lo.y - box.hi.z + ray.c_yz > 0)
93  || (ray.kbyi * box.hi.x - box.hi.z + ray.c_xz > 0)
94  || (ray.ibyk * box.lo.z - box.lo.x + ray.c_zx < 0)
95  )
96  return false;
97  else
98  return true;
99 
100  case Ray::PMP:
101 
102  if ((ray.m_origin.x > box.hi.x) || (ray.m_origin.y < box.lo.y) || (ray.m_origin.z > box.hi.z)
103  || (ray.jbyi * box.hi.x - box.hi.y + ray.c_xy > 0)
104  || (ray.ibyj * box.lo.y - box.lo.x + ray.c_yx < 0)
105  || (ray.jbyk * box.hi.z - box.hi.y + ray.c_zy > 0)
106  || (ray.kbyj * box.lo.y - box.lo.z + ray.c_yz < 0)
107  || (ray.kbyi * box.hi.x - box.lo.z + ray.c_xz < 0)
108  || (ray.ibyk * box.hi.z - box.lo.x + ray.c_zx < 0)
109  )
110  return false;
111  else
112  return true;
113 
114  case Ray::PPM:
115 
116  if ((ray.m_origin.x > box.hi.x) || (ray.m_origin.y > box.hi.y) || (ray.m_origin.z < box.lo.z)
117  || (ray.jbyi * box.hi.x - box.lo.y + ray.c_xy < 0)
118  || (ray.ibyj * box.hi.y - box.lo.x + ray.c_yx < 0)
119  || (ray.jbyk * box.lo.z - box.lo.y + ray.c_zy < 0)
120  || (ray.kbyj * box.hi.y - box.hi.z + ray.c_yz > 0)
121  || (ray.kbyi * box.hi.x - box.hi.z + ray.c_xz > 0)
122  || (ray.ibyk * box.lo.z - box.lo.x + ray.c_zx < 0)
123  )
124  return false;
125  else
126  return true;
127 
128  case Ray::PPP:
129 
130  if ((ray.m_origin.x > box.hi.x) || (ray.m_origin.y > box.hi.y) || (ray.m_origin.z > box.hi.z)
131  || (ray.jbyi * box.hi.x - box.lo.y + ray.c_xy < 0)
132  || (ray.ibyj * box.hi.y - box.lo.x + ray.c_yx < 0)
133  || (ray.jbyk * box.hi.z - box.lo.y + ray.c_zy < 0)
134  || (ray.kbyj * box.hi.y - box.lo.z + ray.c_yz < 0)
135  || (ray.kbyi * box.hi.x - box.lo.z + ray.c_xz < 0)
136  || (ray.ibyk * box.hi.z - box.lo.x + ray.c_zx < 0)) {
137  return false;
138  } else
139  return true;
140 
141  case Ray::OMM:
142 
143  if((ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
144  || (ray.m_origin.y < box.lo.y) || (ray.m_origin.z < box.lo.z)
145  || (ray.jbyk * box.lo.z - box.hi.y + ray.c_zy > 0)
146  || (ray.kbyj * box.lo.y - box.hi.z + ray.c_yz > 0)
147  )
148  return false;
149  else
150  return true;
151 
152  case Ray::OMP:
153 
154  if((ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
155  || (ray.m_origin.y < box.lo.y) || (ray.m_origin.z > box.hi.z)
156  || (ray.jbyk * box.hi.z - box.hi.y + ray.c_zy > 0)
157  || (ray.kbyj * box.lo.y - box.lo.z + ray.c_yz < 0)
158  )
159  return false;
160  else
161  return true;
162 
163  case Ray::OPM:
164 
165  if((ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
166  || (ray.m_origin.y > box.hi.y) || (ray.m_origin.z < box.lo.z)
167  || (ray.jbyk * box.lo.z - box.lo.y + ray.c_zy < 0)
168  || (ray.kbyj * box.hi.y - box.hi.z + ray.c_yz > 0)
169  )
170  return false;
171  else
172  return true;
173 
174  case Ray::OPP:
175 
176  if((ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
177  || (ray.m_origin.y > box.hi.y) || (ray.m_origin.z > box.hi.z)
178  || (ray.jbyk * box.hi.z - box.lo.y + ray.c_zy < 0)
179  || (ray.kbyj * box.hi.y - box.lo.z + ray.c_yz < 0)
180  )
181  return false;
182  else
183  return true;
184 
185  case Ray::MOM:
186 
187  if((ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
188  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.z < box.lo.z)
189  || (ray.kbyi * box.lo.x - box.hi.z + ray.c_xz > 0)
190  || (ray.ibyk * box.lo.z - box.hi.x + ray.c_zx > 0)
191  )
192  return false;
193  else
194  return true;
195 
196  case Ray::MOP:
197 
198  if((ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
199  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.z > box.hi.z)
200  || (ray.kbyi * box.lo.x - box.lo.z + ray.c_xz < 0)
201  || (ray.ibyk * box.hi.z - box.hi.x + ray.c_zx > 0)
202  )
203  return false;
204  else
205  return true;
206 
207  case Ray::POM:
208 
209  if((ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
210  || (ray.m_origin.x > box.hi.x) || (ray.m_origin.z < box.lo.z)
211  || (ray.kbyi * box.hi.x - box.hi.z + ray.c_xz > 0)
212  || (ray.ibyk * box.lo.z - box.lo.x + ray.c_zx < 0)
213  )
214  return false;
215  else
216  return true;
217 
218  case Ray::POP:
219 
220  if((ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
221  || (ray.m_origin.x > box.hi.x) || (ray.m_origin.z > box.hi.z)
222  || (ray.kbyi * box.hi.x - box.lo.z + ray.c_xz < 0)
223  || (ray.ibyk * box.hi.z - box.lo.x + ray.c_zx < 0)
224  )
225  return false;
226  else
227  return true;
228 
229  case Ray::MMO:
230 
231  if((ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)
232  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.y < box.lo.y)
233  || (ray.jbyi * box.lo.x - box.hi.y + ray.c_xy > 0)
234  || (ray.ibyj * box.lo.y - box.hi.x + ray.c_yx > 0)
235  )
236  return false;
237  else
238  return true;
239 
240  case Ray::MPO:
241 
242  if((ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)
243  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.y > box.hi.y)
244  || (ray.jbyi * box.lo.x - box.lo.y + ray.c_xy < 0)
245  || (ray.ibyj * box.hi.y - box.hi.x + ray.c_yx > 0)
246  )
247  return false;
248  else
249  return true;
250 
251  case Ray::PMO:
252 
253  if((ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)
254  || (ray.m_origin.x > box.hi.x) || (ray.m_origin.y < box.lo.y)
255  || (ray.jbyi * box.hi.x - box.hi.y + ray.c_xy > 0)
256  || (ray.ibyj * box.lo.y - box.lo.x + ray.c_yx < 0)
257  )
258  return false;
259  else
260  return true;
261 
262  case Ray::PPO:
263 
264  if((ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)
265  || (ray.m_origin.x > box.hi.x) || (ray.m_origin.y > box.hi.y)
266  || (ray.jbyi * box.hi.x - box.lo.y + ray.c_xy < 0)
267  || (ray.ibyj * box.hi.y - box.lo.x + ray.c_yx < 0)
268  )
269  return false;
270  else
271  return true;
272 
273  case Ray::MOO:
274 
275  if((ray.m_origin.x < box.lo.x)
276  || (ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
277  || (ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)
278  )
279  return false;
280  else
281  return true;
282 
283  case Ray::POO:
284 
285  if((ray.m_origin.x > box.hi.x)
286  || (ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
287  || (ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)
288  )
289  return false;
290  else
291  return true;
292 
293  case Ray::OMO:
294 
295  if((ray.m_origin.y < box.lo.y)
296  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
297  || (ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)
298  )
299  return false;
300  else
301  return true;
302 
303  case Ray::OPO:
304 
305  if((ray.m_origin.y > box.hi.y)
306  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
307  || (ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)
308  )
309  return false;
310  else
311  return true;
312 
313  case Ray::OOM:
314 
315  if((ray.m_origin.z < box.lo.z)
316  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
317  || (ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
318  )
319  return false;
320  else
321  return true;
322 
323  case Ray::OOP:
324 
325  if((ray.m_origin.z > box.hi.z)
326  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
327  || (ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
328  )
329  return false;
330  else
331  return true;
332 
333  }
334 
335  return false;
336 }
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
bool __fastcall G3D::Intersect::rayAABox ( const Ray ray,
const AABox box,
float &  time 
)
static

Returns true if the intersection of the ray and the solid box is non-empty.

Parameters
timeIf there is an intersection, set to the time to that intersection. If the ray origin is inside the box, this is a negative value indicating the distance backwards from the ray origin to the first intersection. time is not set if there is no intersection.

[Slope-Mul] method from "Fast Ray / Axis-Aligned Bounding Box Overlap Tests using Ray Slopes" by Martin Eisemann, Thorsten Grosch, Stefan M�ller and Marcus Magnor Computer Graphics Lab, TU Braunschweig, Germany and University of Koblenz-Landau, Germany

339  {
340 
341  switch (ray.classification) {
342  case Ray::MMM:
343  {
344  if ((ray.m_origin.x < box.lo.x) || (ray.m_origin.y < box.lo.y) || (ray.m_origin.z < box.lo.z)
345  || (ray.jbyi * box.lo.x - box.hi.y + ray.c_xy > 0)
346  || (ray.ibyj * box.lo.y - box.hi.x + ray.c_yx > 0)
347  || (ray.jbyk * box.lo.z - box.hi.y + ray.c_zy > 0)
348  || (ray.kbyj * box.lo.y - box.hi.z + ray.c_yz > 0)
349  || (ray.kbyi * box.lo.x - box.hi.z + ray.c_xz > 0)
350  || (ray.ibyk * box.lo.z - box.hi.x + ray.c_zx > 0)) {
351  return false;
352  }
353 
354  // compute the intersection distance
355 
356  time = (box.hi.x - ray.m_origin.x) * ray.m_invDirection.x;
357  float t1 = (box.hi.y - ray.m_origin.y) * ray.m_invDirection.y;
358  if (t1 > time) {
359  time = t1;
360  }
361 
362  float t2 = (box.hi.z - ray.m_origin.z) * ray.m_invDirection.z;
363  if (t2 > time) {
364  time = t2;
365  }
366 
367  return true;
368  }
369 
370  case Ray::MMP:
371  {
372  if ((ray.m_origin.x < box.lo.x) || (ray.m_origin.y < box.lo.y) || (ray.m_origin.z > box.hi.z)
373  || (ray.jbyi * box.lo.x - box.hi.y + ray.c_xy > 0)
374  || (ray.ibyj * box.lo.y - box.hi.x + ray.c_yx > 0)
375  || (ray.jbyk * box.hi.z - box.hi.y + ray.c_zy > 0)
376  || (ray.kbyj * box.lo.y - box.lo.z + ray.c_yz < 0)
377  || (ray.kbyi * box.lo.x - box.lo.z + ray.c_xz < 0)
378  || (ray.ibyk * box.hi.z - box.hi.x + ray.c_zx > 0)) {
379  return false;
380  }
381 
382  time = (box.hi.x - ray.m_origin.x) * ray.m_invDirection.x;
383  float t1 = (box.hi.y - ray.m_origin.y) * ray.m_invDirection.y;
384  if (t1 > time) {
385  time = t1;
386  }
387  float t2 = (box.lo.z - ray.m_origin.z) * ray.m_invDirection.z;
388  if (t2 > time) {
389  time = t2;
390  }
391 
392  return true;
393  }
394 
395  case Ray::MPM:
396  {
397  if ((ray.m_origin.x < box.lo.x) || (ray.m_origin.y > box.hi.y) || (ray.m_origin.z < box.lo.z)
398  || (ray.jbyi * box.lo.x - box.lo.y + ray.c_xy < 0)
399  || (ray.ibyj * box.hi.y - box.hi.x + ray.c_yx > 0)
400  || (ray.jbyk * box.lo.z - box.lo.y + ray.c_zy < 0)
401  || (ray.kbyj * box.hi.y - box.hi.z + ray.c_yz > 0)
402  || (ray.kbyi * box.lo.x - box.hi.z + ray.c_xz > 0)
403  || (ray.ibyk * box.lo.z - box.hi.x + ray.c_zx > 0)) {
404  return false;
405  }
406 
407  time = (box.hi.x - ray.m_origin.x) * ray.m_invDirection.x;
408  float t1 = (box.lo.y - ray.m_origin.y) * ray.m_invDirection.y;
409  if (t1 > time) {
410  time = t1;
411  }
412  float t2 = (box.hi.z - ray.m_origin.z) * ray.m_invDirection.z;
413  if (t2 > time) {
414  time = t2;
415  }
416 
417  return true;
418  }
419 
420  case Ray::MPP:
421  {
422  if ((ray.m_origin.x < box.lo.x) || (ray.m_origin.y > box.hi.y) || (ray.m_origin.z > box.hi.z)
423  || (ray.jbyi * box.lo.x - box.lo.y + ray.c_xy < 0)
424  || (ray.ibyj * box.hi.y - box.hi.x + ray.c_yx > 0)
425  || (ray.jbyk * box.hi.z - box.lo.y + ray.c_zy < 0)
426  || (ray.kbyj * box.hi.y - box.lo.z + ray.c_yz < 0)
427  || (ray.kbyi * box.lo.x - box.lo.z + ray.c_xz < 0)
428  || (ray.ibyk * box.hi.z - box.hi.x + ray.c_zx > 0)) {
429  return false;
430  }
431 
432  time = (box.hi.x - ray.m_origin.x) * ray.m_invDirection.x;
433  float t1 = (box.lo.y - ray.m_origin.y) * ray.m_invDirection.y;
434  if (t1 > time) {
435  time = t1;
436  }
437  float t2 = (box.lo.z - ray.m_origin.z) * ray.m_invDirection.z;
438  if (t2 > time) {
439  time = t2;
440  }
441 
442  return true;
443  }
444 
445  case Ray::PMM:
446  {
447  if ((ray.m_origin.x > box.hi.x) || (ray.m_origin.y < box.lo.y) || (ray.m_origin.z < box.lo.z)
448  || (ray.jbyi * box.hi.x - box.hi.y + ray.c_xy > 0)
449  || (ray.ibyj * box.lo.y - box.lo.x + ray.c_yx < 0)
450  || (ray.jbyk * box.lo.z - box.hi.y + ray.c_zy > 0)
451  || (ray.kbyj * box.lo.y - box.hi.z + ray.c_yz > 0)
452  || (ray.kbyi * box.hi.x - box.hi.z + ray.c_xz > 0)
453  || (ray.ibyk * box.lo.z - box.lo.x + ray.c_zx < 0)) {
454  return false;
455  }
456 
457  time = (box.lo.x - ray.m_origin.x) * ray.m_invDirection.x;
458  float t1 = (box.hi.y - ray.m_origin.y) * ray.m_invDirection.y;
459  if (t1 > time) {
460  time = t1;
461  }
462  float t2 = (box.hi.z - ray.m_origin.z) * ray.m_invDirection.z;
463  if (t2 > time) {
464  time = t2;
465  }
466 
467  return true;
468  }
469 
470 
471  case Ray::PMP:
472  {
473  if ((ray.m_origin.x > box.hi.x) || (ray.m_origin.y < box.lo.y) || (ray.m_origin.z > box.hi.z)
474  || (ray.jbyi * box.hi.x - box.hi.y + ray.c_xy > 0)
475  || (ray.ibyj * box.lo.y - box.lo.x + ray.c_yx < 0)
476  || (ray.jbyk * box.hi.z - box.hi.y + ray.c_zy > 0)
477  || (ray.kbyj * box.lo.y - box.lo.z + ray.c_yz < 0)
478  || (ray.kbyi * box.hi.x - box.lo.z + ray.c_xz < 0)
479  || (ray.ibyk * box.hi.z - box.lo.x + ray.c_zx < 0)) {
480  return false;
481  }
482 
483  time = (box.lo.x - ray.m_origin.x) * ray.m_invDirection.x;
484  float t1 = (box.hi.y - ray.m_origin.y) * ray.m_invDirection.y;
485  if (t1 > time) {
486  time = t1;
487  }
488  float t2 = (box.lo.z - ray.m_origin.z) * ray.m_invDirection.z;
489  if (t2 > time) {
490  time = t2;
491  }
492 
493  return true;
494  }
495 
496  case Ray::PPM:
497  {
498  if ((ray.m_origin.x > box.hi.x) || (ray.m_origin.y > box.hi.y) || (ray.m_origin.z < box.lo.z)
499  || (ray.jbyi * box.hi.x - box.lo.y + ray.c_xy < 0)
500  || (ray.ibyj * box.hi.y - box.lo.x + ray.c_yx < 0)
501  || (ray.jbyk * box.lo.z - box.lo.y + ray.c_zy < 0)
502  || (ray.kbyj * box.hi.y - box.hi.z + ray.c_yz > 0)
503  || (ray.kbyi * box.hi.x - box.hi.z + ray.c_xz > 0)
504  || (ray.ibyk * box.lo.z - box.lo.x + ray.c_zx < 0)) {
505  return false;
506  }
507 
508  time = (box.lo.x - ray.m_origin.x) * ray.m_invDirection.x;
509  float t1 = (box.lo.y - ray.m_origin.y) * ray.m_invDirection.y;
510  if (t1 > time) {
511  time = t1;
512  }
513  float t2 = (box.hi.z - ray.m_origin.z) * ray.m_invDirection.z;
514  if (t2 > time) {
515  time = t2;
516  }
517 
518  return true;
519  }
520 
521  case Ray::PPP:
522  {
523  if ((ray.m_origin.x > box.hi.x) || (ray.m_origin.y > box.hi.y) || (ray.m_origin.z > box.hi.z)
524  || (ray.jbyi * box.hi.x - box.lo.y + ray.c_xy < 0)
525  || (ray.ibyj * box.hi.y - box.lo.x + ray.c_yx < 0)
526  || (ray.jbyk * box.hi.z - box.lo.y + ray.c_zy < 0)
527  || (ray.kbyj * box.hi.y - box.lo.z + ray.c_yz < 0)
528  || (ray.kbyi * box.hi.x - box.lo.z + ray.c_xz < 0)
529  || (ray.ibyk * box.hi.z - box.lo.x + ray.c_zx < 0)) {
530  return false;
531  }
532 
533  time = (box.lo.x - ray.m_origin.x) * ray.m_invDirection.x;
534  float t1 = (box.lo.y - ray.m_origin.y) * ray.m_invDirection.y;
535  if (t1 > time) {
536  time = t1;
537  }
538  float t2 = (box.lo.z - ray.m_origin.z) * ray.m_invDirection.z;
539  if (t2 > time) {
540  time = t2;
541  }
542 
543  return true;
544  }
545 
546  case Ray::OMM:
547  {
548  if((ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
549  || (ray.m_origin.y < box.lo.y) || (ray.m_origin.z < box.lo.z)
550  || (ray.jbyk * box.lo.z - box.hi.y + ray.c_zy > 0)
551  || (ray.kbyj * box.lo.y - box.hi.z + ray.c_yz > 0)) {
552  return false;
553  }
554 
555  time = (box.hi.y - ray.m_origin.y) * ray.m_invDirection.y;
556  float t2 = (box.hi.z - ray.m_origin.z) * ray.m_invDirection.z;
557  if (t2 > time) {
558  time = t2;
559  }
560 
561  return true;
562  }
563 
564  case Ray::OMP:
565  {
566  if((ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
567  || (ray.m_origin.y < box.lo.y) || (ray.m_origin.z > box.hi.z)
568  || (ray.jbyk * box.hi.z - box.hi.y + ray.c_zy > 0)
569  || (ray.kbyj * box.lo.y - box.lo.z + ray.c_yz < 0)) {
570  return false;
571  }
572 
573  time = (box.hi.y - ray.m_origin.y) * ray.m_invDirection.y;
574  float t2 = (box.lo.z - ray.m_origin.z) * ray.m_invDirection.z;
575  if (t2 > time) {
576  time = t2;
577  }
578 
579  return true;
580  }
581 
582  case Ray::OPM:
583  {
584  if((ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
585  || (ray.m_origin.y > box.hi.y) || (ray.m_origin.z < box.lo.z)
586  || (ray.jbyk * box.lo.z - box.lo.y + ray.c_zy < 0)
587  || (ray.kbyj * box.hi.y - box.hi.z + ray.c_yz > 0)) {
588  return false;
589  }
590 
591  time = (box.lo.y - ray.m_origin.y) * ray.m_invDirection.y;
592  float t2 = (box.hi.z - ray.m_origin.z) * ray.m_invDirection.z;
593  if (t2 > time) {
594  time = t2;
595  }
596 
597  return true;
598  }
599 
600  case Ray::OPP:
601  {
602  if((ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
603  || (ray.m_origin.y > box.hi.y) || (ray.m_origin.z > box.hi.z)
604  || (ray.jbyk * box.hi.z - box.lo.y + ray.c_zy < 0)
605  || (ray.kbyj * box.hi.y - box.lo.z + ray.c_yz < 0)) {
606  return false;
607  }
608 
609  time = (box.lo.y - ray.m_origin.y) * ray.m_invDirection.y;
610  float t2 = (box.lo.z - ray.m_origin.z) * ray.m_invDirection.z;
611  if (t2 > time) {
612  time = t2;
613  }
614 
615  return true;
616  }
617 
618 
619  case Ray::MOM:
620  {
621  if((ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
622  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.z < box.lo.z)
623  || (ray.kbyi * box.lo.x - box.hi.z + ray.c_xz > 0)
624  || (ray.ibyk * box.lo.z - box.hi.x + ray.c_zx > 0)) {
625  return false;
626  }
627 
628  time = (box.hi.x - ray.m_origin.x) * ray.m_invDirection.x;
629  float t2 = (box.hi.z - ray.m_origin.z) * ray.m_invDirection.z;
630  if (t2 > time) {
631  time = t2;
632  }
633 
634  return true;
635  }
636 
637 
638  case Ray::MOP:
639  {
640  if((ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
641  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.z > box.hi.z)
642  || (ray.kbyi * box.lo.x - box.lo.z + ray.c_xz < 0)
643  || (ray.ibyk * box.hi.z - box.hi.x + ray.c_zx > 0)) {
644  return false;
645  }
646 
647  time = (box.hi.x - ray.m_origin.x) * ray.m_invDirection.x;
648  float t2 = (box.lo.z - ray.m_origin.z) * ray.m_invDirection.z;
649  if (t2 > time) {
650  time = t2;
651  }
652 
653  return true;
654  }
655 
656  case Ray::POM:
657  {
658  if((ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
659  || (ray.m_origin.x > box.hi.x) || (ray.m_origin.z < box.lo.z)
660  || (ray.kbyi * box.hi.x - box.hi.z + ray.c_xz > 0)
661  || (ray.ibyk * box.lo.z - box.lo.x + ray.c_zx < 0)) {
662  return false;
663  }
664 
665  time = (box.lo.x - ray.m_origin.x) * ray.m_invDirection.x;
666  float t2 = (box.hi.z - ray.m_origin.z) * ray.m_invDirection.z;
667  if (t2 > time) {
668  time = t2;
669  }
670 
671  return true;
672  }
673 
674 
675  case Ray::POP:
676  {
677  if((ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
678  || (ray.m_origin.x > box.hi.x) || (ray.m_origin.z > box.hi.z)
679  || (ray.kbyi * box.hi.x - box.lo.z + ray.c_xz < 0)
680  || (ray.ibyk * box.hi.z - box.lo.x + ray.c_zx < 0)) {
681  return false;
682  }
683 
684  time = (box.lo.x - ray.m_origin.x) * ray.m_invDirection.x;
685  float t2 = (box.lo.z - ray.m_origin.z) * ray.m_invDirection.z;
686  if (t2 > time) {
687  time = t2;
688  }
689 
690  return true;
691  }
692 
693  case Ray::MMO:
694  {
695  if((ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)
696  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.y < box.lo.y)
697  || (ray.jbyi * box.lo.x - box.hi.y + ray.c_xy > 0)
698  || (ray.ibyj * box.lo.y - box.hi.x + ray.c_yx > 0)) {
699  return false;
700  }
701 
702  time = (box.hi.x - ray.m_origin.x) * ray.m_invDirection.x;
703  float t1 = (box.hi.y - ray.m_origin.y) * ray.m_invDirection.y;
704  if (t1 > time) {
705  time = t1;
706  }
707 
708  return true;
709  }
710 
711  case Ray::MPO:
712  {
713  if((ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)
714  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.y > box.hi.y)
715  || (ray.jbyi * box.lo.x - box.lo.y + ray.c_xy < 0)
716  || (ray.ibyj * box.hi.y - box.hi.x + ray.c_yx > 0)) {
717  return false;
718  }
719 
720  time = (box.hi.x - ray.m_origin.x) * ray.m_invDirection.x;
721  float t1 = (box.lo.y - ray.m_origin.y) * ray.m_invDirection.y;
722  if (t1 > time) {
723  time = t1;
724  }
725 
726  return true;
727  }
728 
729 
730  case Ray::PMO:
731  {
732  if((ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)
733  || (ray.m_origin.x > box.hi.x) || (ray.m_origin.y < box.lo.y)
734  || (ray.jbyi * box.hi.x - box.hi.y + ray.c_xy > 0)
735  || (ray.ibyj * box.lo.y - box.lo.x + ray.c_yx < 0)) {
736  return false;
737  }
738 
739  time = (box.lo.x - ray.m_origin.x) * ray.m_invDirection.x;
740  float t1 = (box.hi.y - ray.m_origin.y) * ray.m_invDirection.y;
741  if (t1 > time) {
742  time = t1;
743  }
744 
745  return true;
746  }
747 
748  case Ray::PPO:
749  {
750  if((ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)
751  || (ray.m_origin.x > box.hi.x) || (ray.m_origin.y > box.hi.y)
752  || (ray.jbyi * box.hi.x - box.lo.y + ray.c_xy < 0)
753  || (ray.ibyj * box.hi.y - box.lo.x + ray.c_yx < 0)) {
754  return false;
755  }
756 
757  time = (box.lo.x - ray.m_origin.x) * ray.m_invDirection.x;
758  float t1 = (box.lo.y - ray.m_origin.y) * ray.m_invDirection.y;
759  if (t1 > time) {
760  time = t1;
761  }
762 
763  return true;
764  }
765 
766 
767  case Ray::MOO:
768  {
769  if((ray.m_origin.x < box.lo.x)
770  || (ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
771  || (ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)) {
772  return false;
773  }
774 
775  time = (box.hi.x - ray.m_origin.x) * ray.m_invDirection.x;
776  return true;
777  }
778 
779  case Ray::POO:
780  {
781  if ((ray.m_origin.x > box.hi.x)
782  || (ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)
783  || (ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)) {
784  return false;
785  }
786 
787  time = (box.lo.x - ray.m_origin.x) * ray.m_invDirection.x;
788  return true;
789  }
790 
791  case Ray::OMO:
792  {
793  if ((ray.m_origin.y < box.lo.y)
794  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
795  || (ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)) {
796  return false;
797  }
798 
799  time = (box.hi.y - ray.m_origin.y) * ray.m_invDirection.y;
800  return true;
801  }
802 
803  case Ray::OPO:
804  {
805  if ((ray.m_origin.y > box.hi.y)
806  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
807  || (ray.m_origin.z < box.lo.z) || (ray.m_origin.z > box.hi.z)) {
808  return false;
809  }
810 
811  time = (box.lo.y - ray.m_origin.y) * ray.m_invDirection.y;
812  return true;
813  }
814 
815 
816  case Ray::OOM:
817  {
818  if ((ray.m_origin.z < box.lo.z)
819  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
820  || (ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)) {
821  return false;
822  }
823 
824  time = (box.hi.z - ray.m_origin.z) * ray.m_invDirection.z;
825  return true;
826  }
827 
828  case Ray::OOP:
829  {
830  if ((ray.m_origin.z > box.hi.z)
831  || (ray.m_origin.x < box.lo.x) || (ray.m_origin.x > box.hi.x)
832  || (ray.m_origin.y < box.lo.y) || (ray.m_origin.y > box.hi.y)) {
833  return false;
834  }
835 
836  time = (box.lo.z - ray.m_origin.z) * ray.m_invDirection.z;
837  return true;
838  }
839  }
840 
841  return false;
842 }
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42
Definition: Ray.h:42

The documentation for this class was generated from the following files: