-#if 1
- int i;
- surfvertex_t *v;
- float *outv, *outc, *outst, cl, ca, diff[3];
- surfmesh_t *mesh;
- rmeshbufferinfo_t m;
- memset(&m, 0, sizeof(m));
- m.transparent = currentrenderentity->effects & EF_ADDITIVE || surf->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1;
- m.blendfunc1 = GL_SRC_ALPHA;
- m.blendfunc2 = GL_ONE;
- m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
- ca = currentrenderentity->alpha;
- for (mesh = surf->mesh;mesh;mesh = mesh->chain)
- {
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
-
- if (R_Mesh_Draw_GetBuffer(&m))
- {
- cl = m.colorscale;
- memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
- if (fogenabled)
- {
- for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2)
- {
- softwaretransform(v->v, outv);
- outv[3] = 1;
- VectorSubtract(outv, r_origin, diff);
- outc[0] = outc[1] = outc[2] = cl * (1 - exp(fogdensity/DotProduct(diff, diff)));
- outc[3] = ca;
- outst[0] = v->st[0];
- outst[1] = v->st[1];
- }
- }
- else
- {
- for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2)
- {
- softwaretransform(v->v, outv);
- outv[3] = 1;
- outc[0] = outc[1] = outc[2] = cl;
- outc[3] = ca;
- outst[0] = v->st[0];
- outst[1] = v->st[1];
- }
- }
- }
- }
-#else
- int i;
- float diff[3], ifog;
- surfvertex_t *v;
- surfvert_t *sv;
- surfmesh_t *mesh;
- rmeshinfo_t m;
-
- memset(&m, 0, sizeof(m));
- m.transparent = currentrenderentity->effects & EF_ADDITIVE || surf->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1;
- m.blendfunc1 = GL_SRC_ALPHA;
- m.blendfunc2 = GL_ONE;
- m.cr = 1;
- m.cg = 1;
- m.cb = 1;
- m.ca = currentrenderentity->alpha;
- m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
- m.texcoordstep[0] = sizeof(surfvertex_t);
- for (mesh = surf->mesh;mesh;mesh = mesh->chain)
- {
- m.numtriangles = mesh->numtriangles;
- m.numverts = mesh->numverts;
- m.index = mesh->index;
- m.texcoords[0] = &mesh->vertex->st[0];
- if (fogenabled)
- {
- m.color = &svert[0].c[0];
- m.colorstep = sizeof(surfvert_t);
- if (softwaretransform_complexity)
- {
- m.vertex = &svert[0].v[0];
- m.vertexstep = sizeof(surfvert_t);
- for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
- {
- softwaretransform(v->v, sv->v);
- VectorSubtract(sv->v, r_origin, diff);
- ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
- sv->c[0] = m.cr * ifog;
- sv->c[1] = m.cg * ifog;
- sv->c[2] = m.cb * ifog;
- sv->c[3] = m.ca;
- }
- }
- else
- {
- m.vertex = &mesh->vertex->v[0];
- m.vertexstep = sizeof(surfvertex_t);
- for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
- {
- VectorSubtract(v->v, r_origin, diff);
- ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
- sv->c[0] = m.cr * ifog;
- sv->c[1] = m.cg * ifog;
- sv->c[2] = m.cb * ifog;
- sv->c[3] = m.ca;
- }
- }
- }
- else
- {
- if (softwaretransform_complexity)
- {
- m.vertex = &svert[0].v[0];
- m.vertexstep = sizeof(surfvert_t);
- for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
- softwaretransform(v->v, sv->v);
- }
- else
- {
- m.vertex = &mesh->vertex->v[0];
- m.vertexstep = sizeof(surfvertex_t);
- }
- }
- R_Mesh_Draw(&m);
- }