KiCad PCB EDA Suite
bbox_3d_ray.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015-2016 Mario Luzeiro <[email protected]>
5 * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
30#include "bbox_3d.h"
31#include "../ray.h"
32#include <wx/debug.h>
33
34// This BBOX Ray intersection test have the following credits:
35
36// "This source code accompanies the Journal of Graphics Tools paper:
37//
38// "Fast Ray / Axis-Aligned Bounding Box Overlap Tests using Ray Slopes"
39// by Martin Eisemann, Thorsten Grosch, Stefan Müller and Marcus Magnor
40// Computer Graphics Lab, TU Braunschweig, Germany and
41// University of Koblenz-Landau, Germany
42//
43// This source code is public domain, but please mention us if you use it."
44
45
46bool BBOX_3D::Intersect( const RAY& aRay, float* t ) const
47{
48 switch( aRay.m_Classification )
49 {
51 {
52 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y < m_min.y )
53 || ( aRay.m_Origin.z < m_min.z )
54 || ( aRay.jbyi * m_min.x - m_max.y + aRay.c_xy > 0 )
55 || ( aRay.ibyj * m_min.y - m_max.x + aRay.c_yx > 0 )
56 || ( aRay.jbyk * m_min.z - m_max.y + aRay.c_zy > 0 )
57 || ( aRay.kbyj * m_min.y - m_max.z + aRay.c_yz > 0 )
58 || ( aRay.kbyi * m_min.x - m_max.z + aRay.c_xz > 0 )
59 || ( aRay.ibyk * m_min.z - m_max.x + aRay.c_zx > 0 ) )
60 return false;
61
62 // compute the intersection distance
63
64 *t = ( m_max.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
65
66 float t1 = ( m_max.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
67
68 if( t1 > *t )
69 *t = t1;
70
71 float t2 = ( m_max.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
72
73 if( t2 > *t )
74 *t = t2;
75
76 return true;
77 }
78
80 {
81 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y < m_min.y )
82 || ( aRay.m_Origin.z > m_max.z )
83 || ( aRay.jbyi * m_min.x - m_max.y + aRay.c_xy > 0 )
84 || ( aRay.ibyj * m_min.y - m_max.x + aRay.c_yx > 0 )
85 || ( aRay.jbyk * m_max.z - m_max.y + aRay.c_zy > 0 )
86 || ( aRay.kbyj * m_min.y - m_min.z + aRay.c_yz < 0 )
87 || ( aRay.kbyi * m_min.x - m_min.z + aRay.c_xz < 0 )
88 || ( aRay.ibyk * m_max.z - m_max.x + aRay.c_zx > 0 ) )
89 return false;
90
91 *t = ( m_max.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
92
93 float t1 = ( m_max.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
94
95 if( t1 > *t )
96 *t = t1;
97
98 float t2 = ( m_min.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
99
100 if( t2 > *t )
101 *t = t2;
102
103 return true;
104 }
105
107 {
108 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y > m_max.y )
109 || ( aRay.m_Origin.z < m_min.z )
110 || ( aRay.jbyi * m_min.x - m_min.y + aRay.c_xy < 0 )
111 || ( aRay.ibyj * m_max.y - m_max.x + aRay.c_yx > 0 )
112 || ( aRay.jbyk * m_min.z - m_min.y + aRay.c_zy < 0 )
113 || ( aRay.kbyj * m_max.y - m_max.z + aRay.c_yz > 0 )
114 || ( aRay.kbyi * m_min.x - m_max.z + aRay.c_xz > 0 )
115 || ( aRay.ibyk * m_min.z - m_max.x + aRay.c_zx > 0 ) )
116 return false;
117
118 *t = ( m_max.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
119
120 float t1 = ( m_min.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
121
122 if( t1 > *t )
123 *t = t1;
124
125 float t2 = ( m_max.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
126
127 if( t2 > *t )
128 *t = t2;
129
130 return true;
131 }
132
134 {
135 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y > m_max.y )
136 || ( aRay.m_Origin.z > m_max.z )
137 || ( aRay.jbyi * m_min.x - m_min.y + aRay.c_xy < 0 )
138 || ( aRay.ibyj * m_max.y - m_max.x + aRay.c_yx > 0 )
139 || ( aRay.jbyk * m_max.z - m_min.y + aRay.c_zy < 0 )
140 || ( aRay.kbyj * m_max.y - m_min.z + aRay.c_yz < 0 )
141 || ( aRay.kbyi * m_min.x - m_min.z + aRay.c_xz < 0 )
142 || ( aRay.ibyk * m_max.z - m_max.x + aRay.c_zx > 0 ) )
143 return false;
144
145 *t = ( m_max.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
146
147 float t1 = ( m_min.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
148
149 if( t1 > *t )
150 *t = t1;
151
152 float t2 = ( m_min.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
153
154 if( t2 > *t )
155 *t = t2;
156
157 return true;
158 }
159
161 {
162 if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y )
163 || ( aRay.m_Origin.z < m_min.z )
164 || ( aRay.jbyi * m_max.x - m_max.y + aRay.c_xy > 0 )
165 || ( aRay.ibyj * m_min.y - m_min.x + aRay.c_yx < 0 )
166 || ( aRay.jbyk * m_min.z - m_max.y + aRay.c_zy > 0 )
167 || ( aRay.kbyj * m_min.y - m_max.z + aRay.c_yz > 0 )
168 || ( aRay.kbyi * m_max.x - m_max.z + aRay.c_xz > 0 )
169 || ( aRay.ibyk * m_min.z - m_min.x + aRay.c_zx < 0 ) )
170 return false;
171
172 *t = ( m_min.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
173
174 float t1 = ( m_max.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
175
176 if( t1 > *t )
177 *t = t1;
178
179 float t2 = ( m_max.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
180
181 if( t2 > *t )
182 *t = t2;
183
184 return true;
185 }
186
188 {
189 if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y )
190 || ( aRay.m_Origin.z > m_max.z )
191 || ( aRay.jbyi * m_max.x - m_max.y + aRay.c_xy > 0 )
192 || ( aRay.ibyj * m_min.y - m_min.x + aRay.c_yx < 0 )
193 || ( aRay.jbyk * m_max.z - m_max.y + aRay.c_zy > 0 )
194 || ( aRay.kbyj * m_min.y - m_min.z + aRay.c_yz < 0 )
195 || ( aRay.kbyi * m_max.x - m_min.z + aRay.c_xz < 0 )
196 || ( aRay.ibyk * m_max.z - m_min.x + aRay.c_zx < 0 ) )
197 return false;
198
199 *t = ( m_min.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
200
201 float t1 = ( m_max.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
202
203 if( t1 > *t )
204 *t = t1;
205
206 float t2 = ( m_min.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
207
208 if( t2 > *t )
209 *t = t2;
210
211 return true;
212 }
213
215 {
216 if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y > m_max.y )
217 || ( aRay.m_Origin.z < m_min.z )
218 || ( aRay.jbyi * m_max.x - m_min.y + aRay.c_xy < 0 )
219 || ( aRay.ibyj * m_max.y - m_min.x + aRay.c_yx < 0 )
220 || ( aRay.jbyk * m_min.z - m_min.y + aRay.c_zy < 0 )
221 || ( aRay.kbyj * m_max.y - m_max.z + aRay.c_yz > 0 )
222 || ( aRay.kbyi * m_max.x - m_max.z + aRay.c_xz > 0 )
223 || ( aRay.ibyk * m_min.z - m_min.x + aRay.c_zx < 0 ) )
224 return false;
225
226 *t = ( m_min.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
227
228 float t1 = ( m_min.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
229
230 if( t1 > *t )
231 *t = t1;
232
233 float t2 = ( m_max.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
234
235 if( t2 > *t )
236 *t = t2;
237
238 return true;
239 }
240
242 {
243 if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y > m_max.y )
244 || ( aRay.m_Origin.z > m_max.z )
245 || ( aRay.jbyi * m_max.x - m_min.y + aRay.c_xy < 0 )
246 || ( aRay.ibyj * m_max.y - m_min.x + aRay.c_yx < 0 )
247 || ( aRay.jbyk * m_max.z - m_min.y + aRay.c_zy < 0 )
248 || ( aRay.kbyj * m_max.y - m_min.z + aRay.c_yz < 0 )
249 || ( aRay.kbyi * m_max.x - m_min.z + aRay.c_xz < 0 )
250 || ( aRay.ibyk * m_max.z - m_min.x + aRay.c_zx < 0 ) )
251 return false;
252
253 *t = ( m_min.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
254
255 float t1 = ( m_min.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
256
257 if( t1 > *t )
258 *t = t1;
259
260 float t2 = ( m_min.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
261
262 if( t2 > *t )
263 *t = t2;
264
265 return true;
266 }
267
269 {
270 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x )
271 || ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.z < m_min.z )
272 || ( aRay.jbyk * m_min.z - m_max.y + aRay.c_zy > 0 )
273 || ( aRay.kbyj * m_min.y - m_max.z + aRay.c_yz > 0 ) )
274 return false;
275
276 *t = ( m_max.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
277
278 float t2 = ( m_max.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
279
280 if( t2 > *t )
281 *t = t2;
282
283 return true;
284 }
285
287 {
288 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x )
289 || ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.z > m_max.z )
290 || ( aRay.jbyk * m_max.z - m_max.y + aRay.c_zy > 0 )
291 || ( aRay.kbyj * m_min.y - m_min.z + aRay.c_yz < 0 ) )
292 return false;
293
294 *t = ( m_max.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
295
296 float t2 = ( m_min.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
297
298 if( t2 > *t )
299 *t = t2;
300
301 return true;
302 }
303
305 {
306 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x )
307 || ( aRay.m_Origin.y > m_max.y ) || ( aRay.m_Origin.z < m_min.z )
308 || ( aRay.jbyk * m_min.z - m_min.y + aRay.c_zy < 0 )
309 || ( aRay.kbyj * m_max.y - m_max.z + aRay.c_yz > 0 ) )
310 return false;
311
312 *t = ( m_min.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
313
314 float t2 = ( m_max.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
315
316 if( t2 > *t )
317 *t = t2;
318
319 return true;
320 }
321
323 {
324 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x )
325 || ( aRay.m_Origin.y > m_max.y ) || ( aRay.m_Origin.z > m_max.z )
326 || ( aRay.jbyk * m_max.z - m_min.y + aRay.c_zy < 0 )
327 || ( aRay.kbyj * m_max.y - m_min.z + aRay.c_yz < 0 ) )
328 return false;
329
330 *t = ( m_min.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
331
332 float t2 = ( m_min.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
333
334 if( t2 > *t )
335 *t = t2;
336
337 return true;
338 }
339
341 {
342 if( ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.y > m_max.y )
343 || ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.z < m_min.z )
344 || ( aRay.kbyi * m_min.x - m_max.z + aRay.c_xz > 0 )
345 || ( aRay.ibyk * m_min.z - m_max.x + aRay.c_zx > 0 ) )
346 return false;
347
348 *t = ( m_max.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
349
350 float t2 = ( m_max.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
351
352 if( t2 > *t )
353 *t = t2;
354
355 return true;
356 }
357
359 {
360 if( ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.y > m_max.y )
361 || ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.z > m_max.z )
362 || ( aRay.kbyi * m_min.x - m_min.z + aRay.c_xz < 0 )
363 || ( aRay.ibyk * m_max.z - m_max.x + aRay.c_zx > 0 ) )
364 return false;
365
366 *t = ( m_max.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
367
368 float t2 = ( m_min.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
369
370 if( t2 > *t )
371 *t = t2;
372
373 return true;
374 }
375
377 {
378 if( ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.y > m_max.y )
379 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.z < m_min.z )
380 || ( aRay.kbyi * m_max.x - m_max.z + aRay.c_xz > 0 )
381 || ( aRay.ibyk * m_min.z - m_min.x + aRay.c_zx < 0 ) )
382 return false;
383
384 *t = ( m_min.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
385
386 float t2 = ( m_max.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
387
388 if( t2 > *t )
389 *t = t2;
390
391 return true;
392 }
393
395 {
396 if( ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.y > m_max.y )
397 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.z > m_max.z )
398 || ( aRay.kbyi * m_max.x - m_min.z + aRay.c_xz < 0 )
399 || ( aRay.ibyk * m_max.z - m_min.x + aRay.c_zx < 0 ) )
400 return false;
401
402 *t = ( m_min.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
403
404 float t2 = ( m_min.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
405
406 if( t2 > *t )
407 *t = t2;
408
409 return true;
410 }
411
413 {
414 if( ( aRay.m_Origin.z < m_min.z ) || ( aRay.m_Origin.z > m_max.z )
415 || ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y < m_min.y )
416 || ( aRay.jbyi * m_min.x - m_max.y + aRay.c_xy > 0 )
417 || ( aRay.ibyj * m_min.y - m_max.x + aRay.c_yx > 0 ) )
418 return false;
419
420 *t = ( m_max.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
421
422 float t1 = ( m_max.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
423
424 if( t1 > *t )
425 *t = t1;
426
427 return true;
428 }
429
431 {
432 if( ( aRay.m_Origin.z < m_min.z ) || ( aRay.m_Origin.z > m_max.z )
433 || ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y > m_max.y )
434 || ( aRay.jbyi * m_min.x - m_min.y + aRay.c_xy < 0 )
435 || ( aRay.ibyj * m_max.y - m_max.x + aRay.c_yx > 0 ) )
436 return false;
437
438 *t = ( m_max.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
439
440 float t1 = ( m_min.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
441
442 if( t1 > *t )
443 *t = t1;
444
445 return true;
446 }
447
449 {
450 if( ( aRay.m_Origin.z < m_min.z ) || ( aRay.m_Origin.z > m_max.z )
451 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y )
452 || ( aRay.jbyi * m_max.x - m_max.y + aRay.c_xy > 0 )
453 || ( aRay.ibyj * m_min.y - m_min.x + aRay.c_yx < 0 ) )
454 return false;
455
456 *t = ( m_min.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
457
458 float t1 = ( m_max.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
459
460 if( t1 > *t )
461 *t = t1;
462
463 return true;
464 }
465
467 {
468 if( ( aRay.m_Origin.z < m_min.z ) || ( aRay.m_Origin.z > m_max.z )
469 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y > m_max.y )
470 || ( aRay.jbyi * m_max.x - m_min.y + aRay.c_xy < 0 )
471 || ( aRay.ibyj * m_max.y - m_min.x + aRay.c_yx < 0 ) )
472 return false;
473
474 *t = ( m_min.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
475
476 float t1 = ( m_min.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
477
478 if( t1 > *t )
479 *t = t1;
480
481 return true;
482 }
483
485 {
486 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y < m_min.y )
487 || ( aRay.m_Origin.y > m_max.y ) || ( aRay.m_Origin.z < m_min.z )
488 || ( aRay.m_Origin.z > m_max.z ) )
489 return false;
490
491 *t = ( m_max.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
492
493 return true;
494 }
495
497 {
498 if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y )
499 || ( aRay.m_Origin.y > m_max.y ) || ( aRay.m_Origin.z < m_min.z )
500 || ( aRay.m_Origin.z > m_max.z ) )
501 return false;
502
503 *t = ( m_min.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
504
505 return true;
506 }
507
509 {
510 if( ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.x < m_min.x )
511 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.z < m_min.z )
512 || ( aRay.m_Origin.z > m_max.z ) )
513 return false;
514
515 *t = ( m_max.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
516
517 return true;
518 }
519
521 {
522 if( ( aRay.m_Origin.y > m_max.y ) || ( aRay.m_Origin.x < m_min.x )
523 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.z < m_min.z )
524 || ( aRay.m_Origin.z > m_max.z ) )
525 return false;
526
527 *t = ( m_min.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
528
529 return true;
530 }
531
533 {
534 if( ( aRay.m_Origin.z < m_min.z ) || ( aRay.m_Origin.x < m_min.x )
535 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y )
536 || ( aRay.m_Origin.y > m_max.y ) )
537 return false;
538
539 *t = ( m_max.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
540
541 return true;
542 }
543
545 {
546 if( ( aRay.m_Origin.z > m_max.z ) || ( aRay.m_Origin.x < m_min.x )
547 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y )
548 || ( aRay.m_Origin.y > m_max.y ) )
549 return false;
550
551 *t = ( m_min.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
552
553 return true;
554 }
555 }
556
557 return false;
558}
559
560
561bool BBOX_3D::Intersect( const RAY& aRay ) const
562{
563 switch( aRay.m_Classification )
564 {
566 {
567 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y < m_min.y )
568 || ( aRay.m_Origin.z < m_min.z )
569 || ( aRay.jbyi * m_min.x - m_max.y + aRay.c_xy > 0 )
570 || ( aRay.ibyj * m_min.y - m_max.x + aRay.c_yx > 0 )
571 || ( aRay.jbyk * m_min.z - m_max.y + aRay.c_zy > 0 )
572 || ( aRay.kbyj * m_min.y - m_max.z + aRay.c_yz > 0 )
573 || ( aRay.kbyi * m_min.x - m_max.z + aRay.c_xz > 0 )
574 || ( aRay.ibyk * m_min.z - m_max.x + aRay.c_zx > 0 ) )
575 return false;
576
577 return true;
578 }
579
581 {
582 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y < m_min.y )
583 || ( aRay.m_Origin.z > m_max.z )
584 || ( aRay.jbyi * m_min.x - m_max.y + aRay.c_xy > 0 )
585 || ( aRay.ibyj * m_min.y - m_max.x + aRay.c_yx > 0 )
586 || ( aRay.jbyk * m_max.z - m_max.y + aRay.c_zy > 0 )
587 || ( aRay.kbyj * m_min.y - m_min.z + aRay.c_yz < 0 )
588 || ( aRay.kbyi * m_min.x - m_min.z + aRay.c_xz < 0 )
589 || ( aRay.ibyk * m_max.z - m_max.x + aRay.c_zx > 0 ) )
590 return false;
591
592 return true;
593 }
594
596 {
597 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y > m_max.y )
598 || ( aRay.m_Origin.z < m_min.z )
599 || ( aRay.jbyi * m_min.x - m_min.y + aRay.c_xy < 0 )
600 || ( aRay.ibyj * m_max.y - m_max.x + aRay.c_yx > 0 )
601 || ( aRay.jbyk * m_min.z - m_min.y + aRay.c_zy < 0 )
602 || ( aRay.kbyj * m_max.y - m_max.z + aRay.c_yz > 0 )
603 || ( aRay.kbyi * m_min.x - m_max.z + aRay.c_xz > 0 )
604 || ( aRay.ibyk * m_min.z - m_max.x + aRay.c_zx > 0 ) )
605 return false;
606
607 return true;
608 }
609
611 {
612 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y > m_max.y )
613 || ( aRay.m_Origin.z > m_max.z )
614 || ( aRay.jbyi * m_min.x - m_min.y + aRay.c_xy < 0 )
615 || ( aRay.ibyj * m_max.y - m_max.x + aRay.c_yx > 0 )
616 || ( aRay.jbyk * m_max.z - m_min.y + aRay.c_zy < 0 )
617 || ( aRay.kbyj * m_max.y - m_min.z + aRay.c_yz < 0 )
618 || ( aRay.kbyi * m_min.x - m_min.z + aRay.c_xz < 0 )
619 || ( aRay.ibyk * m_max.z - m_max.x + aRay.c_zx > 0 ) )
620 return false;
621
622 return true;
623 }
624
626 {
627 if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y )
628 || ( aRay.m_Origin.z < m_min.z )
629 || ( aRay.jbyi * m_max.x - m_max.y + aRay.c_xy > 0 )
630 || ( aRay.ibyj * m_min.y - m_min.x + aRay.c_yx < 0 )
631 || ( aRay.jbyk * m_min.z - m_max.y + aRay.c_zy > 0 )
632 || ( aRay.kbyj * m_min.y - m_max.z + aRay.c_yz > 0 )
633 || ( aRay.kbyi * m_max.x - m_max.z + aRay.c_xz > 0 )
634 || ( aRay.ibyk * m_min.z - m_min.x + aRay.c_zx < 0 ) )
635 return false;
636
637 return true;
638 }
639
640
642 {
643 if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y )
644 || ( aRay.m_Origin.z > m_max.z )
645 || ( aRay.jbyi * m_max.x - m_max.y + aRay.c_xy > 0 )
646 || ( aRay.ibyj * m_min.y - m_min.x + aRay.c_yx < 0 )
647 || ( aRay.jbyk * m_max.z - m_max.y + aRay.c_zy > 0 )
648 || ( aRay.kbyj * m_min.y - m_min.z + aRay.c_yz < 0 )
649 || ( aRay.kbyi * m_max.x - m_min.z + aRay.c_xz < 0 )
650 || ( aRay.ibyk * m_max.z - m_min.x + aRay.c_zx < 0 ) )
651 return false;
652
653 return true;
654 }
655
657 {
658 if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y > m_max.y )
659 || ( aRay.m_Origin.z < m_min.z )
660 || ( aRay.jbyi * m_max.x - m_min.y + aRay.c_xy < 0 )
661 || ( aRay.ibyj * m_max.y - m_min.x + aRay.c_yx < 0 )
662 || ( aRay.jbyk * m_min.z - m_min.y + aRay.c_zy < 0 )
663 || ( aRay.kbyj * m_max.y - m_max.z + aRay.c_yz > 0 )
664 || ( aRay.kbyi * m_max.x - m_max.z + aRay.c_xz > 0 )
665 || ( aRay.ibyk * m_min.z - m_min.x + aRay.c_zx < 0 ) )
666 return false;
667
668 return true;
669 }
670
672 {
673 if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y > m_max.y )
674 || ( aRay.m_Origin.z > m_max.z )
675 || ( aRay.jbyi * m_max.x - m_min.y + aRay.c_xy < 0 )
676 || ( aRay.ibyj * m_max.y - m_min.x + aRay.c_yx < 0 )
677 || ( aRay.jbyk * m_max.z - m_min.y + aRay.c_zy < 0 )
678 || ( aRay.kbyj * m_max.y - m_min.z + aRay.c_yz < 0 )
679 || ( aRay.kbyi * m_max.x - m_min.z + aRay.c_xz < 0 )
680 || ( aRay.ibyk * m_max.z - m_min.x + aRay.c_zx < 0 ) )
681 return false;
682
683 return true;
684 }
685
687 {
688 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x )
689 || ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.z < m_min.z )
690 || ( aRay.jbyk * m_min.z - m_max.y + aRay.c_zy > 0 )
691 || ( aRay.kbyj * m_min.y - m_max.z + aRay.c_yz > 0 ) )
692 return false;
693
694 return true;
695 }
696
698 {
699 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x )
700 || ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.z > m_max.z )
701 || ( aRay.jbyk * m_max.z - m_max.y + aRay.c_zy > 0 )
702 || ( aRay.kbyj * m_min.y - m_min.z + aRay.c_yz < 0 ) )
703 return false;
704
705 return true;
706 }
707
709 {
710 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x )
711 || ( aRay.m_Origin.y > m_max.y ) || ( aRay.m_Origin.z < m_min.z )
712 || ( aRay.jbyk * m_min.z - m_min.y + aRay.c_zy < 0 )
713 || ( aRay.kbyj * m_max.y - m_max.z + aRay.c_yz > 0 ) )
714 return false;
715
716 return true;
717 }
718
720 {
721 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x )
722 || ( aRay.m_Origin.y > m_max.y ) || ( aRay.m_Origin.z > m_max.z )
723 || ( aRay.jbyk * m_max.z - m_min.y + aRay.c_zy < 0 )
724 || ( aRay.kbyj * m_max.y - m_min.z + aRay.c_yz < 0 ) )
725 return false;
726
727 return true;
728 }
729
731 {
732 if( ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.y > m_max.y )
733 || ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.z < m_min.z )
734 || ( aRay.kbyi * m_min.x - m_max.z + aRay.c_xz > 0 )
735 || ( aRay.ibyk * m_min.z - m_max.x + aRay.c_zx > 0 ) )
736 return false;
737
738 return true;
739 }
740
742 {
743 if( ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.y > m_max.y )
744 || ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.z > m_max.z )
745 || ( aRay.kbyi * m_min.x - m_min.z + aRay.c_xz < 0 )
746 || ( aRay.ibyk * m_max.z - m_max.x + aRay.c_zx > 0 ) )
747 return false;
748
749 return true;
750 }
751
753 {
754 if( ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.y > m_max.y )
755 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.z < m_min.z )
756 || ( aRay.kbyi * m_max.x - m_max.z + aRay.c_xz > 0 )
757 || ( aRay.ibyk * m_min.z - m_min.x + aRay.c_zx < 0 ) )
758 return false;
759
760 return true;
761 }
762
764 {
765 if( ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.y > m_max.y )
766 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.z > m_max.z )
767 || ( aRay.kbyi * m_max.x - m_min.z + aRay.c_xz < 0 )
768 || ( aRay.ibyk * m_max.z - m_min.x + aRay.c_zx < 0 ) )
769 return false;
770
771 return true;
772 }
773
775 {
776 if( ( aRay.m_Origin.z < m_min.z ) || ( aRay.m_Origin.z > m_max.z )
777 || ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y < m_min.y )
778 || ( aRay.jbyi * m_min.x - m_max.y + aRay.c_xy > 0 )
779 || ( aRay.ibyj * m_min.y - m_max.x + aRay.c_yx > 0 ) )
780 return false;
781
782 return true;
783 }
784
786 {
787 if( ( aRay.m_Origin.z < m_min.z ) || ( aRay.m_Origin.z > m_max.z )
788 || ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y > m_max.y )
789 || ( aRay.jbyi * m_min.x - m_min.y + aRay.c_xy < 0 )
790 || ( aRay.ibyj * m_max.y - m_max.x + aRay.c_yx > 0 ) )
791 return false;
792
793 return true;
794 }
795
797 {
798 if( ( aRay.m_Origin.z < m_min.z ) || ( aRay.m_Origin.z > m_max.z )
799 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y )
800 || ( aRay.jbyi * m_max.x - m_max.y + aRay.c_xy > 0 )
801 || ( aRay.ibyj * m_min.y - m_min.x + aRay.c_yx < 0 ) )
802 return false;
803
804 return true;
805 }
806
808 {
809 if( ( aRay.m_Origin.z < m_min.z ) || ( aRay.m_Origin.z > m_max.z )
810 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y > m_max.y )
811 || ( aRay.jbyi * m_max.x - m_min.y + aRay.c_xy < 0 )
812 || ( aRay.ibyj * m_max.y - m_min.x + aRay.c_yx < 0 ) )
813 return false;
814
815 return true;
816 }
817
819 {
820 if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y < m_min.y )
821 || ( aRay.m_Origin.y > m_max.y ) || ( aRay.m_Origin.z < m_min.z )
822 || ( aRay.m_Origin.z > m_max.z ) )
823 return false;
824
825 return true;
826 }
827
829 {
830 if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y )
831 || ( aRay.m_Origin.y > m_max.y ) || ( aRay.m_Origin.z < m_min.z )
832 || ( aRay.m_Origin.z > m_max.z ) )
833 return false;
834
835 return true;
836 }
837
839 {
840 if( ( aRay.m_Origin.y < m_min.y ) || ( aRay.m_Origin.x < m_min.x )
841 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.z < m_min.z )
842 || ( aRay.m_Origin.z > m_max.z ) )
843 return false;
844
845 return true;
846 }
847
849 {
850 if( ( aRay.m_Origin.y > m_max.y ) || ( aRay.m_Origin.x < m_min.x )
851 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.z < m_min.z )
852 || ( aRay.m_Origin.z > m_max.z ) )
853 return false;
854
855 return true;
856 }
857
859 {
860 if( ( aRay.m_Origin.z < m_min.z ) || ( aRay.m_Origin.x < m_min.x )
861 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y )
862 || ( aRay.m_Origin.y > m_max.y ) )
863 return false;
864
865 return true;
866 }
867
869 {
870 if( ( aRay.m_Origin.z > m_max.z ) || ( aRay.m_Origin.x < m_min.x )
871 || ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y )
872 || ( aRay.m_Origin.y > m_max.y ) )
873 return false;
874
875 return true;
876 }
877 }
878
879 return false;
880}
Bounding Box class definition.
bool Intersect(const RAY &aRay, float *t) const
Definition: bbox_3d_ray.cpp:46
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: bbox_3d.h:228
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: bbox_3d.h:229
Definition: ray.h:63
float ibyj
Definition: ray.h:72
float c_zx
Definition: ray.h:73
float jbyk
Definition: ray.h:72
RAY_CLASSIFICATION m_Classification
Definition: ray.h:68
float jbyi
Definition: ray.h:72
float c_xz
Definition: ray.h:73
float c_xy
Definition: ray.h:73
float c_yz
Definition: ray.h:73
float kbyi
Definition: ray.h:72
SFVEC3F m_InvDir
Definition: ray.h:70
SFVEC3F m_Origin
Definition: ray.h:64
float ibyk
Definition: ray.h:72
float c_yx
Definition: ray.h:73
float c_zy
Definition: ray.h:73
float kbyj
Definition: ray.h:72