Mesh operations
It's time to implement intersection tests for the mesh object. We want to test the mesh for intersection against all of the primitive shapes we have implemented. The only shapes that we will not test for intersection are points and other meshes.
Getting ready
We are about to implement seven new functions. These functions test for intersection between a mesh and a number of primitives. We will not be performing a mesh to mesh intersection test because it would require looping through the triangle list of each mesh in a nested fashion. This nested loop would become very expensive.
Because most of the functions we are about to implement look the exact same, I will list the full source of MeshRay
and MeshAABB
here. MeshAABB
will contain comments for copy/paste instructions to the rest of the functions being implemented.
How to do it…
Follow these steps to implement intersection tests against meshes:
- Declare all mesh operations in
Geometry3D.h
:float MeshRay(const Mesh&...