]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
found out why the water plane issue happend: namely, when a water plane is backface...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 14 Dec 2010 17:57:32 +0000 (17:57 +0000)
committerRudolf Polzer <divverent@alientrap.org>
Tue, 14 Dec 2010 18:46:59 +0000 (19:46 +0100)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10662 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=7ada10412116cc9625c5191a00fbda7f2c701b0c

gl_rmain.c

index a08e3ff8416f979499b531b74e9e3eb8b3d86d2a..626762f51ddc91735eeaaecdf1e3ce03200cb73e 100644 (file)
@@ -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;
                        }