Linetest Oriented Bounding Box

Rays and Line segments are similar. The slab test for raycasting and the slap test to see if a Line and OBB intersect are almost the same. The only thing a linetest does different from a Raycast is it normalizes the result of the t value to the length of the line segment.

Because the two tests are so similar, we are going to build the linetest using the existing Raycast against the OBB function. Comparing the squared value of t against the squared length of the line segment is more efficient than normalizing t to the length of the Line.

Getting ready

We are going to implement a function to check if a Line segment and an OBB intersect. This function will return a Boolean result. The linetest function is going to build ...

Get Game Physics Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.