most of Q2's keyboard handling ported over - what this means: keypad is now separatel...
[divverent/darkplaces.git] / gl_models.c
1
2 #include "quakedef.h"
3 #include "cl_collision.h"
4 #include "r_shadow.h"
5
6 typedef struct
7 {
8         float m[3][4];
9 } zymbonematrix;
10
11 // LordHavoc: vertex arrays
12
13 float *aliasvertcolorbuf;
14 float *aliasvertcolor; // this may point at aliasvertcolorbuf or at vertex arrays in the mesh backend
15 float *aliasvert_svectors;
16 float *aliasvert_tvectors;
17 float *aliasvert_normals;
18
19 float *aliasvertcolor2;
20 int *aliasvertusage;
21 zymbonematrix *zymbonepose;
22
23 mempool_t *gl_models_mempool;
24
25 void gl_models_start(void)
26 {
27         // allocate vertex processing arrays
28         gl_models_mempool = Mem_AllocPool("GL_Models");
29         aliasvertcolor = aliasvertcolorbuf = Mem_Alloc(gl_models_mempool, sizeof(float[MD2MAX_VERTS][4]));
30         aliasvert_svectors = Mem_Alloc(gl_models_mempool, sizeof(float[MD2MAX_VERTS][4]));
31         aliasvert_tvectors = Mem_Alloc(gl_models_mempool, sizeof(float[MD2MAX_VERTS][4]));
32         aliasvert_normals = Mem_Alloc(gl_models_mempool, sizeof(float[MD2MAX_VERTS][4]));
33         aliasvertcolor2 = Mem_Alloc(gl_models_mempool, sizeof(float[MD2MAX_VERTS][4])); // used temporarily for tinted coloring
34         zymbonepose = Mem_Alloc(gl_models_mempool, sizeof(zymbonematrix[256]));
35         aliasvertusage = Mem_Alloc(gl_models_mempool, sizeof(int[MD2MAX_VERTS]));
36 }
37
38 void gl_models_shutdown(void)
39 {
40         Mem_FreePool(&gl_models_mempool);
41 }
42
43 void gl_models_newmap(void)
44 {
45 }
46
47 void GL_Models_Init(void)
48 {
49         R_RegisterModule("GL_Models", gl_models_start, gl_models_shutdown, gl_models_newmap);
50 }
51
52 void R_AliasLerpVerts(int vertcount, float *vertices, float *normals,
53                 float lerp1, const trivertx_t *verts1, const vec3_t fscale1, const vec3_t translate1,
54                 float lerp2, const trivertx_t *verts2, const vec3_t fscale2, const vec3_t translate2,
55                 float lerp3, const trivertx_t *verts3, const vec3_t fscale3, const vec3_t translate3,
56                 float lerp4, const trivertx_t *verts4, const vec3_t fscale4, const vec3_t translate4)
57 {
58         int i;
59         vec3_t scale1, scale2, scale3, scale4, translate;
60         const float *n1, *n2, *n3, *n4;
61         float *av, *avn;
62         av = vertices;
63         avn = normals;
64         VectorScale(fscale1, lerp1, scale1);
65         if (lerp2)
66         {
67                 VectorScale(fscale2, lerp2, scale2);
68                 if (lerp3)
69                 {
70                         VectorScale(fscale3, lerp3, scale3);
71                         if (lerp4)
72                         {
73                                 VectorScale(fscale4, lerp4, scale4);
74                                 translate[0] = translate1[0] * lerp1 + translate2[0] * lerp2 + translate3[0] * lerp3 + translate4[0] * lerp4;
75                                 translate[1] = translate1[1] * lerp1 + translate2[1] * lerp2 + translate3[1] * lerp3 + translate4[1] * lerp4;
76                                 translate[2] = translate1[2] * lerp1 + translate2[2] * lerp2 + translate3[2] * lerp3 + translate4[2] * lerp4;
77                                 // generate vertices
78                                 for (i = 0;i < vertcount;i++)
79                                 {
80                                         av[0] = verts1->v[0] * scale1[0] + verts2->v[0] * scale2[0] + verts3->v[0] * scale3[0] + verts4->v[0] * scale4[0] + translate[0];
81                                         av[1] = verts1->v[1] * scale1[1] + verts2->v[1] * scale2[1] + verts3->v[1] * scale3[1] + verts4->v[1] * scale4[1] + translate[1];
82                                         av[2] = verts1->v[2] * scale1[2] + verts2->v[2] * scale2[2] + verts3->v[2] * scale3[2] + verts4->v[2] * scale4[2] + translate[2];
83                                         n1 = m_bytenormals[verts1->lightnormalindex];
84                                         n2 = m_bytenormals[verts2->lightnormalindex];
85                                         n3 = m_bytenormals[verts3->lightnormalindex];
86                                         n4 = m_bytenormals[verts4->lightnormalindex];
87                                         avn[0] = n1[0] * lerp1 + n2[0] * lerp2 + n3[0] * lerp3 + n4[0] * lerp4;
88                                         avn[1] = n1[1] * lerp1 + n2[1] * lerp2 + n3[1] * lerp3 + n4[1] * lerp4;
89                                         avn[2] = n1[2] * lerp1 + n2[2] * lerp2 + n3[2] * lerp3 + n4[2] * lerp4;
90                                         av += 4;
91                                         avn += 4;
92                                         verts1++;verts2++;verts3++;verts4++;
93                                 }
94                         }
95                         else
96                         {
97                                 translate[0] = translate1[0] * lerp1 + translate2[0] * lerp2 + translate3[0] * lerp3;
98                                 translate[1] = translate1[1] * lerp1 + translate2[1] * lerp2 + translate3[1] * lerp3;
99                                 translate[2] = translate1[2] * lerp1 + translate2[2] * lerp2 + translate3[2] * lerp3;
100                                 // generate vertices
101                                 for (i = 0;i < vertcount;i++)
102                                 {
103                                         av[0] = verts1->v[0] * scale1[0] + verts2->v[0] * scale2[0] + verts3->v[0] * scale3[0] + translate[0];
104                                         av[1] = verts1->v[1] * scale1[1] + verts2->v[1] * scale2[1] + verts3->v[1] * scale3[1] + translate[1];
105                                         av[2] = verts1->v[2] * scale1[2] + verts2->v[2] * scale2[2] + verts3->v[2] * scale3[2] + translate[2];
106                                         n1 = m_bytenormals[verts1->lightnormalindex];
107                                         n2 = m_bytenormals[verts2->lightnormalindex];
108                                         n3 = m_bytenormals[verts3->lightnormalindex];
109                                         avn[0] = n1[0] * lerp1 + n2[0] * lerp2 + n3[0] * lerp3;
110                                         avn[1] = n1[1] * lerp1 + n2[1] * lerp2 + n3[1] * lerp3;
111                                         avn[2] = n1[2] * lerp1 + n2[2] * lerp2 + n3[2] * lerp3;
112                                         av += 4;
113                                         avn += 4;
114                                         verts1++;verts2++;verts3++;
115                                 }
116                         }
117                 }
118                 else
119                 {
120                         translate[0] = translate1[0] * lerp1 + translate2[0] * lerp2;
121                         translate[1] = translate1[1] * lerp1 + translate2[1] * lerp2;
122                         translate[2] = translate1[2] * lerp1 + translate2[2] * lerp2;
123                         // generate vertices
124                         for (i = 0;i < vertcount;i++)
125                         {
126                                 av[0] = verts1->v[0] * scale1[0] + verts2->v[0] * scale2[0] + translate[0];
127                                 av[1] = verts1->v[1] * scale1[1] + verts2->v[1] * scale2[1] + translate[1];
128                                 av[2] = verts1->v[2] * scale1[2] + verts2->v[2] * scale2[2] + translate[2];
129                                 n1 = m_bytenormals[verts1->lightnormalindex];
130                                 n2 = m_bytenormals[verts2->lightnormalindex];
131                                 avn[0] = n1[0] * lerp1 + n2[0] * lerp2;
132                                 avn[1] = n1[1] * lerp1 + n2[1] * lerp2;
133                                 avn[2] = n1[2] * lerp1 + n2[2] * lerp2;
134                                 av += 4;
135                                 avn += 4;
136                                 verts1++;verts2++;
137                         }
138                 }
139         }
140         else
141         {
142                 translate[0] = translate1[0] * lerp1;
143                 translate[1] = translate1[1] * lerp1;
144                 translate[2] = translate1[2] * lerp1;
145                 // generate vertices
146                 if (lerp1 != 1)
147                 {
148                         // general but almost never used case
149                         for (i = 0;i < vertcount;i++)
150                         {
151                                 av[0] = verts1->v[0] * scale1[0] + translate[0];
152                                 av[1] = verts1->v[1] * scale1[1] + translate[1];
153                                 av[2] = verts1->v[2] * scale1[2] + translate[2];
154                                 n1 = m_bytenormals[verts1->lightnormalindex];
155                                 avn[0] = n1[0] * lerp1;
156                                 avn[1] = n1[1] * lerp1;
157                                 avn[2] = n1[2] * lerp1;
158                                 av += 4;
159                                 avn += 4;
160                                 verts1++;
161                         }
162                 }
163                 else
164                 {
165                         // fast normal case
166                         for (i = 0;i < vertcount;i++)
167                         {
168                                 av[0] = verts1->v[0] * scale1[0] + translate[0];
169                                 av[1] = verts1->v[1] * scale1[1] + translate[1];
170                                 av[2] = verts1->v[2] * scale1[2] + translate[2];
171                                 VectorCopy(m_bytenormals[verts1->lightnormalindex], avn);
172                                 av += 4;
173                                 avn += 4;
174                                 verts1++;
175                         }
176                 }
177         }
178 }
179
180 skinframe_t *R_FetchSkinFrame(const entity_render_t *ent)
181 {
182         model_t *model = ent->model;
183         int s = ent->skinnum;
184         if ((unsigned int)s >= (unsigned int)model->numskins)
185                 s = 0;
186         if (model->skinscenes[s].framecount > 1)
187                 return &model->skinframes[model->skinscenes[s].firstframe + (int) (cl.time * 10) % model->skinscenes[s].framecount];
188         else
189                 return &model->skinframes[model->skinscenes[s].firstframe];
190 }
191
192 void R_LerpMDLMD2Vertices(const entity_render_t *ent, float *vertices, float *normals)
193 {
194         const md2frame_t *frame1, *frame2, *frame3, *frame4;
195         const trivertx_t *frame1verts, *frame2verts, *frame3verts, *frame4verts;
196         const model_t *model = ent->model;
197
198         frame1 = &model->mdlmd2data_frames[ent->frameblend[0].frame];
199         frame2 = &model->mdlmd2data_frames[ent->frameblend[1].frame];
200         frame3 = &model->mdlmd2data_frames[ent->frameblend[2].frame];
201         frame4 = &model->mdlmd2data_frames[ent->frameblend[3].frame];
202         frame1verts = &model->mdlmd2data_pose[ent->frameblend[0].frame * model->numverts];
203         frame2verts = &model->mdlmd2data_pose[ent->frameblend[1].frame * model->numverts];
204         frame3verts = &model->mdlmd2data_pose[ent->frameblend[2].frame * model->numverts];
205         frame4verts = &model->mdlmd2data_pose[ent->frameblend[3].frame * model->numverts];
206         R_AliasLerpVerts(model->numverts, vertices, normals,
207                 ent->frameblend[0].lerp, frame1verts, frame1->scale, frame1->translate,
208                 ent->frameblend[1].lerp, frame2verts, frame2->scale, frame2->translate,
209                 ent->frameblend[2].lerp, frame3verts, frame3->scale, frame3->translate,
210                 ent->frameblend[3].lerp, frame4verts, frame4->scale, frame4->translate);
211 }
212
213 void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
214 {
215         int i, c, fullbright, pantsfullbright, shirtfullbright, colormapped, tex;
216         float pantscolor[3], shirtcolor[3];
217         float fog, ifog, colorscale;
218         vec3_t diff;
219         qbyte *bcolor;
220         rmeshstate_t m;
221         model_t *model;
222         skinframe_t *skinframe;
223         const entity_render_t *ent = calldata1;
224         int blendfunc1, blendfunc2;
225
226         R_Mesh_Matrix(&ent->matrix);
227
228         model = ent->model;
229         R_Mesh_ResizeCheck(model->numverts);
230
231         skinframe = R_FetchSkinFrame(ent);
232
233         fullbright = (ent->effects & EF_FULLBRIGHT) != 0;
234
235         fog = 0;
236         if (fogenabled)
237         {
238                 VectorSubtract(ent->origin, r_origin, diff);
239                 fog = DotProduct(diff,diff);
240                 if (fog < 0.01f)
241                         fog = 0.01f;
242                 fog = exp(fogdensity/fog);
243                 if (fog > 1)
244                         fog = 1;
245                 if (fog < 0.01f)
246                         fog = 0;
247                 // fog method: darken, additive fog
248                 // 1. render model as normal, scaled by inverse of fog alpha (darkens it)
249                 // 2. render fog as additive
250         }
251         ifog = 1 - fog;
252
253         if (ent->effects & EF_ADDITIVE)
254         {
255                 blendfunc1 = GL_SRC_ALPHA;
256                 blendfunc2 = GL_ONE;
257         }
258         else if (ent->alpha != 1.0 || skinframe->fog != NULL)
259         {
260                 blendfunc1 = GL_SRC_ALPHA;
261                 blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
262         }
263         else
264         {
265                 blendfunc1 = GL_ONE;
266                 blendfunc2 = GL_ZERO;
267         }
268
269         R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
270         memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[4]));
271         if (!skinframe->base && !skinframe->pants && !skinframe->shirt && !skinframe->glow)
272         {
273                 // untextured
274                 memset(&m, 0, sizeof(m));
275                 m.blendfunc1 = blendfunc1;
276                 m.blendfunc2 = blendfunc2;
277                 colorscale = r_colorscale;
278                 if (gl_combine.integer)
279                 {
280                         colorscale *= 0.25f;
281                         m.texrgbscale[0] = 4;
282                 }
283                 m.tex[0] = R_GetTexture(r_notexture);
284                 R_Mesh_State(&m);
285                 c_alias_polys += model->numtris;
286                 for (i = 0;i < model->numverts * 4;i += 4)
287                 {
288                         varray_texcoord[0][i + 0] *= 8.0f;
289                         varray_texcoord[0][i + 1] *= 8.0f;
290                 }
291                 R_LightModel(ent, model->numverts, varray_vertex, aliasvert_normals, varray_color, colorscale, colorscale, colorscale, false);
292                 R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
293                 return;
294         }
295
296         colormapped = !skinframe->merged || (ent->colormap >= 0 && skinframe->base && (skinframe->pants || skinframe->shirt));
297         if (colormapped)
298         {
299                 // 128-224 are backwards ranges
300                 c = (ent->colormap & 0xF) << 4;c += (c >= 128 && c < 224) ? 4 : 12;
301                 bcolor = (qbyte *) (&palette_complete[c]);
302                 pantsfullbright = c >= 224;
303                 VectorScale(bcolor, (1.0f / 255.0f), pantscolor);
304                 c = (ent->colormap & 0xF0);c += (c >= 128 && c < 224) ? 4 : 12;
305                 bcolor = (qbyte *) (&palette_complete[c]);
306                 shirtfullbright = c >= 224;
307                 VectorScale(bcolor, (1.0f / 255.0f), shirtcolor);
308         }
309         else
310         {
311                 pantscolor[0] = pantscolor[1] = pantscolor[2] = shirtcolor[0] = shirtcolor[1] = shirtcolor[2] = 1;
312                 pantsfullbright = shirtfullbright = false;
313         }
314
315         tex = colormapped ? R_GetTexture(skinframe->base) : R_GetTexture(skinframe->merged);
316         if (tex)
317         {
318                 memset(&m, 0, sizeof(m));
319                 m.blendfunc1 = blendfunc1;
320                 m.blendfunc2 = blendfunc2;
321                 colorscale = r_colorscale;
322                 if (gl_combine.integer)
323                 {
324                         colorscale *= 0.25f;
325                         m.texrgbscale[0] = 4;
326                 }
327                 m.tex[0] = tex;
328                 R_Mesh_State(&m);
329                 if (fullbright)
330                         GL_Color(colorscale * ifog, colorscale * ifog, colorscale * ifog, ent->alpha);
331                 else
332                         R_LightModel(ent, model->numverts, varray_vertex, aliasvert_normals, varray_color, colorscale * ifog, colorscale * ifog, colorscale * ifog, false);
333                 R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
334                 c_alias_polys += model->numtris;
335                 blendfunc1 = GL_SRC_ALPHA;
336                 blendfunc2 = GL_ONE;
337         }
338
339         if (colormapped)
340         {
341                 if (skinframe->pants)
342                 {
343                         tex = R_GetTexture(skinframe->pants);
344                         if (tex)
345                         {
346                                 memset(&m, 0, sizeof(m));
347                                 m.blendfunc1 = blendfunc1;
348                                 m.blendfunc2 = blendfunc2;
349                                 colorscale = r_colorscale;
350                                 if (gl_combine.integer)
351                                 {
352                                         colorscale *= 0.25f;
353                                         m.texrgbscale[0] = 4;
354                                 }
355                                 m.tex[0] = tex;
356                                 R_Mesh_State(&m);
357                                 if (pantsfullbright)
358                                         GL_Color(pantscolor[0] * colorscale * ifog, pantscolor[1] * colorscale * ifog, pantscolor[2] * colorscale * ifog, ent->alpha);
359                                 else
360                                         R_LightModel(ent, model->numverts, varray_vertex, aliasvert_normals, varray_color, pantscolor[0] * colorscale * ifog, pantscolor[1] * colorscale * ifog, pantscolor[2] * colorscale * ifog, false);
361                                 R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
362                                 c_alias_polys += model->numtris;
363                                 blendfunc1 = GL_SRC_ALPHA;
364                                 blendfunc2 = GL_ONE;
365                         }
366                 }
367                 if (skinframe->shirt)
368                 {
369                         tex = R_GetTexture(skinframe->shirt);
370                         if (tex)
371                         {
372                                 memset(&m, 0, sizeof(m));
373                                 m.blendfunc1 = blendfunc1;
374                                 m.blendfunc2 = blendfunc2;
375                                 colorscale = r_colorscale;
376                                 if (gl_combine.integer)
377                                 {
378                                         colorscale *= 0.25f;
379                                         m.texrgbscale[0] = 4;
380                                 }
381                                 m.tex[0] = tex;
382                                 R_Mesh_State(&m);
383                                 if (shirtfullbright)
384                                         GL_Color(shirtcolor[0] * colorscale * ifog, shirtcolor[1] * colorscale * ifog, shirtcolor[2] * colorscale * ifog, ent->alpha);
385                                 else
386                                         R_LightModel(ent, model->numverts, varray_vertex, aliasvert_normals, varray_color, shirtcolor[0] * colorscale * ifog, shirtcolor[1] * colorscale * ifog, shirtcolor[2] * colorscale * ifog, false);
387                                 R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
388                                 c_alias_polys += model->numtris;
389                                 blendfunc1 = GL_SRC_ALPHA;
390                                 blendfunc2 = GL_ONE;
391                         }
392                 }
393         }
394         if (skinframe->glow)
395         {
396                 tex = R_GetTexture(skinframe->glow);
397                 if (tex)
398                 {
399                         memset(&m, 0, sizeof(m));
400                         m.blendfunc1 = blendfunc1;
401                         m.blendfunc2 = blendfunc2;
402                         m.tex[0] = tex;
403                         R_Mesh_State(&m);
404
405                         blendfunc1 = GL_SRC_ALPHA;
406                         blendfunc2 = GL_ONE;
407                         c_alias_polys += model->numtris;
408                         GL_Color(ifog * r_colorscale, ifog * r_colorscale, ifog * r_colorscale, ent->alpha);
409                         R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
410                 }
411         }
412         if (fog)
413         {
414                 memset(&m, 0, sizeof(m));
415                 m.blendfunc1 = GL_SRC_ALPHA;
416                 m.blendfunc2 = GL_ONE;
417                 m.tex[0] = R_GetTexture(skinframe->fog);
418                 R_Mesh_State(&m);
419
420                 c_alias_polys += model->numtris;
421                 GL_Color(fogcolor[0] * fog * r_colorscale, fogcolor[1] * fog * r_colorscale, fogcolor[2] * fog * r_colorscale, ent->alpha);
422                 R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
423         }
424 }
425
426 void R_Model_Alias_Draw(entity_render_t *ent)
427 {
428         if (ent->alpha < (1.0f / 64.0f))
429                 return; // basically completely transparent
430
431         c_models++;
432
433         if (ent->effects & EF_ADDITIVE || ent->alpha != 1.0 || R_FetchSkinFrame(ent)->fog != NULL)
434                 R_MeshQueue_AddTransparent(ent->origin, R_DrawQ1Q2AliasModelCallback, ent, 0);
435         else
436                 R_DrawQ1Q2AliasModelCallback(ent, 0);
437 }
438
439 void R_Model_Alias_DrawFakeShadow (entity_render_t *ent)
440 {
441         int i;
442         rmeshstate_t m;
443         model_t *model;
444         float *v, planenormal[3], planedist, dist, projection[3], floororigin[3], surfnormal[3], lightdirection[3], v2[3];
445
446         lightdirection[0] = 0.5;
447         lightdirection[1] = 0.2;
448         lightdirection[2] = -1;
449         VectorNormalizeFast(lightdirection);
450
451         VectorMA(ent->origin, 65536.0f, lightdirection, v2);
452         if (CL_TraceLine(ent->origin, v2, floororigin, surfnormal, 0, false, NULL) == 1)
453                 return;
454
455         R_Mesh_Matrix(&ent->matrix);
456
457         model = ent->model;
458         R_Mesh_ResizeCheck(model->numverts);
459
460         memset(&m, 0, sizeof(m));
461         m.blendfunc1 = GL_SRC_ALPHA;
462         m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
463         R_Mesh_State(&m);
464
465         c_alias_polys += model->numtris;
466         R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
467
468         // put a light direction in the entity's coordinate space
469         Matrix4x4_Transform3x3(&ent->inversematrix, lightdirection, projection);
470         VectorNormalizeFast(projection);
471
472         // put the plane's normal in the entity's coordinate space
473         Matrix4x4_Transform3x3(&ent->inversematrix, surfnormal, planenormal);
474         VectorNormalizeFast(planenormal);
475
476         // put the plane's distance in the entity's coordinate space
477         VectorSubtract(floororigin, ent->origin, floororigin);
478         planedist = DotProduct(floororigin, surfnormal) + 2;
479
480         dist = -1.0f / DotProduct(projection, planenormal);
481         VectorScale(projection, dist, projection);
482         for (i = 0, v = varray_vertex;i < model->numverts;i++, v += 4)
483         {
484                 dist = DotProduct(v, planenormal) - planedist;
485                 if (dist > 0)
486                 //if (i & 1)
487                         VectorMA(v, dist, projection, v);
488         }
489         GL_Color(0, 0, 0, 0.5);
490         R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
491 }
492
493 void R_Model_Alias_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius)
494 {
495         float projectdistance;
496         projectdistance = lightradius + ent->model->radius - sqrt(DotProduct(relativelightorigin, relativelightorigin));
497         if (projectdistance > 0.1)
498         {
499                 R_Mesh_Matrix(&ent->matrix);
500                 R_Mesh_ResizeCheck(ent->model->numverts * 2);
501                 R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
502                 R_Shadow_Volume(ent->model->numverts, ent->model->numtris, ent->model->mdlmd2data_indices, ent->model->mdlmd2data_triangleneighbors, relativelightorigin, lightradius, projectdistance);
503         }
504 }
505
506 void R_Model_Alias_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor)
507 {
508         int c;
509         float lightcolor2[3];
510         qbyte *bcolor;
511         skinframe_t *skinframe;
512         R_Mesh_Matrix(&ent->matrix);
513         R_Mesh_ResizeCheck(ent->model->numverts);
514         R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
515         Mod_BuildTextureVectorsAndNormals(ent->model->numverts, ent->model->numtris, varray_vertex, ent->model->mdlmd2data_texcoords, ent->model->mdlmd2data_indices, aliasvert_svectors, aliasvert_tvectors, aliasvert_normals);
516         skinframe = R_FetchSkinFrame(ent);
517
518         // note: to properly handle fog this should scale the lightcolor into lightcolor2 according to 1-fog scaling
519
520         R_Shadow_SpecularLighting(ent->model->numverts, ent->model->numtris, ent->model->mdlmd2data_indices, aliasvert_svectors, aliasvert_tvectors, aliasvert_normals, ent->model->mdlmd2data_texcoords, relativelightorigin, relativeeyeorigin, lightradius, lightcolor, NULL, NULL, NULL);
521
522         if (!skinframe->base && !skinframe->pants && !skinframe->shirt && !skinframe->glow)
523         {
524                 R_Shadow_DiffuseLighting(ent->model->numverts, ent->model->numtris, ent->model->mdlmd2data_indices, aliasvert_svectors, aliasvert_tvectors, aliasvert_normals, ent->model->mdlmd2data_texcoords, relativelightorigin, lightradius, lightcolor, r_notexture, NULL, NULL);
525                 return;
526         }
527
528         if (!skinframe->merged || (ent->colormap >= 0 && skinframe->base && (skinframe->pants || skinframe->shirt)))
529         {
530                 // 128-224 are backwards ranges
531                 // we only render non-fullbright ranges here
532                 if (skinframe->pants && (ent->colormap & 0xF) < 0xE)
533                 {
534                         c = (ent->colormap & 0xF) << 4;c += (c >= 128 && c < 224) ? 4 : 12;
535                         bcolor = (qbyte *) (&palette_complete[c]);
536                         lightcolor2[0] = lightcolor[0] * bcolor[0] * (1.0f / 255.0f);
537                         lightcolor2[1] = lightcolor[1] * bcolor[1] * (1.0f / 255.0f);
538                         lightcolor2[2] = lightcolor[2] * bcolor[2] * (1.0f / 255.0f);
539                         R_Shadow_DiffuseLighting(ent->model->numverts, ent->model->numtris, ent->model->mdlmd2data_indices, aliasvert_svectors, aliasvert_tvectors, aliasvert_normals, ent->model->mdlmd2data_texcoords, relativelightorigin, lightradius, lightcolor2, skinframe->pants, skinframe->nmap, NULL);
540                 }
541
542                 // we only render non-fullbright ranges here
543                 if (skinframe->shirt && (ent->colormap & 0xF0) < 0xE0)
544                 {
545                         c = (ent->colormap & 0xF0);c += (c >= 128 && c < 224) ? 4 : 12;
546                         bcolor = (qbyte *) (&palette_complete[c]);
547                         lightcolor2[0] = lightcolor[0] * bcolor[0] * (1.0f / 255.0f);
548                         lightcolor2[1] = lightcolor[1] * bcolor[1] * (1.0f / 255.0f);
549                         lightcolor2[2] = lightcolor[2] * bcolor[2] * (1.0f / 255.0f);
550                         R_Shadow_DiffuseLighting(ent->model->numverts, ent->model->numtris, ent->model->mdlmd2data_indices, aliasvert_svectors, aliasvert_tvectors, aliasvert_normals, ent->model->mdlmd2data_texcoords, relativelightorigin, lightradius, lightcolor2, skinframe->shirt, skinframe->nmap, NULL);
551                 }
552
553                 if (skinframe->base)
554                         R_Shadow_DiffuseLighting(ent->model->numverts, ent->model->numtris, ent->model->mdlmd2data_indices, aliasvert_svectors, aliasvert_tvectors, aliasvert_normals, ent->model->mdlmd2data_texcoords, relativelightorigin, lightradius, lightcolor, skinframe->base, skinframe->nmap, NULL);
555         }
556         else
557                 if (skinframe->merged)
558                         R_Shadow_DiffuseLighting(ent->model->numverts, ent->model->numtris, ent->model->mdlmd2data_indices, aliasvert_svectors, aliasvert_tvectors, aliasvert_normals, ent->model->mdlmd2data_texcoords, relativelightorigin, lightradius, lightcolor, skinframe->merged, skinframe->nmap, NULL);
559 }
560
561 int ZymoticLerpBones(int count, const zymbonematrix *bonebase, const frameblend_t *blend, const zymbone_t *bone)
562 {
563         int i;
564         float lerp1, lerp2, lerp3, lerp4;
565         zymbonematrix *out, rootmatrix, m;
566         const zymbonematrix *bone1, *bone2, *bone3, *bone4;
567
568         rootmatrix.m[0][0] = 1;
569         rootmatrix.m[0][1] = 0;
570         rootmatrix.m[0][2] = 0;
571         rootmatrix.m[0][3] = 0;
572         rootmatrix.m[1][0] = 0;
573         rootmatrix.m[1][1] = 1;
574         rootmatrix.m[1][2] = 0;
575         rootmatrix.m[1][3] = 0;
576         rootmatrix.m[2][0] = 0;
577         rootmatrix.m[2][1] = 0;
578         rootmatrix.m[2][2] = 1;
579         rootmatrix.m[2][3] = 0;
580
581         bone1 = bonebase + blend[0].frame * count;
582         lerp1 = blend[0].lerp;
583         if (blend[1].lerp)
584         {
585                 bone2 = bonebase + blend[1].frame * count;
586                 lerp2 = blend[1].lerp;
587                 if (blend[2].lerp)
588                 {
589                         bone3 = bonebase + blend[2].frame * count;
590                         lerp3 = blend[2].lerp;
591                         if (blend[3].lerp)
592                         {
593                                 // 4 poses
594                                 bone4 = bonebase + blend[3].frame * count;
595                                 lerp4 = blend[3].lerp;
596                                 for (i = 0, out = zymbonepose;i < count;i++, out++)
597                                 {
598                                         // interpolate matrices
599                                         m.m[0][0] = bone1->m[0][0] * lerp1 + bone2->m[0][0] * lerp2 + bone3->m[0][0] * lerp3 + bone4->m[0][0] * lerp4;
600                                         m.m[0][1] = bone1->m[0][1] * lerp1 + bone2->m[0][1] * lerp2 + bone3->m[0][1] * lerp3 + bone4->m[0][1] * lerp4;
601                                         m.m[0][2] = bone1->m[0][2] * lerp1 + bone2->m[0][2] * lerp2 + bone3->m[0][2] * lerp3 + bone4->m[0][2] * lerp4;
602                                         m.m[0][3] = bone1->m[0][3] * lerp1 + bone2->m[0][3] * lerp2 + bone3->m[0][3] * lerp3 + bone4->m[0][3] * lerp4;
603                                         m.m[1][0] = bone1->m[1][0] * lerp1 + bone2->m[1][0] * lerp2 + bone3->m[1][0] * lerp3 + bone4->m[1][0] * lerp4;
604                                         m.m[1][1] = bone1->m[1][1] * lerp1 + bone2->m[1][1] * lerp2 + bone3->m[1][1] * lerp3 + bone4->m[1][1] * lerp4;
605                                         m.m[1][2] = bone1->m[1][2] * lerp1 + bone2->m[1][2] * lerp2 + bone3->m[1][2] * lerp3 + bone4->m[1][2] * lerp4;
606                                         m.m[1][3] = bone1->m[1][3] * lerp1 + bone2->m[1][3] * lerp2 + bone3->m[1][3] * lerp3 + bone4->m[1][3] * lerp4;
607                                         m.m[2][0] = bone1->m[2][0] * lerp1 + bone2->m[2][0] * lerp2 + bone3->m[2][0] * lerp3 + bone4->m[2][0] * lerp4;
608                                         m.m[2][1] = bone1->m[2][1] * lerp1 + bone2->m[2][1] * lerp2 + bone3->m[2][1] * lerp3 + bone4->m[2][1] * lerp4;
609                                         m.m[2][2] = bone1->m[2][2] * lerp1 + bone2->m[2][2] * lerp2 + bone3->m[2][2] * lerp3 + bone4->m[2][2] * lerp4;
610                                         m.m[2][3] = bone1->m[2][3] * lerp1 + bone2->m[2][3] * lerp2 + bone3->m[2][3] * lerp3 + bone4->m[2][3] * lerp4;
611                                         if (bone->parent >= 0)
612                                                 R_ConcatTransforms(&zymbonepose[bone->parent].m[0][0], &m.m[0][0], &out->m[0][0]);
613                                         else
614                                                 R_ConcatTransforms(&rootmatrix.m[0][0], &m.m[0][0], &out->m[0][0]);
615                                         bone1++;
616                                         bone2++;
617                                         bone3++;
618                                         bone4++;
619                                         bone++;
620                                 }
621                         }
622                         else
623                         {
624                                 // 3 poses
625                                 for (i = 0, out = zymbonepose;i < count;i++, out++)
626                                 {
627                                         // interpolate matrices
628                                         m.m[0][0] = bone1->m[0][0] * lerp1 + bone2->m[0][0] * lerp2 + bone3->m[0][0] * lerp3;
629                                         m.m[0][1] = bone1->m[0][1] * lerp1 + bone2->m[0][1] * lerp2 + bone3->m[0][1] * lerp3;
630                                         m.m[0][2] = bone1->m[0][2] * lerp1 + bone2->m[0][2] * lerp2 + bone3->m[0][2] * lerp3;
631                                         m.m[0][3] = bone1->m[0][3] * lerp1 + bone2->m[0][3] * lerp2 + bone3->m[0][3] * lerp3;
632                                         m.m[1][0] = bone1->m[1][0] * lerp1 + bone2->m[1][0] * lerp2 + bone3->m[1][0] * lerp3;
633                                         m.m[1][1] = bone1->m[1][1] * lerp1 + bone2->m[1][1] * lerp2 + bone3->m[1][1] * lerp3;
634                                         m.m[1][2] = bone1->m[1][2] * lerp1 + bone2->m[1][2] * lerp2 + bone3->m[1][2] * lerp3;
635                                         m.m[1][3] = bone1->m[1][3] * lerp1 + bone2->m[1][3] * lerp2 + bone3->m[1][3] * lerp3;
636                                         m.m[2][0] = bone1->m[2][0] * lerp1 + bone2->m[2][0] * lerp2 + bone3->m[2][0] * lerp3;
637                                         m.m[2][1] = bone1->m[2][1] * lerp1 + bone2->m[2][1] * lerp2 + bone3->m[2][1] * lerp3;
638                                         m.m[2][2] = bone1->m[2][2] * lerp1 + bone2->m[2][2] * lerp2 + bone3->m[2][2] * lerp3;
639                                         m.m[2][3] = bone1->m[2][3] * lerp1 + bone2->m[2][3] * lerp2 + bone3->m[2][3] * lerp3;
640                                         if (bone->parent >= 0)
641                                                 R_ConcatTransforms(&zymbonepose[bone->parent].m[0][0], &m.m[0][0], &out->m[0][0]);
642                                         else
643                                                 R_ConcatTransforms(&rootmatrix.m[0][0], &m.m[0][0], &out->m[0][0]);
644                                         bone1++;
645                                         bone2++;
646                                         bone3++;
647                                         bone++;
648                                 }
649                         }
650                 }
651                 else
652                 {
653                         // 2 poses
654                         for (i = 0, out = zymbonepose;i < count;i++, out++)
655                         {
656                                 // interpolate matrices
657                                 m.m[0][0] = bone1->m[0][0] * lerp1 + bone2->m[0][0] * lerp2;
658                                 m.m[0][1] = bone1->m[0][1] * lerp1 + bone2->m[0][1] * lerp2;
659                                 m.m[0][2] = bone1->m[0][2] * lerp1 + bone2->m[0][2] * lerp2;
660                                 m.m[0][3] = bone1->m[0][3] * lerp1 + bone2->m[0][3] * lerp2;
661                                 m.m[1][0] = bone1->m[1][0] * lerp1 + bone2->m[1][0] * lerp2;
662                                 m.m[1][1] = bone1->m[1][1] * lerp1 + bone2->m[1][1] * lerp2;
663                                 m.m[1][2] = bone1->m[1][2] * lerp1 + bone2->m[1][2] * lerp2;
664                                 m.m[1][3] = bone1->m[1][3] * lerp1 + bone2->m[1][3] * lerp2;
665                                 m.m[2][0] = bone1->m[2][0] * lerp1 + bone2->m[2][0] * lerp2;
666                                 m.m[2][1] = bone1->m[2][1] * lerp1 + bone2->m[2][1] * lerp2;
667                                 m.m[2][2] = bone1->m[2][2] * lerp1 + bone2->m[2][2] * lerp2;
668                                 m.m[2][3] = bone1->m[2][3] * lerp1 + bone2->m[2][3] * lerp2;
669                                 if (bone->parent >= 0)
670                                         R_ConcatTransforms(&zymbonepose[bone->parent].m[0][0], &m.m[0][0], &out->m[0][0]);
671                                 else
672                                         R_ConcatTransforms(&rootmatrix.m[0][0], &m.m[0][0], &out->m[0][0]);
673                                 bone1++;
674                                 bone2++;
675                                 bone++;
676                         }
677                 }
678         }
679         else
680         {
681                 // 1 pose
682                 if (lerp1 != 1)
683                 {
684                         // lerp != 1.0
685                         for (i = 0, out = zymbonepose;i < count;i++, out++)
686                         {
687                                 // interpolate matrices
688                                 m.m[0][0] = bone1->m[0][0] * lerp1;
689                                 m.m[0][1] = bone1->m[0][1] * lerp1;
690                                 m.m[0][2] = bone1->m[0][2] * lerp1;
691                                 m.m[0][3] = bone1->m[0][3] * lerp1;
692                                 m.m[1][0] = bone1->m[1][0] * lerp1;
693                                 m.m[1][1] = bone1->m[1][1] * lerp1;
694                                 m.m[1][2] = bone1->m[1][2] * lerp1;
695                                 m.m[1][3] = bone1->m[1][3] * lerp1;
696                                 m.m[2][0] = bone1->m[2][0] * lerp1;
697                                 m.m[2][1] = bone1->m[2][1] * lerp1;
698                                 m.m[2][2] = bone1->m[2][2] * lerp1;
699                                 m.m[2][3] = bone1->m[2][3] * lerp1;
700                                 if (bone->parent >= 0)
701                                         R_ConcatTransforms(&zymbonepose[bone->parent].m[0][0], &m.m[0][0], &out->m[0][0]);
702                                 else
703                                         R_ConcatTransforms(&rootmatrix.m[0][0], &m.m[0][0], &out->m[0][0]);
704                                 bone1++;
705                                 bone++;
706                         }
707                 }
708                 else
709                 {
710                         // lerp == 1.0
711                         for (i = 0, out = zymbonepose;i < count;i++, out++)
712                         {
713                                 if (bone->parent >= 0)
714                                         R_ConcatTransforms(&zymbonepose[bone->parent].m[0][0], &bone1->m[0][0], &out->m[0][0]);
715                                 else
716                                         R_ConcatTransforms(&rootmatrix.m[0][0], &bone1->m[0][0], &out->m[0][0]);
717                                 bone1++;
718                                 bone++;
719                         }
720                 }
721         }
722         return true;
723 }
724
725 void ZymoticTransformVerts(int vertcount, float *vertex, int *bonecounts, zymvertex_t *vert)
726 {
727         int c;
728         float *out = vertex;
729         zymbonematrix *matrix;
730         while(vertcount--)
731         {
732                 c = *bonecounts++;
733                 // FIXME: validate bonecounts at load time (must be >= 1)
734                 // FIXME: need 4th component in origin, for how much of the translate to blend in
735                 if (c == 1)
736                 {
737                         matrix = &zymbonepose[vert->bonenum];
738                         out[0] = vert->origin[0] * matrix->m[0][0] + vert->origin[1] * matrix->m[0][1] + vert->origin[2] * matrix->m[0][2] + matrix->m[0][3];
739                         out[1] = vert->origin[0] * matrix->m[1][0] + vert->origin[1] * matrix->m[1][1] + vert->origin[2] * matrix->m[1][2] + matrix->m[1][3];
740                         out[2] = vert->origin[0] * matrix->m[2][0] + vert->origin[1] * matrix->m[2][1] + vert->origin[2] * matrix->m[2][2] + matrix->m[2][3];
741                         vert++;
742                 }
743                 else
744                 {
745                         VectorClear(out);
746                         while(c--)
747                         {
748                                 matrix = &zymbonepose[vert->bonenum];
749                                 out[0] += vert->origin[0] * matrix->m[0][0] + vert->origin[1] * matrix->m[0][1] + vert->origin[2] * matrix->m[0][2] + matrix->m[0][3];
750                                 out[1] += vert->origin[0] * matrix->m[1][0] + vert->origin[1] * matrix->m[1][1] + vert->origin[2] * matrix->m[1][2] + matrix->m[1][3];
751                                 out[2] += vert->origin[0] * matrix->m[2][0] + vert->origin[1] * matrix->m[2][1] + vert->origin[2] * matrix->m[2][2] + matrix->m[2][3];
752                                 vert++;
753                         }
754                 }
755                 out += 4;
756         }
757 }
758
759 void ZymoticCalcNormals(int vertcount, float *vertex, float *normals, int shadercount, int *renderlist)
760 {
761         int a, b, c, d;
762         float *out, v1[3], v2[3], normal[3], s;
763         int *u;
764         // clear normals
765         memset(normals, 0, sizeof(float) * vertcount * 3);
766         memset(aliasvertusage, 0, sizeof(int) * vertcount);
767         // parse render list and accumulate surface normals
768         while(shadercount--)
769         {
770                 d = *renderlist++;
771                 while (d--)
772                 {
773                         a = renderlist[0]*4;
774                         b = renderlist[1]*4;
775                         c = renderlist[2]*4;
776                         v1[0] = vertex[a+0] - vertex[b+0];
777                         v1[1] = vertex[a+1] - vertex[b+1];
778                         v1[2] = vertex[a+2] - vertex[b+2];
779                         v2[0] = vertex[c+0] - vertex[b+0];
780                         v2[1] = vertex[c+1] - vertex[b+1];
781                         v2[2] = vertex[c+2] - vertex[b+2];
782                         CrossProduct(v1, v2, normal);
783                         VectorNormalizeFast(normal);
784                         // add surface normal to vertices
785                         a = renderlist[0] * 3;
786                         normals[a+0] += normal[0];
787                         normals[a+1] += normal[1];
788                         normals[a+2] += normal[2];
789                         aliasvertusage[renderlist[0]]++;
790                         a = renderlist[1] * 3;
791                         normals[a+0] += normal[0];
792                         normals[a+1] += normal[1];
793                         normals[a+2] += normal[2];
794                         aliasvertusage[renderlist[1]]++;
795                         a = renderlist[2] * 3;
796                         normals[a+0] += normal[0];
797                         normals[a+1] += normal[1];
798                         normals[a+2] += normal[2];
799                         aliasvertusage[renderlist[2]]++;
800                         renderlist += 3;
801                 }
802         }
803         // FIXME: precalc this
804         // average surface normals
805         out = normals;
806         u = aliasvertusage;
807         while(vertcount--)
808         {
809                 if (*u > 1)
810                 {
811                         s = ixtable[*u];
812                         out[0] *= s;
813                         out[1] *= s;
814                         out[2] *= s;
815                 }
816                 u++;
817                 out += 3;
818         }
819 }
820
821 void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
822 {
823         float fog, ifog, colorscale;
824         vec3_t diff;
825         int i, *renderlist, *elements;
826         rtexture_t *texture;
827         rmeshstate_t mstate;
828         const entity_render_t *ent = calldata1;
829         int shadernum = calldata2;
830         int numverts, numtriangles;
831
832         R_Mesh_Matrix(&ent->matrix);
833
834         // find the vertex index list and texture
835         renderlist = ent->model->zymdata_renderlist;
836         for (i = 0;i < shadernum;i++)
837                 renderlist += renderlist[0] * 3 + 1;
838         texture = ent->model->zymdata_textures[shadernum];
839
840         numverts = ent->model->zymnum_verts;
841         numtriangles = *renderlist++;
842         elements = renderlist;
843         R_Mesh_ResizeCheck(numverts);
844
845         fog = 0;
846         if (fogenabled)
847         {
848                 VectorSubtract(ent->origin, r_origin, diff);
849                 fog = DotProduct(diff,diff);
850                 if (fog < 0.01f)
851                         fog = 0.01f;
852                 fog = exp(fogdensity/fog);
853                 if (fog > 1)
854                         fog = 1;
855                 if (fog < 0.01f)
856                         fog = 0;
857                 // fog method: darken, additive fog
858                 // 1. render model as normal, scaled by inverse of fog alpha (darkens it)
859                 // 2. render fog as additive
860         }
861         ifog = 1 - fog;
862
863         memset(&mstate, 0, sizeof(mstate));
864         if (ent->effects & EF_ADDITIVE)
865         {
866                 mstate.blendfunc1 = GL_SRC_ALPHA;
867                 mstate.blendfunc2 = GL_ONE;
868         }
869         else if (ent->alpha != 1.0 || R_TextureHasAlpha(texture))
870         {
871                 mstate.blendfunc1 = GL_SRC_ALPHA;
872                 mstate.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
873         }
874         else
875         {
876                 mstate.blendfunc1 = GL_ONE;
877                 mstate.blendfunc2 = GL_ZERO;
878         }
879         colorscale = r_colorscale;
880         if (gl_combine.integer)
881         {
882                 mstate.texrgbscale[0] = 4;
883                 colorscale *= 0.25f;
884         }
885         mstate.tex[0] = R_GetTexture(texture);
886         R_Mesh_State(&mstate);
887         ZymoticLerpBones(ent->model->zymnum_bones, (zymbonematrix *) ent->model->zymdata_poses, ent->frameblend, ent->model->zymdata_bones);
888         ZymoticTransformVerts(numverts, varray_vertex, ent->model->zymdata_vertbonecounts, ent->model->zymdata_verts);
889         ZymoticCalcNormals(numverts, varray_vertex, aliasvert_normals, ent->model->zymnum_shaders, ent->model->zymdata_renderlist);
890         memcpy(varray_texcoord[0], ent->model->zymdata_texcoords, ent->model->zymnum_verts * sizeof(float[4]));
891         GL_UseColorArray();
892         R_LightModel(ent, numverts, varray_vertex, aliasvert_normals, varray_color, ifog * colorscale, ifog * colorscale, ifog * colorscale, false);
893         R_Mesh_Draw(numverts, numtriangles, elements);
894         c_alias_polys += numtriangles;
895
896         if (fog)
897         {
898                 memset(&mstate, 0, sizeof(mstate));
899                 mstate.blendfunc1 = GL_SRC_ALPHA;
900                 mstate.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
901                 // FIXME: need alpha mask for fogging...
902                 //mstate.tex[0] = R_GetTexture(texture);
903                 R_Mesh_State(&mstate);
904                 GL_Color(fogcolor[0] * r_colorscale, fogcolor[1] * r_colorscale, fogcolor[2] * r_colorscale, ent->alpha * fog);
905                 R_Mesh_Draw(numverts, numtriangles, elements);
906                 c_alias_polys += numtriangles;
907         }
908 }
909
910 void R_Model_Zymotic_Draw(entity_render_t *ent)
911 {
912         int i;
913
914         if (ent->alpha < (1.0f / 64.0f))
915                 return; // basically completely transparent
916
917         c_models++;
918
919         for (i = 0;i < ent->model->zymnum_shaders;i++)
920         {
921                 if (ent->effects & EF_ADDITIVE || ent->alpha != 1.0 || R_TextureHasAlpha(ent->model->zymdata_textures[i]))
922                         R_MeshQueue_AddTransparent(ent->origin, R_DrawZymoticModelMeshCallback, ent, i);
923                 else
924                         R_DrawZymoticModelMeshCallback(ent, i);
925         }
926 }
927
928 void R_Model_Zymotic_DrawFakeShadow(entity_render_t *ent)
929 {
930         // FIXME
931 }
932
933 void R_Model_Zymotic_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, float lightradius2, float lightdistbias, float lightsubtract, float *lightcolor)
934 {
935         // FIXME
936 }
937
938 void R_Model_Zymotic_DrawOntoLight(entity_render_t *ent)
939 {
940         // FIXME
941 }