g-truc/glm — pull request #193 by tOgg1 (2014-04-27 08:49:19+00:00)
Title: IntersectRayQuad and IntersectLineQuad methods

Let me just preface this by saying thanks for all your great work on glm. It has been of immeasurable value to me (and many others).

I'm currently working on a project where I needed intersectRayQuad methods, and after implementing them I thought they might be of use to you (they may not be). So I rewrote them to conform to "glm's style", resulting in the below-code.

The intersectRay/LineQuad methods also calculates the bilinear coordinates of the intersection points. The fast version does not do this, and are noticeably faster.

I've also added, which may or may not be of interest to you, versions of all methods for degenerate quadrilaterals. They are slightly slower (and uglier), but the fast versions SHOULD still be slightly faster than two iterations of glm::intersectRay/LineTriangle (From my testing this difference became very large with O2/3, although I can't explain why).

I've also added some test code, showing that the results of intersectRay/LineTriangle and intersectRayLineDegenerateQuad conforms.

If any of this is of interest, and you want me to add some more test code (corroborating the validity of the intersectRayX methods) please say so.