From fd16101be6eab309ea867ceefddfdd59cb77eef1 Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 22 Feb 2007 14:37:43 +0000 Subject: [PATCH] fixed bug that made some models invisible in nexuiz (if they have skin != 0 and skin 0 was never rendered yet on this model, they were using skin 0, which was often uninitialized) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6898 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 736f722c..c5d0c0d3 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -3762,6 +3762,7 @@ static void R_DrawSurface_TransparentCallback(const entity_render_t *ent, const { int i, j; int texturenumsurfaces, endsurface; + texture_t *texture; msurface_t *surface; msurface_t *texturesurfacelist[1024]; @@ -3777,7 +3778,8 @@ static void R_DrawSurface_TransparentCallback(const entity_render_t *ent, const { j = i + 1; surface = rsurface_model->data_surfaces + surfacelist[i]; - rsurface_texture = surface->texture; + texture = surface->texture; + rsurface_texture = texture->currentframe; rsurface_uselightmaptexture = surface->lightmaptexture != NULL; // scan ahead until we find a different texture endsurface = min(i + 1024, numsurfaces); @@ -3786,7 +3788,7 @@ static void R_DrawSurface_TransparentCallback(const entity_render_t *ent, const for (;j < endsurface;j++) { surface = rsurface_model->data_surfaces + surfacelist[j]; - if (rsurface_texture != surface->texture || rsurface_uselightmaptexture != (surface->lightmaptexture != NULL)) + if (texture != surface->texture || rsurface_uselightmaptexture != (surface->lightmaptexture != NULL)) break; texturesurfacelist[texturenumsurfaces++] = surface; } @@ -3801,11 +3803,17 @@ void R_QueueSurfaceList(int numsurfaces, msurface_t **surfacelist) { int i, j; vec3_t tempcenter, center; + texture_t *texture; // break the surface list down into batches by texture and use of lightmapping for (i = 0;i < numsurfaces;i = j) { j = i + 1; - rsurface_texture = surfacelist[i]->texture; + // texture is the base texture pointer, rsurface_texture is the + // current frame/skin the texture is directing us to use (for example + // if a model has 2 skins and it is on skin 1, then skin 0 tells us to + // use skin 1 instead) + texture = surfacelist[i]->texture; + rsurface_texture = texture->currentframe; rsurface_uselightmaptexture = surfacelist[i]->lightmaptexture != NULL; if (rsurface_texture->currentmaterialflags & MATERIALFLAG_BLENDED) { @@ -3820,7 +3828,7 @@ void R_QueueSurfaceList(int numsurfaces, msurface_t **surfacelist) else { // simply scan ahead until we find a different texture - for (;j < numsurfaces && rsurface_texture == surfacelist[j]->texture && rsurface_uselightmaptexture == (surfacelist[j]->lightmaptexture != NULL);j++); + for (;j < numsurfaces && texture == surfacelist[j]->texture && rsurface_uselightmaptexture == (surfacelist[j]->lightmaptexture != NULL);j++); // render the range of surfaces R_DrawTextureSurfaceList(j - i, surfacelist + i); } @@ -3889,7 +3897,7 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces) // process this surface surface = model->data_surfaces + j; // if this surface fits the criteria, add it to the list - if (surface->texture->currentmaterialflags & flagsmask && surface->num_triangles) + if (surface->texture->basematerialflags & flagsmask && surface->num_triangles) { // if lightmap parameters changed, rebuild lightmap texture if (surface->cached_dlight) @@ -3913,7 +3921,7 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces) for (;surface < endsurface;surface++) { // if this surface fits the criteria, add it to the list - if (surface->texture->currentmaterialflags & flagsmask && surface->num_triangles) + if (surface->texture->basematerialflags & flagsmask && surface->num_triangles) { // if lightmap parameters changed, rebuild lightmap texture if (surface->cached_dlight) -- 2.39.2