From ccfa5ab3fc1504e94dbefefe3e0125197a891e8c Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 13 Nov 2010 12:35:42 +0000 Subject: [PATCH] fix wrong-texture rendering in stonekeep where a 0-triangles patch (probably degenerate) was causing the surface batcher to give up early, and render the previous batch instead (drawing over a perfectly good piece of geometry with the wrong texture...) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10593 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 4242f8de..e5dea7c7 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -11402,8 +11402,6 @@ void RSurf_PrepareVerticesForBatch(int batchneed, int texturenumsurfaces, const endvertex = surfaceendvertex; numtriangles += surfacenumtriangles; } - if (!numtriangles) - return; // we now know the vertex range used, and if there are any gaps in it rsurface.batchfirstvertex = firstvertex; @@ -12194,6 +12192,30 @@ void RSurf_PrepareVerticesForBatch(int batchneed, int texturenumsurfaces, const void RSurf_DrawBatch(void) { +#if 0 + // batch debugging code + if (r_test.integer && rsurface.entity == r_refdef.scene.worldentity && rsurface.batchvertex3f == r_refdef.scene.worldentity->model->surfmesh.data_vertex3f) + { + int i; + int j; + int c; + const int *e; + e = rsurface.batchelement3i + rsurface.batchfirsttriangle*3; + for (i = 0;i < rsurface.batchnumtriangles*3;i++) + { + c = e[i]; + for (j = 0;j < rsurface.entity->model->num_surfaces;j++) + { + if (c >= rsurface.modelsurfaces[j].num_firstvertex && c < (rsurface.modelsurfaces[j].num_firstvertex + rsurface.modelsurfaces[j].num_vertices)) + { + if (rsurface.modelsurfaces[j].texture != rsurface.texture) + Sys_Error("RSurf_DrawBatch: index %i uses different texture (%s) than surface %i which it belongs to (which uses %s)\n", c, rsurface.texture->name, j, rsurface.modelsurfaces[j].texture->name); + break; + } + } + } + } +#endif R_Mesh_Draw(rsurface.batchfirstvertex, rsurface.batchnumvertices, rsurface.batchfirsttriangle, rsurface.batchnumtriangles, rsurface.batchelement3i, rsurface.batchelement3i_indexbuffer, rsurface.batchelement3i_bufferoffset, rsurface.batchelement3s, rsurface.batchelement3s_indexbuffer, rsurface.batchelement3s_bufferoffset); } -- 2.39.2