I am finding the point where the ray becomes [radius distance] to the edge. There is a huge difference. Although finding the closest point on the edge to the ray will always detect collisions, if there is one, it will not give very good results when you want the point of contact.
For example, if the ray is moving into a triangle area 6 inches this frame and collides, the closest point on line to line method will report a collision, say at 3 inches. So the contact point is 3 inches after the start point. So now we change that 6 inches of movement this frame to 16 inches of movement this frame, but the exact same direction and starting point. The method will now report that contact was made after 4-5 inches of movement. So it will always report the correct yes/no answer, but the distance is off.
In a game, the point of contact is pretty important. The code you see at the top of this is 2-3 days old (err, I think). The pushed plane idea is all that remains of it in my current code. The new code finds the point where the ray end distance from the edge becomes radius.
Actually, I have learned something from this. If the ray starts inside of the pushed plane, two edges need to be checked. My assumption that another triangle would take care of it was incorrect. But the idea is very simple. When the starting point of the ray starts inside of the pushed plane, check the edges which are facing the opposite direction that the ray is moving. This could be a maximum of 2 edge checks, but sometimes could only be 1. Basically, look at the direction of the third vertex (the vertex that the edge is not connected to) from the center of the edge. If the ray is moving towards that direction to some degree, then it needs checked.
I'm holding on to my idea that the pushed plane intersection holds the first point of contact. I'm also still saying that only one edge needs checked when the ray intersects the pushed plane (starts outside of it). I have been testing this algo for 2 days straight. Mainly because I had a little trouble projecting a fixed path after collision. But the point is that out of all of the angles I've tried, this routine has never failed.
By the way, any suggestions on how to prevent several collisions in one frame and still allow "sliding"? I think I'm going to trap the sphere inside of every sliding plane that it creates. For example, if a sphere hits the ground, and slides into a wall, the wall will not only force the point back onto it's sliding plane, but the floor's as well. So on, so on. I haven't tested this out fully.
Thanks for all of the advice
edit:
Quote:
develops to :
Pos*N - N*A - r*N*N
I'm not really sure I know what vector * vector means at all. Is this a cross product? Dot product? I've seen it on math sites quite often, but I have no idea what operations are being performed.
[Edited by - Jiia on November 17, 2004 1:32:04 AM]