+ R_Mesh_State(&m);
+
+ c_alias_polys += model->numtris;
+ GL_Color(fogcolor[0] * fog * r_colorscale, fogcolor[1] * fog * r_colorscale, fogcolor[2] * fog * r_colorscale, ent->alpha);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
+ }
+}
+
+void R_Model_Alias_Draw(entity_render_t *ent)
+{
+ if (ent->alpha < (1.0f / 64.0f))
+ return; // basically completely transparent
+
+ c_models++;
+
+ if (ent->effects & EF_ADDITIVE || ent->alpha != 1.0 || R_FetchSkinFrame(ent)->fog != NULL)
+ R_MeshQueue_AddTransparent(ent->origin, R_DrawQ1Q2AliasModelCallback, ent, 0);
+ else
+ R_DrawQ1Q2AliasModelCallback(ent, 0);
+}
+
+void R_Model_Alias_DrawFakeShadow (entity_render_t *ent)
+{
+ int i;
+ rmeshstate_t m;
+ model_t *model;
+ float *v, planenormal[3], planedist, dist, projection[3], floororigin[3], surfnormal[3], lightdirection[3], v2[3];
+
+ lightdirection[0] = 0.5;
+ lightdirection[1] = 0.2;
+ lightdirection[2] = -1;
+ VectorNormalizeFast(lightdirection);
+
+ VectorMA(ent->origin, 65536.0f, lightdirection, v2);
+ if (CL_TraceLine(ent->origin, v2, floororigin, surfnormal, 0, false, NULL) == 1)
+ return;
+
+ R_Mesh_Matrix(&ent->matrix);
+
+ model = ent->model;
+ R_Mesh_ResizeCheck(model->numverts);
+
+ memset(&m, 0, sizeof(m));
+ m.blendfunc1 = GL_SRC_ALPHA;
+ m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
+ R_Mesh_State(&m);
+
+ c_alias_polys += model->numtris;
+ R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
+
+ // put a light direction in the entity's coordinate space
+ Matrix4x4_Transform3x3(&ent->inversematrix, lightdirection, projection);
+ VectorNormalizeFast(projection);
+
+ // put the plane's normal in the entity's coordinate space
+ Matrix4x4_Transform3x3(&ent->inversematrix, surfnormal, planenormal);
+ VectorNormalizeFast(planenormal);
+
+ // put the plane's distance in the entity's coordinate space
+ VectorSubtract(floororigin, ent->origin, floororigin);
+ planedist = DotProduct(floororigin, surfnormal) + 2;
+
+ dist = -1.0f / DotProduct(projection, planenormal);
+ VectorScale(projection, dist, projection);
+ for (i = 0, v = varray_vertex;i < model->numverts;i++, v += 4)
+ {
+ dist = DotProduct(v, planenormal) - planedist;
+ if (dist > 0)
+ //if (i & 1)
+ VectorMA(v, dist, projection, v);
+ }
+ GL_Color(0, 0, 0, 0.5);
+ R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
+}
+
+void R_Model_Alias_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius)
+{
+ float projectdistance;
+ projectdistance = lightradius + ent->model->radius - sqrt(DotProduct(relativelightorigin, relativelightorigin));
+ if (projectdistance > 0.1)
+ {
+ R_Mesh_Matrix(&ent->matrix);
+ R_Mesh_ResizeCheck(ent->model->numverts * 2);
+ R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
+ R_Shadow_Volume(ent->model->numverts, ent->model->numtris, ent->model->mdlmd2data_indices, ent->model->mdlmd2data_triangleneighbors, relativelightorigin, lightradius, projectdistance);
+ }
+}
+
+void R_Model_Alias_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor)
+{
+ int c;
+ float lightcolor2[3];
+ qbyte *bcolor;
+ skinframe_t *skinframe;
+ R_Mesh_Matrix(&ent->matrix);
+ R_Mesh_ResizeCheck(ent->model->numverts);
+ R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
+ Mod_BuildTextureVectorsAndNormals(ent->model->numverts, ent->model->numtris, varray_vertex, ent->model->mdlmd2data_texcoords, ent->model->mdlmd2data_indices, aliasvert_svectors, aliasvert_tvectors, aliasvert_normals);
+ skinframe = R_FetchSkinFrame(ent);
+
+ // note: to properly handle fog this should scale the lightcolor into lightcolor2 according to 1-fog scaling
+
+ 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);
+
+ if (!skinframe->base && !skinframe->pants && !skinframe->shirt && !skinframe->glow)
+ {
+ 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);
+ return;
+ }
+
+ if (!skinframe->merged || (ent->colormap >= 0 && skinframe->base && (skinframe->pants || skinframe->shirt)))
+ {
+ // 128-224 are backwards ranges
+ // we only render non-fullbright ranges here
+ if (skinframe->pants && (ent->colormap & 0xF) < 0xE)