-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Game Physics Cookbook
By :
Any box in 3D space, OBB, or AABB has six sides. This means the normal of a Raycast against a box will be the normal of one of the six sides. When doing a Raycast against a Bounding Box, we find the point of impact the same way we did for a Raycast against a Sphere. The normal, however, will be the same as the normal of the side which the ray hit.
Several of our existing functions use Raycast against AABB or OBB internally. When we change the API, we must be careful to update every spot where these functions are used. We must update the Linetest functions and the MeshRay function. In this section we are going to rewrite the Raycast function for AABB and OBB.
Follow these steps to update the Raycast functions of boxes in a way that they provide additional useful data:
Raycast against both OBB and AABB in Geometry3D.h:bool Raycast(const AABB& aabb, const Ray& ray, RaycastResult* outResult); bool Raycast...