I'm not sure what you mean by ray tracing bullets, but I'll take a guess.
A,B are vectors for the starting point of the bullet and ending point, respectively. This forms a line segment which you then use to check for collision. Test the line against all polys in each object using a ray-plane intersection. If the line intersects the plane that a poly lies in, then check that intersection point against the actual boundaries of the triangle. This can be done simply by projected the triangle and the point onto the axis of the plane's normal with the largest component, thus turning the problem from 3D into 2D. At that point you can then just look up any point in a triangle algorithm.
let
T1,
T2,
T3 be the 3 points making up a poly
Subtract vectors to form 2 lines that lie in the plane, then normalize the cross product of the 2. This will give you the normal of the plane.
N = normalize((T2 - T1) * (T3 - T2))
Now form a ray representing the bullet, using A and B as defined above.
V = B - A
Assuming the vertices are in clockwise order, take the dot product of the plane's normal and the ray to check for which side of the plane we're on. If the result is less than 0, then we're facing the front of the plane and thus we should check it for collision. This simple check can greatly reduce the number of needed calculations.
(remember that a dot product of 2 vectors returns a single value)
if N.V <= 0 then check for collision
We form a ray from any point on the plane and the origin of the bullet ray.
R = T1 - A
Dot product again to form the parts of our quadratic equation.
num# = N.R
den# = N.V
Now get the time of intersection between the ray created from the bullet and the plane.
t# = num# / den#
Since a line can be infinite, so can our answer. To make sure the collision happens between the starting and ending point of our ray, t# must be between 0 and 1, inclusive.
If t# meets the above condition, then get the point of intersection.
I = V * t#
Use this point 'I' and the 3 points from earlier 'T1,T2,T3' to do the triangle check. If that returns true, then the bullet has in fact collided with the object at this point.
But you're not done yet. Store the value of
t# and perform the collision checks all over again. You need to check every poly in every object, because more than 1 collision is possible. The first collision, the one you want to respond to, is the collision which has the smallest value of
t#
I hope this helped you.