Archived

This topic is now archived and is closed to further replies.

tigra

faster ray-triangle intersect algorithm

Recommended Posts

tigra    124
did anyone can help me with subject? i need method which faster then moller''s and dont need to calculate u, v? i need it only for check is ray hit triangle - not need hit point.

Share this post


Link to post
Share on other sites
Trienco    2555
hm.. if it wouldnt need all that converting id have said try plücker coords for the triangle edges and a basic plane-distance for.. wait.. ray? then forget the plane intersection and just doing those 3 plücker-dot-products should let you know if the ray is passing inside all three edges if all signs are equal.

if you want to test whole models i wonder if it would work to store in a different way, ie. for each triangle store the three edges as plücker coords and the neighbouring triangle for each edge. with each check you should be able to traverse your models geometry in the right direction.

without knowing what mollers method is i assume its finding the intersection with the plane and doing the three dotproducts with each edges normal? with A being the starting point, N the plane normal and V the direction of A and C the intersection of ray and plane and Px the vertices of the triangle:

float s=N*V;
if (!s) return 0;
float d=N*(P0-A);
float t=d/s;
if (t<0) return 0;
C=A+V*t;

if (P0.normal*(C-P0)) return 0;
if (P1.normal*(C-P1)) return 0;
if (P2.normal*(C-P2)) return 0;
return 1;

without having the normals precalculated you get an additional (Py-Px)xN.

[edited by - Trienco on January 16, 2004 10:36:01 AM]

Share this post


Link to post
Share on other sites
Trienco    2555
in that case plücker coordinates might be worth a look. but if you find yourself with too many triangles to do it in realtime it always a good moment to use something more elegant than brute-forcing every triangle in the whole world. in other words: there might be much better places to start optimizing than the intersection test.

Share this post


Link to post
Share on other sites