MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / intersect

Function intersect

Source/3rdParty/bx/src/bounds.cpp:426–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424 }
425
426 bool intersect(const Ray& _ray, const Aabb& _aabb, Hit* _hit)
427 {
428 const Vec3 invDir = rcp(_ray.dir);
429 const Vec3 tmp0 = sub(_aabb.min, _ray.pos);
430 const Vec3 t0 = mul(tmp0, invDir);
431 const Vec3 tmp1 = sub(_aabb.max, _ray.pos);
432 const Vec3 t1 = mul(tmp1, invDir);
433
434 const Vec3 mn = min(t0, t1);
435 const Vec3 mx = max(t0, t1);
436
437 const float tmin = max(mn.x, mn.y, mn.z);
438 const float tmax = min(mx.x, mx.y, mx.z);
439
440 if (0.0f > tmax
441 || tmin > tmax)
442 {
443 return false;
444 }
445
446 if (NULL != _hit)
447 {
448 _hit->plane.normal.x = float( (t1.x == tmin) - (t0.x == tmin) );
449 _hit->plane.normal.y = float( (t1.y == tmin) - (t0.y == tmin) );
450 _hit->plane.normal.z = float( (t1.z == tmin) - (t0.z == tmin) );
451
452 _hit->plane.dist = tmin;
453 _hit->pos = getPointAt(_ray, tmin);
454 }
455
456 return true;
457 }
458
459 static constexpr Aabb kUnitAabb =
460 {

Callers 1

overlapFunction · 0.85

Calls 15

toAabbFunction · 0.85
mtxInverseFunction · 0.85
squareFunction · 0.85
isNearZeroFunction · 0.85
projectToAxisFunction · 0.85
absFunction · 0.70
sqrtFunction · 0.70
distanceFunction · 0.70
addFunction · 0.70
subFunction · 0.50
mulFunction · 0.50
minFunction · 0.50

Tested by

no test coverage detected