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