- lightpvsbytes = 0;
- if (r_vismarklights.integer && ent->model->brush.FatPVS)
- lightpvsbytes = ent->model->brush.FatPVS(ent->model, lightorigin, 0, lightpvs, sizeof(lightpvs));
- R_RecursiveMarkLights(ent, lightorigin, light, bit, bitindex, ent->model->brush.data_nodes + ent->model->brushq1.hulls[0].firstclipnode, lightpvs, min(lightpvsbytes * 8, ent->model->brush.num_pvsclusters));
+ lightmins[0] = lightorigin[0] - light->rtlight.lightmap_cullradius;
+ lightmins[1] = lightorigin[1] - light->rtlight.lightmap_cullradius;
+ lightmins[2] = lightorigin[2] - light->rtlight.lightmap_cullradius;
+ lightmaxs[0] = lightorigin[0] + light->rtlight.lightmap_cullradius;
+ lightmaxs[1] = lightorigin[1] + light->rtlight.lightmap_cullradius;
+ lightmaxs[2] = lightorigin[2] + light->rtlight.lightmap_cullradius;
+ if (ent == r_refdef.worldentity)
+ {
+ lightpvsbytes = 0;
+ if (r_vismarklights.integer && ent->model->brush.FatPVS)
+ lightpvsbytes = ent->model->brush.FatPVS(ent->model, lightorigin, 0, lightpvs, sizeof(lightpvs));
+ R_RecursiveMarkLights(ent, lightorigin, lightmins, lightmaxs, light, bit, bitindex, ent->model->brush.data_nodes, lightpvs, min(lightpvsbytes * 8, ent->model->brush.num_pvsclusters));
+ }
+ else
+ {
+ msurface_t *surface;
+ for (j = 0, surface = ent->model->brush.data_surfaces + ent->model->firstmodelsurface;j < ent->model->nummodelsurfaces;j++, surface++)
+ {
+ if (BoxesOverlap(surface->mins, surface->maxs, lightmins, lightmaxs))
+ {
+ if (surface->dlightframe != r_framecount) // not dynamic until now
+ {
+ surface->dlightbits[0] = surface->dlightbits[1] = surface->dlightbits[2] = surface->dlightbits[3] = surface->dlightbits[4] = surface->dlightbits[5] = surface->dlightbits[6] = surface->dlightbits[7] = 0;
+ surface->dlightframe = r_framecount;
+ surface->cached_dlight = true;
+ }
+ surface->dlightbits[bitindex] |= bit;
+ }
+ }
+ }