MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / intersectBox

Method intersectBox

Engine/source/environment/river.cpp:501–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499}
500
501bool RiverSegment::intersectBox( const Box3F &bounds ) const
502{
503 // This code copied from Frustum class.
504
505 Point3F maxPoint;
506 F32 maxDot;
507
508 // Note the planes are ordered left, right, near,
509 // far, top, bottom for getting early rejections
510 // from the typical horizontal scene.
511 for ( S32 i = 0; i < mPlaneCount; i++ )
512 {
513 // This is pretty much as optimal as you can
514 // get for a plane vs AABB test...
515 //
516 // 4 comparisons
517 // 3 multiplies
518 // 2 adds
519 // 1 negation
520 //
521 // It will early out as soon as it detects the
522 // bounds is outside one of the planes.
523
524 if ( mPlanes[i].x > 0 )
525 maxPoint.x = bounds.maxExtents.x;
526 else
527 maxPoint.x = bounds.minExtents.x;
528
529 if ( mPlanes[i].y > 0 )
530 maxPoint.y = bounds.maxExtents.y;
531 else
532 maxPoint.y = bounds.minExtents.y;
533
534 if ( mPlanes[i].z > 0 )
535 maxPoint.z = bounds.maxExtents.z;
536 else
537 maxPoint.z = bounds.minExtents.z;
538
539 maxDot = mDot( maxPoint, mPlanes[ i ] );
540
541 if ( maxDot <= -mPlanes[ i ].d )
542 return false;
543 }
544
545 return true;
546}
547
548bool RiverSegment::containsPoint( const Point3F &pnt ) const
549{

Callers 1

getWaterCoverageMethod · 0.45

Calls 1

mDotFunction · 0.50

Tested by

no test coverage detected