]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fix wrong-texture rendering in stonekeep where a 0-triangles patch
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 13 Nov 2010 12:35:42 +0000 (12:35 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 13 Nov 2010 12:35:42 +0000 (12:35 +0000)
(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

index 4242f8de56082f02b1870ea949b1cbfdbfa27a41..e5dea7c7ecd5c68b869df6fa966886f8b895112d 100644 (file)
@@ -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);
 }