Here is some public domain (MIT license) code that I have developed:
Ray-Triangle Intersection
The article is here.
Developed with Ben Trumbore from Cornell University. The
source here together with some optimizations
and some
extra statistics for different CPUs.
Triangle-Triangle Overlap Test [Updated 2001-06-20]
The article is here.
I have optimized (in that I replaced the divisions
with some multiplications - from a suggestion by
Dave Eberly) that code since
then.
New (faster) code is
here. If you want the line of intersection as well, the get
this code.
Triangle-Box Overlap Test [Updated 2004-08-25]
The article is here. Old code is here. New, faster code is here. It's not noticably faster on a 1333 MHz PC,
but it's about 15% faster on a SUN 333MHz. Bug-fixed code This is the code you should get. It correctly
reports intersections for triangles completely in a box plane. Bug fix by Nick Pelling: thanks!