]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rsurf.c
fixed realtime lighting bugs with gl_mesh_batching 1 (... by not using batching while...
[xonotic/darkplaces.git] / gl_rsurf.c
index ad2b93f350a95c224415e45eb38e719fe21eaf6f..84adabbb3a2c8aabf94c0ab7cb969b9f4be05710 100644 (file)
@@ -985,6 +985,10 @@ static void RSurfShader_OpaqueWall_Pass_BaseTripleTexCombine(const entity_render
        rmeshstate_t m;
        int lightmaptexturenum;
        float cl;
+       /*
+       rcachearrayrequest_t request;
+       memset(&request, 0, sizeof(request));
+       */
        memset(&m, 0, sizeof(m));
        m.blendfunc1 = GL_ONE;
        m.blendfunc2 = GL_ZERO;
@@ -997,6 +1001,9 @@ static void RSurfShader_OpaqueWall_Pass_BaseTripleTexCombine(const entity_render
        R_Mesh_State(&m);
        cl = (float) (1 << r_lightmapscalebit) * r_colorscale;
        GL_Color(cl, cl, cl, 1);
+       if (!gl_mesh_copyarrays.integer)
+               R_Mesh_EndBatch();
+
        while((surf = *surfchain++) != NULL)
        {
                if (surf->visframe == r_framecount)
@@ -1005,15 +1012,36 @@ static void RSurfShader_OpaqueWall_Pass_BaseTripleTexCombine(const entity_render
                        if (m.tex[1] != lightmaptexturenum)
                        {
                                m.tex[1] = lightmaptexturenum;
-                               R_Mesh_State(&m);
+                               if (gl_mesh_copyarrays.integer)
+                                       R_Mesh_State(&m);
                        }
                        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
                        {
-                               R_Mesh_GetSpace(mesh->numverts);
-                               R_Mesh_CopyVertex3f(mesh->vertex3f, mesh->numverts);
-                               R_Mesh_CopyTexCoord2f(0, mesh->texcoordtexture2f, mesh->numverts);
-                               R_Mesh_CopyTexCoord2f(1, mesh->texcoordlightmap2f, mesh->numverts);
-                               R_Mesh_CopyTexCoord2f(2, mesh->texcoorddetail2f, mesh->numverts);
+                               if (!gl_mesh_copyarrays.integer)
+                               {
+                                       m.pointervertexcount = mesh->numverts;
+                                       m.pointer_vertex = mesh->vertex3f;
+                                       m.pointer_texcoord[0] = mesh->texcoordtexture2f;
+                                       m.pointer_texcoord[1] = mesh->texcoordlightmap2f;
+                                       m.pointer_texcoord[2] = mesh->texcoorddetail2f;
+                                       /*
+                                       request.id_pointer1 = ent->model;
+                                       request.id_pointer2 = mesh->texcoorddetail2f;
+                                       request.data_size = sizeof(float[2]) * mesh->numverts;
+                                       if (R_Mesh_CacheArray(&request))
+                                               memcpy(request.data, mesh->texcoorddetail2f, request.data_size);
+                                       m.pointer_texcoord[2] = request.data;
+                                       */
+                                       R_Mesh_State(&m);
+                               }
+                               else
+                               {
+                                       R_Mesh_GetSpace(mesh->numverts);
+                                       R_Mesh_CopyVertex3f(mesh->vertex3f, mesh->numverts);
+                                       R_Mesh_CopyTexCoord2f(0, mesh->texcoordtexture2f, mesh->numverts);
+                                       R_Mesh_CopyTexCoord2f(1, mesh->texcoordlightmap2f, mesh->numverts);
+                                       R_Mesh_CopyTexCoord2f(2, mesh->texcoorddetail2f, mesh->numverts);
+                               }
                                R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->element3i);
                        }
                }