Support Forum       G3D Web Page     
Public Member Functions | List of all members
glsl::our_glsl Class Reference


Our ray-box intersection More...

Public Member Functions

bool ourHitAABox (vec3 boxCenter, vec3 boxRadius, vec3 rayOrigin, vec3 rayDirection, vec3 invRayDirection)
 
bool ourIntersectBox (Box box, Ray ray, out float distance, out vec3 normal, const in bool oriented, in vec3 _invRayDirection)
 
bool ourIntersectBoxCommon (Box box, Ray ray, out float distance, out vec3 normal, const bool rayCanStartInBox, const in bool oriented, in vec3 _invRayDirection)
 
bool ourOutsideHitAABox (vec3 boxCenter, vec3 boxRadius, vec3 rayOrigin, vec3 rayDirection, vec3 invRayDirection)
 
bool ourOutsideIntersectBox (Box box, Ray ray, out float distance, out vec3 normal, const in bool oriented, in vec3 _invRayDirection)
 

Detailed Description


Our ray-box intersection

Parameterized on three macros (can be const in bool GLSL, but that changes the signature of the function):

RAY_CAN_START_IN_BOX : You can avoid three operations if you know that the ray origin is outside of the box. That's true for scenes modeled from opaque objects.

In the general case of transparent objects (or two-sided boxes), you need to test for this case and flip the sense of the backface test when the ray is in the box. Note that if all that you care about is the intersection itself (e.g., you're doing BVH traversal without looking at the distance), then the answer is always "yes, the ray hits the box", since you're inside of it, and this isn't necessary.

If a distanceToPlane is negative, then the intersection is behind the ray origin and we want to ignore it. If a distance is positive, then we need to find the intersection point and see if the hit is in bounds. Because we're only considering front faces and boxes are convex, we don't have to see which intersection occurs first–any intersection with a face must be the only one.

Member Function Documentation

◆ ourHitAABox()

bool glsl::our_glsl::ourHitAABox ( vec3  boxCenter,
vec3  boxRadius,
vec3  rayOrigin,
vec3  rayDirection,
vec3  invRayDirection 
)
inline

◆ ourIntersectBox()

bool glsl::our_glsl::ourIntersectBox ( Box  box,
Ray  ray,
out float  distance,
out vec3  normal,
const in bool  oriented,
in vec3  _invRayDirection 
)
inline

◆ ourIntersectBoxCommon()

bool glsl::our_glsl::ourIntersectBoxCommon ( Box  box,
Ray  ray,
out float  distance,
out vec3  normal,
const bool  rayCanStartInBox,
const in bool  oriented,
in vec3  _invRayDirection 
)
inline

◆ ourOutsideHitAABox()

bool glsl::our_glsl::ourOutsideHitAABox ( vec3  boxCenter,
vec3  boxRadius,
vec3  rayOrigin,
vec3  rayDirection,
vec3  invRayDirection 
)
inline

◆ ourOutsideIntersectBox()

bool glsl::our_glsl::ourOutsideIntersectBox ( Box  box,
Ray  ray,
out float  distance,
out vec3  normal,
const in bool  oriented,
in vec3  _invRayDirection 
)
inline

documentation generated on Wed Nov 24 2021 08:02:04 using doxygen 1.8.15