From 146b4e0ae86940ca9191ae9717efe3df97e22717 Mon Sep 17 00:00:00 2001 From: havoc Date: Fri, 23 Feb 2007 12:45:35 +0000 Subject: [PATCH] fixed bug that caused the wrong texture to be used on rtlight lighting when two or more textures were involved in a single batch git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6908 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rsurf.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gl_rsurf.c b/gl_rsurf.c index ff9f78b9..8e9afe8d 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -922,7 +922,7 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface { model_t *model = ent->model; msurface_t *surface; - int i, j, k, l, endsurface, batchnumsurfaces; + int i, k, l, endsurface, batchnumsurfaces; msurface_t *batchsurfacelist[RSURF_MAX_BATCHSURFACES]; texture_t *tex; CHECKGLERROR @@ -933,30 +933,30 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface // fast, and even if this is not the world model (and hence no visibility // checking) the input surface list and batch buffer are different formats // so some processing is necessary. (luckily models have few surfaces) - for (i = 0;i < numsurfaces;i = j) + for (i = 0;i < numsurfaces;) { batchnumsurfaces = 0; endsurface = min(i + RSURF_MAX_BATCHSURFACES, numsurfaces); if (ent == r_refdef.worldentity) { - for (j = i;j < endsurface;j++) - if (r_viewcache.world_surfacevisible[surfacelist[j]]) - batchsurfacelist[batchnumsurfaces++] = model->data_surfaces + surfacelist[j]; + for (;i < endsurface;i++) + if (r_viewcache.world_surfacevisible[surfacelist[i]]) + batchsurfacelist[batchnumsurfaces++] = model->data_surfaces + surfacelist[i]; } else { - for (j = i;j < endsurface;j++) - batchsurfacelist[batchnumsurfaces++] = model->data_surfaces + surfacelist[j]; + for (;i < endsurface;i++) + batchsurfacelist[batchnumsurfaces++] = model->data_surfaces + surfacelist[i]; } if (!batchnumsurfaces) continue; for (k = 0;k < batchnumsurfaces;k = l) { - l = k + 1; surface = batchsurfacelist[k]; tex = surface->texture; rsurface_texture = tex->currentframe; - for (;l < batchnumsurfaces && tex == batchsurfacelist[k]->texture;l++); + for (l = k;l < batchnumsurfaces && tex == batchsurfacelist[l]->texture;l++); + r_refdef.stats.lights_lighttriangles += batchsurfacelist[l]->num_triangles; if (rsurface_texture->currentmaterialflags & (MATERIALFLAG_WALL | MATERIALFLAG_WATER)) { if (rsurface_texture->currentmaterialflags & MATERIALFLAG_BLENDED) -- 2.39.2