]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rsurf.c
add comments so I know which plane type is which
[xonotic/darkplaces.git] / gl_rsurf.c
index 554fb0fa2cbeccba0ee61346bf42ff791b7d30ad..bd084c162aba448d2def27aadf258cc24435e1a4 100644 (file)
@@ -349,10 +349,7 @@ static void R_DrawPortal_Callback(const entity_render_t *ent, const rtlight_t *r
 
        numpoints = min(portal->numpoints, POLYGONELEMENTS_MAXPOINTS);
 
-       R_Mesh_VertexPointer(vertex3f, 0, 0);
-       R_Mesh_ColorPointer(NULL, 0, 0);
        R_Mesh_ResetTextureState();
-       R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
 
        isvis = (portal->here->clusterindex >= 0 && portal->past->clusterindex >= 0 && portal->here->clusterindex != portal->past->clusterindex);
 
@@ -363,7 +360,9 @@ static void R_DrawPortal_Callback(const entity_render_t *ent, const rtlight_t *r
                         isvis ? 0.125f : 0.03125f);
        for (i = 0, v = vertex3f;i < numpoints;i++, v += 3)
                VectorCopy(portal->points[i].position, v);
-       R_Mesh_Draw(0, numpoints, 0, numpoints - 2, polygonelement3i, polygonelement3s, 0, 0);
+       R_Mesh_PrepareVertices_Generic_Arrays(numpoints, vertex3f, NULL, NULL);
+       R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
+       R_Mesh_Draw(0, numpoints, 0, numpoints - 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0);
 }
 
 // LordHavoc: this is just a nice debugging tool, very slow
@@ -611,7 +610,6 @@ void R_Q1BSP_DrawDepth(entity_render_t *ent)
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_DepthMask(true);
        GL_AlphaTest(false);
-       R_Mesh_ColorPointer(NULL, 0, 0);
        R_Mesh_ResetTextureState();
        R_SetupShader_DepthOrShadow();
        if (ent == r_refdef.scene.worldentity)
@@ -739,7 +737,7 @@ static void R_Q1BSP_RecursiveGetLightInfo(r_q1bsp_getlightinfo_t *info, mnode_t
                        if (SVBSP_AddPolygon(&r_svbsp, portal->numpoints, points[0], false, NULL, NULL, 0) & 2)
                                break;
                }
-               if (portal == NULL)
+               if (leaf->portals && portal == NULL)
                        return; // no portals of this leaf visible
        }
        if (info->svbsp_insertoccluder)
@@ -1086,10 +1084,9 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, const vec3_t relativelightor
                        rsurface.texture = R_GetCurrentTexture(surface->texture);
                        if (rsurface.texture->currentmaterialflags & MATERIALFLAG_NOSHADOW)
                                continue;
-                       RSurf_PrepareVerticesForBatch(false, false, 1, &surface);
-                       R_Shadow_MarkVolumeFromBox(surface->num_firsttriangle, surface->num_triangles, rsurface.vertex3f, rsurface.modelelement3i, relativelightorigin, relativelightdirection, lightmins, lightmaxs, surface->mins, surface->maxs);
+                       R_Shadow_MarkVolumeFromBox(surface->num_firsttriangle, surface->num_triangles, rsurface.modelvertex3f, rsurface.modelelement3i, relativelightorigin, relativelightdirection, lightmins, lightmaxs, surface->mins, surface->maxs);
                }
-               R_Shadow_VolumeFromList(model->surfmesh.num_vertices, model->surfmesh.num_triangles, rsurface.vertex3f, model->surfmesh.data_element3i, model->surfmesh.data_neighbor3i, relativelightorigin, relativelightdirection, projectdistance, numshadowmark, shadowmarklist, ent->mins, ent->maxs);
+               R_Shadow_VolumeFromList(model->surfmesh.num_vertices, model->surfmesh.num_triangles, rsurface.modelvertex3f, model->surfmesh.data_element3i, model->surfmesh.data_neighbor3i, relativelightorigin, relativelightdirection, projectdistance, numshadowmark, shadowmarklist, ent->mins, ent->maxs);
        }
        if (ent->model->brush.submodel)
                GL_PolygonOffset(r_refdef.shadowpolygonfactor, r_refdef.shadowpolygonoffset);
@@ -1159,8 +1156,9 @@ void R_Q1BSP_DrawShadowMap(int side, entity_render_t *ent, const vec3_t relative
                }
                --modelsurfacelistindex;
                GL_CullFace(rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE ? GL_NONE : r_refdef.view.cullface_back);
-               RSurf_PrepareVerticesForBatch(false, false, batchnumsurfaces, batchsurfacelist);
-               RSurf_DrawBatch_Simple(batchnumsurfaces, batchsurfacelist);
+               RSurf_PrepareVerticesForBatch(BATCHNEED_VERTEXPOSITION, batchnumsurfaces, batchsurfacelist);
+               R_Mesh_PrepareVertices_Position(rsurface.batchnumvertices, rsurface.batchvertexposition, rsurface.batchvertexpositionbuffer);
+               RSurf_DrawBatch();
        }
 }
 
