]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rsurf.c
renamed varray_ arrays to rsurface_array_, and they are no longer used outside the...
[xonotic/darkplaces.git] / gl_rsurf.c
index 69164fb2ef1781ca7030b4fc215825156afd1db2..fc04f2443b9ae6d65f4c2e001e3622103559879d 100644 (file)
@@ -268,9 +268,9 @@ void R_Stain (const vec3_t origin, float radius, int cr1, int cg1, int cb1, int
        R_StainNode(r_refdef.worldmodel->brush.data_nodes + r_refdef.worldmodel->brushq1.hulls[0].firstclipnode, r_refdef.worldmodel, origin, radius, fcolor);
 
        // look for embedded bmodels
-       for (n = 0;n < cl_num_brushmodel_entities;n++)
+       for (n = 0;n < cl.num_brushmodel_entities;n++)
        {
-               ent = &cl_entities[cl_brushmodel_entities[n]].render;
+               ent = &cl.entities[cl.brushmodel_entities[n]].render;
                model = ent->model;
                if (model && model->name[0] == '*')
                {
@@ -295,16 +295,20 @@ void R_Stain (const vec3_t origin, float radius, int cr1, int cg1, int cb1, int
 static void R_DrawPortal_Callback(const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight)
 {
        const mportal_t *portal = (mportal_t *)ent;
-       int i;
+       int i, numpoints;
        float *v;
        rmeshstate_t m;
+       float vertex3f[POLYGONELEMENTS_MAXPOINTS*3];
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        GL_DepthMask(false);
        GL_DepthTest(true);
+       qglDisable(GL_CULL_FACE);
        R_Mesh_Matrix(&identitymatrix);
 
+       numpoints = min(portal->numpoints, POLYGONELEMENTS_MAXPOINTS);
+
        memset(&m, 0, sizeof(m));
-       m.pointer_vertex = varray_vertex3f;
+       m.pointer_vertex = vertex3f;
        R_Mesh_State(&m);
 
        i = surfacenumber;
@@ -312,17 +316,10 @@ static void R_DrawPortal_Callback(const entity_render_t *ent, int surfacenumber,
                         ((i & 0x0038) >> 3) * (1.0f / 7.0f),
                         ((i & 0x01C0) >> 6) * (1.0f / 7.0f),
                         0.125f);
-       if (PlaneDiff(r_vieworigin, (&portal->plane)) < 0)
-       {
-               for (i = portal->numpoints - 1, v = varray_vertex3f;i >= 0;i--, v += 3)
-                       VectorCopy(portal->points[i].position, v);
-       }
-       else
-               for (i = 0, v = varray_vertex3f;i < portal->numpoints;i++, v += 3)
-                       VectorCopy(portal->points[i].position, v);
-       GL_LockArrays(0, portal->numpoints);
-       R_Mesh_Draw(0, portal->numpoints, portal->numpoints - 2, polygonelements);
-       GL_LockArrays(0, 0);
+       for (i = 0, v = vertex3f;i < numpoints;i++, v += 3)
+               VectorCopy(portal->points[i].position, v);
+       R_Mesh_Draw(0, numpoints, numpoints - 2, polygonelements);
+       qglEnable(GL_CULL_FACE);
 }
 
 // LordHavoc: this is just a nice debugging tool, very slow
@@ -693,7 +690,7 @@ void R_Q1BSP_CompileShadowVolume(entity_render_t *ent, vec3_t relativelightorigi
        int surfacelistindex;
        float projectdistance = lightradius + model->radius*2 + r_shadow_projectdistance.value;
        texture_t *texture;
-       r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Begin(r_shadow_mempool, 32768, 32768, NULL, NULL, NULL, false, false, true);
+       r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Begin(r_main_mempool, 32768, 32768, NULL, NULL, NULL, false, false, true);
        R_Shadow_PrepareShadowMark(model->brush.shadowmesh->numtriangles);
        for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
        {
@@ -706,14 +703,14 @@ void R_Q1BSP_CompileShadowVolume(entity_render_t *ent, vec3_t relativelightorigi
                R_Shadow_MarkVolumeFromBox(surface->num_firstshadowmeshtriangle, surface->num_triangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, relativelightorigin, r_shadow_compilingrtlight->cullmins, r_shadow_compilingrtlight->cullmaxs, surface->mins, surface->maxs);
        }
        R_Shadow_VolumeFromList(model->brush.shadowmesh->numverts, model->brush.shadowmesh->numtriangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, model->brush.shadowmesh->neighbor3i, relativelightorigin, lightradius + model->radius + projectdistance, numshadowmark, shadowmarklist);
-       r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Finish(r_shadow_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, false, false);
+       r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Finish(r_main_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, false, false);
 }
 
 extern float *rsurface_vertex3f;
 extern float *rsurface_svector3f;
 extern float *rsurface_tvector3f;
 extern float *rsurface_normal3f;
-extern void RSurf_SetVertexPointer(const entity_render_t *ent, const texture_t *texture, const msurface_t *surface, const vec3_t modelorg);
+extern void RSurf_SetVertexPointer(const entity_render_t *ent, const texture_t *texture, const msurface_t *surface, const vec3_t modelorg, qboolean generatenormals, qboolean generatetangents);
 
 void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, int numsurfaces, const int *surfacelist, const vec3_t lightmins, const vec3_t lightmaxs)
 {
@@ -753,7 +750,7 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin,
                        texture = surface->texture;//R_FetchAliasSkin(ent, surface->groupmesh);
                        if (texture->currentmaterialflags & (MATERIALFLAG_NODRAW | MATERIALFLAG_TRANSPARENT) || !surface->num_triangles)
                                continue;
-                       RSurf_SetVertexPointer(ent, texture, surface, modelorg);
+                       RSurf_SetVertexPointer(ent, texture, surface, modelorg, false, false);
                        // identify lit faces within the bounding box
                        R_Shadow_PrepareShadowMark(surface->groupmesh->num_triangles);
                        R_Shadow_MarkVolumeFromBox(surface->num_firsttriangle, surface->num_triangles, rsurface_vertex3f, surface->groupmesh->data_element3i, relativelightorigin, lightmins, lightmaxs, surface->mins, surface->maxs);