|
 |
>> Wouldn't it be faster to just directly check the line against the
>> triangle?
>
> Honestly, I don't know. I'm not sure my code for the triangle-line check is
> very good. =)
>
> As far as I can tell, to check for an intersection between a triangle and a
> line segment, you need to check that one of the triangle's vertices is on an
> opposite side of the line from the other two, and then check that both of
> the line segment's endpoints are on opposite sides of at least one of the
> triangle's edges, or that both of them are inside the triangle.
>
> I did most of these checks with cross products, and then found I had some
> precision problems in some cases, and the code got more complicated when I
> tried to avoid them. Since intersections are rare, I figured a bounding
> check would be the easiest way to improve performance.
Er... yeah, that's not terribly good. ;-)
Do a quick google for "ray triangle intersection". There are several
methods for doing this kind of thing, some of them highly optimised.
Post a reply to this message
|
 |