Just a few questions regarding the following code :
( Im not entirly sure if actually allowed to post this code, so i apologise if im not )

int IntersectSegmentTriangle(Point p, Point q, Point a, Point b, Point c,
float &u, float &v, float &w, float &t)
{
Vector ab = b - a;
Vector ac = c - a;
Vector qp = p - q;
Vector n = Cross(ab, ac);
float d = Dot(qp, n);
if (d <= 0.0f) return 0;
Vector ap = p - a;
t = Dot(ap, n);
if (t < 0.0f) return 0;
if (t > d) return 0;
Vector e = Cross(qp, ap);
v = Dot(ac, e);
if (v < 0.0f || v > d) return 0;
w = -Dot(ab, e);
if (w < 0.0f || v + w > d) return 0;
float ood = 1.0f / d;
t *= ood;
v *= ood;
w *= ood;
u = 1.0f - v - w;
return 1;
}

Vector ap = p - a;
t = Dot(ap, n);
if (t < 0.0f) return 0;

Why does he get the vector from a triangle point to the ray origin? The only reason i can think of is for returning a false intersection if we are intersecting a reverse facing triangle, (back face culling). If so, surely its still an intersection whether its back facing or not. The comments say its a ray/plane test. But i dont see how it is. Im not really understanding the purpose of this test.

Vector e = Cross(qp, ap);
v = Dot(ac, e);
if (v < 0.0f || v > d) return 0;
w = -Dot(ab, e);
if (w < 0.0f || v + w > d) return 0;

Here, is he testing v and w against d due to the fact that they will be divided by d later on. So if they are more than d, then dividing them by d will result in a value more than 1.0f, which for barycentric coordinates, meaning the point is outside the triangle.