From 7ada10412116cc9625c5191a00fbda7f2c701b0c Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 14 Dec 2010 17:57:32 +0000 Subject: [PATCH] found out why the water plane issue happend: namely, when a water plane is backface culled, R_Water_FindPlane may not find ANY plane. Remove the print, ignore the damage it causes (as the damage only consists of some additional tris being rendered that should not, but instead less batches). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10662 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index a08e3ff8..626762f5 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -12253,13 +12253,20 @@ static int RSurf_FindWaterPlaneForSurface(const msurface_t *surface) vec3_t vert; const float *v; r_waterstate_waterplane_t *p; + qboolean prepared = false; bestd = 0; for (planeindex = 0, p = r_waterstate.waterplanes;planeindex < r_waterstate.numwaterplanes;planeindex++, p++) { if(p->camera_entity != rsurface.texture->camera_entity) continue; d = 0; - RSurf_PrepareVerticesForBatch(BATCHNEED_ARRAY_VERTEX, 1, &surface); + if(!prepared) + { + RSurf_PrepareVerticesForBatch(BATCHNEED_ARRAY_VERTEX, 1, &surface); + prepared = true; + if(rsurface.batchnumvertices == 0) + break; + } for (vertexindex = 0, v = rsurface.batchvertex3f + rsurface.batchfirstvertex * 3;vertexindex < rsurface.batchnumvertices;vertexindex++, v += 3) { Matrix4x4_Transform(&rsurface.matrix, v, vert); @@ -12272,6 +12279,10 @@ static int RSurf_FindWaterPlaneForSurface(const msurface_t *surface) } } return bestplaneindex; + // NOTE: this MAY return a totally unrelated water plane; we can ignore + // this situation though, as it might be better to render single larger + // batches with useless stuff (backface culled for example) than to + // render multiple smaller batches } static void RSurf_DrawBatch_GL11_MakeFullbrightLightmapColorArray(void) @@ -12632,7 +12643,8 @@ static void R_DrawTextureSurfaceList_GL20(int texturenumsurfaces, const msurface startplaneindex = RSurf_FindWaterPlaneForSurface(texturesurfacelist[start]); if(startplaneindex < 0) { - Con_Printf("No matching water plane for surface with material flags 0x%08x - PLEASE DEBUG THIS\n", rsurface.texture->currentmaterialflags); + // this happens if the plane e.g. got backface culled and thus didn't get a water plane. We can just ignore this. + // Con_Printf("No matching water plane for surface with material flags 0x%08x - PLEASE DEBUG THIS\n", rsurface.texture->currentmaterialflags); end = start + 1; continue; } -- 2.39.2