- surface = model->data_surfaces + surfacelist[surfacelistindex];
- // FIXME: get current skin
- texture = surface->texture;//R_FetchAliasSkin(ent, surface->groupmesh);
- if (texture->currentmaterialflags & (MATERIALFLAG_NODRAW | MATERIALFLAG_TRANSPARENT) || !surface->num_triangles)
- continue;
- RSurf_SetVertexPointer(ent, texture, surface, modelorg);
- // identify lit faces within the bounding box
- R_Shadow_PrepareShadowMark(surface->groupmesh->num_triangles);
- R_Shadow_MarkVolumeFromBox(surface->num_firsttriangle, surface->num_triangles, rsurface_vertex3f, surface->groupmesh->data_element3i, relativelightorigin, lightmins, lightmaxs, surface->mins, surface->maxs);
- R_Shadow_VolumeFromList(surface->groupmesh->num_vertices, surface->groupmesh->num_triangles, rsurface_vertex3f, surface->groupmesh->data_element3i, surface->groupmesh->data_neighbor3i, relativelightorigin, projectdistance, numshadowmark, shadowmarklist);
+ surface = model->data_surfaces + modelsurfacelist[modelsurfacelistindex];
+ if (t != surface->texture || numsurfacelist >= maxsurfacelist)
+ {
+ if (numsurfacelist)
+ {
+ R_Q1BSP_DrawShadowVolume_Batch(relativelightorigin, relativelightdirection, lightmins, lightmaxs, numsurfacelist, surfacelist);
+ numsurfacelist = 0;
+ }
+ t = surface->texture;
+ rsurface_texture = t->currentframe;
+ f = (rsurface_texture->currentmaterialflags & (MATERIALFLAG_NODRAW | MATERIALFLAG_TRANSPARENT | MATERIALFLAG_WALL)) == MATERIALFLAG_WALL;
+ }
+ if (f && surface->num_triangles)
+ surfacelist[numsurfacelist++] = surface;
+ }
+ if (numsurfacelist)
+ R_Q1BSP_DrawShadowVolume_Batch(relativelightorigin, relativelightdirection, lightmins, lightmaxs, numsurfacelist, surfacelist);
+ R_Shadow_VolumeFromList(model->surfmesh.num_vertices, model->surfmesh.num_triangles, rsurface_vertex3f, model->surfmesh.data_element3i, model->surfmesh.data_neighbor3i, relativelightorigin, relativelightdirection, projectdistance, numshadowmark, shadowmarklist);
+ }
+}
+
+#define BATCHSIZE 256
+
+static void R_Q1BSP_DrawLight_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
+{
+ int surfacelistindex, batchcount;
+ texture_t *t;
+ msurface_t *batchsurfaces[BATCHSIZE];
+ // note: in practice this never actually batches, oh well
+ R_Shadow_RenderMode_Begin();
+ R_Shadow_RenderMode_ActiveLight((rtlight_t *)rtlight);
+ R_Shadow_RenderMode_Lighting(false, true);
+ R_Shadow_SetupEntityLight(ent);
+ t = NULL;
+ batchcount = 0;
+ for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
+ {
+ msurface_t *surface = ent->model->data_surfaces + surfacelist[surfacelistindex];
+ if (t != surface->texture)
+ {
+ if (batchcount > 0)
+ R_Shadow_RenderSurfacesLighting(batchcount, batchsurfaces);
+ batchcount = 0;
+ t = surface->texture;
+ R_UpdateTextureInfo(ent, t);
+ rsurface_texture = t->currentframe;