OBB-to-plane
Just like with the AABB, we know that an OBB does not intersect a plane if all of the OBB vertices are on the same side of the plane. The actual test to check if an OBB and plane intersect will be very similar to the AABB-to-Plane test:
Getting ready
We are going to implement a function to test if an OBB and a Plane intersect. This function will be similar to how we checked if an AABB and Plane intersected. We will project the OBB onto the normal of the plane and find the interval of this projection. If the interval contains the origin of the plane, we know we have an intersection.
How to do it…
Follow the given steps to find intersections between an OBB and a plane:
Declare
OBBPlane
inGeometry3D.h
:bool OBBPlane(const OBB&obb, const Plane& plane);
Dclare the
PlaneOBB
macro inGeometry3D.h
:#define PlaneOBB(plane, obb) \ OBBPlane(obb, plane)
Implement
OBBPlane
inGeometry3D.cpp
:bool OBBPlane(const OBB& obb, const Plane& plane) { // Local variables for readability...