#define VectorNegate(a,b) ((b)[0]=-((a)[0]),(b)[1]=-((a)[1]),(b)[2]=-((a)[2]))
#define VectorSet(a,b,c,d) ((a)[0]=(b),(a)[1]=(c),(a)[2]=(d))
+#define Vector4Set(a,b,c,d,e) ((a)[0]=(b),(a)[1]=(c),(a)[2]=(d),(a)[3]=(e))
#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0)
#define DotProduct(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])
#define VectorSubtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])
// finally a comparison to determine if the light is infront of the triangle
// (the goal of this statement) we do not need to normalize the surface
// normal because both sides of the comparison use it, therefore they are
-// both multiplied the same amount... furthermore the subtract can be done
-// on the vectors, saving a little bit of math in the dotproducts
-#define PointInfrontOfTriangle(p,a,b,c) (((p)[0] - (a)[0]) * (((a)[1] - (b)[1]) * ((c)[2] - (b)[2]) - ((a)[2] - (b)[2]) * ((c)[1] - (b)[1])) + ((p)[1] - (a)[1]) * (((a)[2] - (b)[2]) * ((c)[0] - (b)[0]) - ((a)[0] - (b)[0]) * ((c)[2] - (b)[2])) + ((p)[2] - (a)[2]) * (((a)[0] - (b)[0]) * ((c)[1] - (b)[1]) - ((a)[1] - (b)[1]) * ((c)[0] - (b)[0])) > 0)
+// both multiplied the same amount... furthermore a subtract can be done on
+// the point to eliminate one dotproduct
+// this is ((p - a) * cross(a-b,c-b))
+#define PointInfrontOfTriangle(p,a,b,c) \
+( ((p)[0] - (a)[0]) * (((a)[1] - (b)[1]) * ((c)[2] - (b)[2]) - ((a)[2] - (b)[2]) * ((c)[1] - (b)[1])) \
++ ((p)[1] - (a)[1]) * (((a)[2] - (b)[2]) * ((c)[0] - (b)[0]) - ((a)[0] - (b)[0]) * ((c)[2] - (b)[2])) \
++ ((p)[2] - (a)[2]) * (((a)[0] - (b)[0]) * ((c)[1] - (b)[1]) - ((a)[1] - (b)[1]) * ((c)[0] - (b)[0])) > 0)
+
#if 0
// readable version, kept only for explanatory reasons
int PointInfrontOfTriangle(const float *p, const float *a, const float *b, const float *c)
VectorSubtract(c, b, dir1);
// we have two edge directions, we can calculate a third vector from
- // them, which is the direction of the surface normal (it's magnitude
+ // them, which is the direction of the surface normal (its magnitude
// is not 1 however)
CrossProduct(dir0, dir1, normal);
#define NUMVERTEXNORMALS 162
extern float m_bytenormals[NUMVERTEXNORMALS][3];
-qbyte NormalToByte(const vec3_t n);
-void ByteToNormal(qbyte num, vec3_t n);
+unsigned char NormalToByte(const vec3_t n);
+void ByteToNormal(unsigned char num, vec3_t n);
void R_ConcatRotations (const float in1[3*3], const float in2[3*3], float out[3*3]);
void R_ConcatTransforms (const float in1[3*4], const float in2[3*4], float out[3*4]);