- batchnumtriangles = 0;
- batchfirsttriangle = surface->num_firsttriangle;
- m = 0; // hush warning
- for (l = k;l < kend;l++)
- {
- surface = batchsurfacelist[l];
- RSurf_PrepareVerticesForBatch(true, true, 1, &surface);
- for (m = surface->num_firsttriangle, mend = m + surface->num_triangles;m < mend;m++)
- {
- if (lighttrispvs && r_test.integer && !CHECKPVSBIT(lighttrispvs, m))
- continue;
- if (batchnumtriangles >= BATCHSIZE)
- {
- r_refdef.stats.lights_lighttriangles += batchnumtriangles;
- Mod_VertexRangeFromElements(batchnumtriangles*3, batchelements, &batchfirstvertex, &batchlastvertex);
- // use the element buffer if all triangles are consecutive
- if (m == batchfirsttriangle + batchnumtriangles)
- R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, batchfirsttriangle, batchnumtriangles, ent->model->surfmesh.data_element3i, ent->model->surfmesh.data_element3s, ent->model->surfmesh.ebo3i, ent->model->surfmesh.ebo3s);
- else
- R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, 0, batchnumtriangles, batchelements, NULL, 0, 0);
- batchnumtriangles = 0;
- batchfirsttriangle = m;
- }
- batchelements[batchnumtriangles*3+0] = element3i[m*3+0];
- batchelements[batchnumtriangles*3+1] = element3i[m*3+1];
- batchelements[batchnumtriangles*3+2] = element3i[m*3+2];
- batchnumtriangles++;
- }
- }
- if (batchnumtriangles > 0)
- {
- r_refdef.stats.lights_lighttriangles += batchnumtriangles;
- Mod_VertexRangeFromElements(batchnumtriangles*3, batchelements, &batchfirstvertex, &batchlastvertex);
- // use the element buffer if all triangles are consecutive
- if (m == batchfirsttriangle + batchnumtriangles)
- R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, batchfirsttriangle, batchnumtriangles, ent->model->surfmesh.data_element3i, ent->model->surfmesh.data_element3s, ent->model->surfmesh.ebo3i, ent->model->surfmesh.ebo3s);
- else
- R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, 0, batchnumtriangles, batchelements, NULL, 0, 0);
- }