@@ -1171,7 +1169,7 @@ static void R_Q1BSP_DrawLight_TransparentCallback(const entity_render_t *ent, co
        int i, j, endsurface;
        texture_t *t;
        const msurface_t *surface;
-       // note: in practice this never actually receives batches), oh well
+       // note: in practice this never actually receives batches
        R_Shadow_RenderMode_Begin();
        R_Shadow_RenderMode_ActiveLight(rtlight);
        R_Shadow_RenderMode_Lighting(false, true, false);
@@ -1188,8 +1186,7 @@ static void R_Q1BSP_DrawLight_TransparentCallback(const entity_render_t *ent, co
                        surface = rsurface.modelsurfaces + surfacelist[j];
                        if (t != surface->texture)
                                break;
-                       RSurf_PrepareVerticesForBatch(true, true, 1, &surface);
-                       R_Shadow_RenderLighting(surface->num_firstvertex, surface->num_vertices, surface->num_firsttriangle, surface->num_triangles, ent->model->surfmesh.data_element3i, ent->model->surfmesh.data_element3s, ent->model->surfmesh.ebo3i, ent->model->surfmesh.ebo3s);
+                       R_Shadow_RenderLighting(1, &surface);
                }
        }
        R_Shadow_RenderMode_End();
@@ -1200,9 +1197,9 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface
 {
        dp_model_t *model = ent->model;
        const msurface_t *surface;
-       int i, k, kend, l, m, mend, endsurface, batchnumsurfaces, batchnumtriangles, batchfirstvertex, batchlastvertex, batchfirsttriangle;
+       int i, k, kend, l, endsurface, batchnumsurfaces, texturenumsurfaces;
+       const msurface_t **texturesurfacelist;
        const int *element3i;
-       static int batchelements[BATCHSIZE*3];
        texture_t *tex;
        CHECKGLERROR
        element3i = rsurface.modelelement3i;
@@ -1256,45 +1253,9 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface
                        }
                        if (r_shadow_usingdeferredprepass)
                                continue;
-                       batchnumtriangles = 0;
-                       batchfirsttriangle = surface->num_firsttriangle;
-                       m = 0; // hush warning
-                       for (l = k;l < kend;l++)
-                       {
-                               surface = batchsurfacelist[l];
-                               RSurf_PrepareVerticesForBatch(true, true, 1, &surface);
-                               for (m = surface->num_firsttriangle, mend = m + surface->num_triangles;m < mend;m++)
-                               {
-                                       if (lighttrispvs && r_test.integer && !CHECKPVSBIT(lighttrispvs, m))
-                                               continue;
-                                       if (batchnumtriangles >= BATCHSIZE)
-                                       {
-                                               r_refdef.stats.lights_lighttriangles += batchnumtriangles;
-                                               Mod_VertexRangeFromElements(batchnumtriangles*3, batchelements, &batchfirstvertex, &batchlastvertex);
-                                               // use the element buffer if all triangles are consecutive
-                                               if (m == batchfirsttriangle + batchnumtriangles)
-                                                       R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, batchfirsttriangle, batchnumtriangles, ent->model->surfmesh.data_element3i, ent->model->surfmesh.data_element3s, ent->model->surfmesh.ebo3i, ent->model->surfmesh.ebo3s);
-                                               else
-                                                       R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, 0, batchnumtriangles, batchelements, NULL, 0, 0);
-                                               batchnumtriangles = 0;
-                                               batchfirsttriangle = m;
-                                       }
-                                       batchelements[batchnumtriangles*3+0] = element3i[m*3+0];
-                                       batchelements[batchnumtriangles*3+1] = element3i[m*3+1];
-                                       batchelements[batchnumtriangles*3+2] = element3i[m*3+2];
-                                       batchnumtriangles++;
-                               }
-                       }
-                       if (batchnumtriangles > 0)
-                       {
-                               r_refdef.stats.lights_lighttriangles += batchnumtriangles;
-                               Mod_VertexRangeFromElements(batchnumtriangles*3, batchelements, &batchfirstvertex, &batchlastvertex);
-                               // use the element buffer if all triangles are consecutive
-                               if (m == batchfirsttriangle + batchnumtriangles)
-                                       R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, batchfirsttriangle, batchnumtriangles, ent->model->surfmesh.data_element3i, ent->model->surfmesh.data_element3s, ent->model->surfmesh.ebo3i, ent->model->surfmesh.ebo3s);
-                               else
-                                       R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, 0, batchnumtriangles, batchelements, NULL, 0, 0);
-                       }
+                       texturenumsurfaces = kend - k;
+                       texturesurfacelist = batchsurfacelist + k;
+                       R_Shadow_RenderLighting(texturenumsurfaces, texturesurfacelist);
                }
        }
 }
@@ -1309,8 +1270,7 @@ void R_ReplaceWorldTexture (void)
        skinframe_t *skinframe;
        if (!r_refdef.scene.worldmodel)
        {
-               if (gamemode != GAME_BLOODOMNICIDE)
-                       Con_Printf("There is no worldmodel\n");
+               Con_Printf("There is no worldmodel\n");
                return;
        }
        m = r_refdef.scene.worldmodel;
@@ -1323,8 +1283,7 @@ void R_ReplaceWorldTexture (void)
        }
        if(!cl.islocalgame || !cl.worldmodel)
        {
-               if (gamemode != GAME_BLOODOMNICIDE)
-                       Con_Print("This command works only in singleplayer\n");
+               Con_Print("This command works only in singleplayer\n");
                return;
        }
        r = Cmd_Argv(1);
@@ -1340,13 +1299,11 @@ void R_ReplaceWorldTexture (void)
 //                             t->skinframes[0] = skinframe;
                                t->currentskinframe = skinframe;
                                t->currentskinframe = skinframe;
-                               if (gamemode != GAME_BLOODOMNICIDE)
-                                       Con_Printf("%s replaced with %s\n", r, newt);
+                               Con_Printf("%s replaced with %s\n", r, newt);
                        }
                        else
                        {
-                               if (gamemode != GAME_BLOODOMNICIDE)
-                                       Con_Printf("%s was not found\n", newt);
+                               Con_Printf("%s was not found\n", newt);
                                return;
                        }
                }