Ray Intersect Triangle / Ray Intersect Mesh added to code archives.

Blitz3D Forums/Blitz3D Programming/Ray Intersect Triangle / Ray Intersect Mesh added to code archives.

sswift(Posted 2003) [#1]
http://www.blitzbasic.com/codearcs/codearcs.php?code=793


The Ray_Intersect_Triangle function I have provided here provides functionality which even Blitz's own line intersect function does not.

It provides the ability to define a line segment instead of a ray just as you can with Blitz's line intersect function, but it also allows infinite rays, and it allows backface culling, so if you fire a ray from inside a mesh it will be as if the mesh does not exist. This is very useful for light map calculations, which is why I wrote it.

The Ray_Intersect_Mesh function is an extension of the Ray_Intersect_Triangle function. It behaves more like Blitz's line intersect function because it checks whole meshes rather than just a single triangle. It examines all triangles in all surfaces until it hits one and then it exits early.

This early out functionality should make it faster than Blitz's own lineintersect function. The drawback is that it does not tell you what the CLOSEST intersection was like Blitz's lineintersect function, but you could easily modify the Ray_Intersect_Mesh function to provide that capability.