Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Ray-triangle collision gives very accurate collision detection in games. Depending on the return value of the distance from the ray start position to the triangle, it is easy for you to decide whether a collision occurs. As you might know, all the models in 3D games are made of triangles, whether static or dynamic. The ray is like a bullet fired from a gun; here, you can consider the gun as another object, with a straight thin rope behind. Once the bullet hits the triangle an object, the collision happens. A lot of methods on ray-triangle are available; in this recipe, you will learn how to implement the method which has the best time and space complexity to make your game run faster with less memory usage.
The ray-triangle collision detection method provides more accurate data than other methods using BoundingBox or BoundingSphere. Before the best ray-triangle collision detection method was invented by Moller and Trumbore, most of the existing methods first compute the intersection point between the ray and the triangle's plane. After that, the intersection point will be projected to the axis-aligned plane to determine whether it is inside the 2D projected triangle. These kinds of methods need the plain equation of triangle based on the computed normal every frame, for a triangle mesh; to do this will cost considerable memory space and CPU resources. However, the method from Moller and Trumbore requires only two cross product computations and also gives us an intersection point.