- *index++ = 0;
- *index++ = i + 1;
- *index++ = i + 2;
- }
-
- for (i = 0, in = surf->poly_verts, out = mesh->vertex;i < mesh->numverts;i++, in += 3, out++)
- {
- VectorCopy (in, out->v);
-
- s = DotProduct (out->v, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3];
- t = DotProduct (out->v, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3];
-
- out->st[0] = s / surf->texinfo->texture->width;
- out->st[1] = t / surf->texinfo->texture->height;
-
- s = (s + 8 - surf->texturemins[0]) * (1.0 / 16.0);
- t = (t + 8 - surf->texturemins[1]) * (1.0 / 16.0);
-
- // lightmap coordinates
- out->uv[0] = 0;
- out->uv[1] = 0;
-
- // LordHavoc: calc lightmap data offset for vertex lighting to use
- is = (int) s;
- it = (int) t;
- is = bound(0, is, smax);
- it = bound(0, it, tmax);
- out->lightmapoffset = ((it * (smax+1) + is) * 3);
- }
-}
-
-void Mod_GenerateLightmappedMesh (msurface_t *surf)
-{
- int i, is, it, *index, smax, tmax;
- float *in, s, t, xbase, ybase, xscale, yscale;
- surfvertex_t *out;
- surfmesh_t *mesh;
-
- surf->flags |= SURF_LIGHTMAP;
- smax = surf->extents[0] >> 4;
- tmax = surf->extents[1] >> 4;
- if (r_miplightmaps.integer)
- {
- surf->lightmaptexturestride = (surf->extents[0]>>4)+1;
- surf->lightmaptexture = R_ProceduralTexture(loadmodel->texturepool, NULL, surf->lightmaptexturestride, (surf->extents[1]>>4)+1, loadmodel->lightmaprgba ? TEXTYPE_RGBA : TEXTYPE_RGB, TEXF_MIPMAP | TEXF_PRECACHE, NULL, NULL, 0);