2 #ifndef TRANSFORM_H
3 #define TRANSFORM_H
5 extern vec_t softwaretransform_rotatematrix[3][4];
6 extern vec_t softwaretransform_matrix[3][4];
7 extern vec_t softwaretransform_invmatrix[3][4];
8 extern int softwaretransform_complexity;
10 void softwaretransformidentity (void);
11 void softwaretransformset (vec3_t origin, vec3_t angles, vec_t scale);
12 void softwaretransformforentity (entity_render_t *r);
14 // #defines for speed reasons
15 #define softwaretransform(in, out)\
16 {\
17         if (softwaretransform_complexity == 0)\
18         {\
19                 VectorCopy(in, out);\
20         }\
21         else if (softwaretransform_complexity == 1)\
22         {\
23                 out[0] = in[0] + softwaretransform_matrix[0][3];\
24                 out[1] = in[1] + softwaretransform_matrix[1][3];\
25                 out[2] = in[2] + softwaretransform_matrix[2][3];\
26         }\
27         else\
28         {\
29                 out[0] = DotProduct(in, softwaretransform_matrix[0]) + softwaretransform_matrix[0][3];\
30                 out[1] = DotProduct(in, softwaretransform_matrix[1]) + softwaretransform_matrix[1][3];\
31                 out[2] = DotProduct(in, softwaretransform_matrix[2]) + softwaretransform_matrix[2][3];\
32         }\
33 }
35 #define softwaretransformdirection(in, out)\
36 {\
37         if (softwaretransform_complexity == 2)\
38         {\
39                 out[0] = DotProduct(in, softwaretransform_rotatematrix[0]);\
40                 out[1] = DotProduct(in, softwaretransform_rotatematrix[1]);\
41                 out[2] = DotProduct(in, softwaretransform_rotatematrix[2]);\
42         }\
43         else\
44                 VectorCopy(in, out);\
45 }
47 #define softwareuntransform(in, out)\
48 {\
49         if (softwaretransform_complexity == 0)\
50         {\
51                 VectorCopy(in, out);\
52         }\
53         else if (softwaretransform_complexity == 1)\
54         {\
55                 out[0] = in[0] - softwaretransform_invmatrix[0][3];\
56                 out[1] = in[1] - softwaretransform_invmatrix[1][3];\
57                 out[2] = in[2] - softwaretransform_invmatrix[2][3];\
58         }\
59         else\
60         {\
61                 vec3_t soft_v;\
62                 soft_v[0] = in[0] - softwaretransform_invmatrix[0][3];\
63                 soft_v[1] = in[1] - softwaretransform_invmatrix[1][3];\
64                 soft_v[2] = in[2] - softwaretransform_invmatrix[2][3];\
65                 out[0] = DotProduct(soft_v, softwaretransform_invmatrix[0]);\
66                 out[1] = DotProduct(soft_v, softwaretransform_invmatrix[1]);\
67                 out[2] = DotProduct(soft_v, softwaretransform_invmatrix[2]);\
68         }\
69 }
71 #endif