MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / iBoxIsectRay

Function iBoxIsectRay

src/SB/Core/gc/iMath3.cpp:480–559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

478}
479
480void iBoxIsectRay(const xBox* b, const xRay3* r, xIsect* isx)
481{
482 xVec3 var_14, var_20;
483 F32 t_in, t_out;
484
485 if (!(r->flags & 0x400))
486 {
487 ((xRay3*)r)->min_t = 0.0f; // wait, that's illegal
488 }
489
490 if (!(r->flags & 0x800))
491 {
492 ((xRay3*)r)->max_t = 1.0f;
493 }
494
495 // non-matching: incorrect instruction order
496
497 t_in = -9.9999997e37f;
498 t_out = 9.9999997e37f;
499
500 var_14.x = b->upper.x - b->lower.x;
501 var_14.y = b->upper.y - b->lower.y;
502 var_14.z = b->upper.z - b->lower.z;
503
504 var_20.x = b->lower.x + b->upper.x;
505 var_20.y = b->lower.y + b->upper.y;
506
507 var_14.x *= 0.5f;
508 var_14.y *= 0.5f;
509 var_14.z *= 0.5f;
510
511 var_20.z = b->lower.z + b->upper.z;
512
513 var_20.x *= -0.5f;
514 var_20.y *= -0.5f;
515 var_20.z *= -0.5f;
516
517 var_20.x += r->origin.x;
518 var_20.y += r->origin.y;
519 var_20.z += r->origin.z;
520
521 if (ClipBox(&var_14, &var_20, &r->dir, &t_in, &t_out))
522 {
523 if (t_in < r->min_t)
524 {
525 if (t_out < r->min_t)
526 {
527 isx->dist = t_out;
528 isx->penned = 1.0f;
529 isx->contained = 1.0f;
530 }
531 else
532 {
533 isx->dist = t_out;
534 isx->penned = -1.0f;
535 isx->contained = -1.0f;
536 }
537 }

Callers 3

xRayHitsBoxFastFunction · 0.50
xBoundOBBIsectRayFunction · 0.50
xRayHitsBoundFunction · 0.50

Calls 1

ClipBoxFunction · 0.85

Tested by

no test coverage detected