]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rsurf.c
changed rtlight compiled cluster list/pvs to leaf list/pvs to enable slightly more...
[xonotic/darkplaces.git] / gl_rsurf.c
index 3a46cbfc070535e68a8214f48a90c5aa24255de7..16e50846b19cbc90e9624b40f92fa603a18c978e 100644 (file)
@@ -469,7 +469,7 @@ static void R_DrawSurfaceList(const entity_render_t *ent, texture_t *texture, in
                                R_Sky();
                }
                // LordHavoc: HalfLife maps have freaky skypolys...
-               if (!ent->model->brush.ishlbsp)
+               //if (!ent->model->brush.ishlbsp)
                {
                        R_Mesh_Matrix(&ent->matrix);
                        GL_Color(fogcolor[0], fogcolor[1], fogcolor[2], 1);
@@ -1593,7 +1593,7 @@ void R_WorldVisibility(void)
                return;
 
        // if possible find the leaf the view origin is in
-       viewleaf = model->brushq1.PointInLeaf ? model->brushq1.PointInLeaf(model, r_vieworigin) : NULL;
+       viewleaf = model->brush.PointInLeaf ? model->brush.PointInLeaf(model, r_vieworigin) : NULL;
        // if possible fetch the visible cluster bits
        if (model->brush.FatPVS)
                model->brush.FatPVS(model, r_vieworigin, 2, r_pvsbits, sizeof(r_pvsbits));
@@ -1700,9 +1700,9 @@ typedef struct r_q1bsp_getlightinfo_s
        model_t *model;
        vec3_t relativelightorigin;
        float lightradius;
-       int *outclusterlist;
-       qbyte *outclusterpvs;
-       int outnumclusters;
+       int *outleaflist;
+       qbyte *outleafpvs;
+       int outnumleafs;
        int *outsurfacelist;
        qbyte *outsurfacepvs;
        int outnumsurfaces;
@@ -1742,12 +1742,13 @@ void R_Q1BSP_RecursiveGetLightInfo(r_q1bsp_getlightinfo_t *info, mnode_t *node)
                info->outmaxs[0] = max(info->outmaxs[0], leaf->maxs[0]);
                info->outmaxs[1] = max(info->outmaxs[1], leaf->maxs[1]);
                info->outmaxs[2] = max(info->outmaxs[2], leaf->maxs[2]);
-               if (info->outclusterpvs)
+               if (info->outleafpvs)
                {
-                       if (!CHECKPVSBIT(info->outclusterpvs, leaf->clusterindex))
+                       int leafindex = leaf - info->model->brush.data_leafs;
+                       if (!CHECKPVSBIT(info->outleafpvs, leafindex))
                        {
-                               SETPVSBIT(info->outclusterpvs, leaf->clusterindex);
-                               info->outclusterlist[info->outnumclusters++] = leaf->clusterindex;
+                               SETPVSBIT(info->outleafpvs, leafindex);
+                               info->outleaflist[info->outnumleafs++] = leafindex;
                        }
                }
                if (info->outsurfacepvs)
@@ -1784,7 +1785,7 @@ void R_Q1BSP_RecursiveGetLightInfo(r_q1bsp_getlightinfo_t *info, mnode_t *node)
        }
 }
 
-void R_Q1BSP_GetLightInfo(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outclusterlist, qbyte *outclusterpvs, int *outnumclusterspointer, int *outsurfacelist, qbyte *outsurfacepvs, int *outnumsurfacespointer)
+void R_Q1BSP_GetLightInfo(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outleaflist, qbyte *outleafpvs, int *outnumleafspointer, int *outsurfacelist, qbyte *outsurfacepvs, int *outnumsurfacespointer)
 {
        r_q1bsp_getlightinfo_t info;
        VectorCopy(relativelightorigin, info.relativelightorigin);
@@ -1799,28 +1800,37 @@ void R_Q1BSP_GetLightInfo(entity_render_t *ent, vec3_t relativelightorigin, floa
        {
                VectorCopy(info.lightmins, outmins);
                VectorCopy(info.lightmaxs, outmaxs);
-               *outnumclusterspointer = 0;
+               *outnumleafspointer = 0;
                *outnumsurfacespointer = 0;
                return;
        }
        info.model = ent->model;
-       info.outclusterlist = outclusterlist;
-       info.outclusterpvs = outclusterpvs;
-       info.outnumclusters = 0;
+       info.outleaflist = outleaflist;
+       info.outleafpvs = outleafpvs;
+       info.outnumleafs = 0;
        info.outsurfacelist = outsurfacelist;
        info.outsurfacepvs = outsurfacepvs;
        info.outnumsurfaces = 0;
        VectorCopy(info.relativelightorigin, info.outmins);
        VectorCopy(info.relativelightorigin, info.outmaxs);
-       memset(outclusterpvs, 0, info.model->brush.num_pvsclusterbytes);
+       memset(outleafpvs, 0, (info.model->brush.num_leafs + 7) >> 3);
        memset(outsurfacepvs, 0, (info.model->nummodelsurfaces + 7) >> 3);
        if (info.model->brush.GetPVS)
                info.pvs = info.model->brush.GetPVS(info.model, info.relativelightorigin);
        else
                info.pvs = NULL;
        R_UpdateAllTextureInfo(ent);
-       // use BSP recursion as lights are often small
-       R_Q1BSP_RecursiveGetLightInfo(&info, info.model->brush.data_nodes);
+       /*
+       if (r_shadow_compilingrtlight)
+       {
+               Portal_Visibility(info.model, info.relativelightorigin, leafmark, surfacemark, const mplane_t *frustumplanes, int numfrustumplanes, int exact, const float *boxmins, const float *boxmaxs, float *updateleafsmins, float *updateleafsmaxs)
+       }
+       else
+       */
+       {
+               // use BSP recursion as lights are often small
+               R_Q1BSP_RecursiveGetLightInfo(&info, info.model->brush.data_nodes);
+       }
 
        // limit combined leaf box to light boundaries
        outmins[0] = max(info.outmins[0], info.lightmins[0]);
@@ -1830,7 +1840,7 @@ void R_Q1BSP_GetLightInfo(entity_render_t *ent, vec3_t relativelightorigin, floa
        outmaxs[1] = min(info.outmaxs[1], info.lightmaxs[1]);
        outmaxs[2] = min(info.outmaxs[2], info.lightmaxs[2]);
 
-       *outnumclusterspointer = info.outnumclusters;
+       *outnumleafspointer = info.outnumleafs;
        *outnumsurfacespointer = info.outnumsurfaces;
 }
 
@@ -1858,7 +1868,7 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin,
        }
 }
 
-void R_Q1BSP_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltolight, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz, rtexture_t *lightcubemap, vec_t ambientscale, vec_t diffusescale, vec_t specularscale, int numsurfaces, const int *surfacelist)
+void R_Q1BSP_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltolight, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz, rtexture_t *lightcubemap, vec_t ambientscale, vec_t diffusescale, vec_t specularscale, int numsurfaces, const int *surfacelist, int visiblelighting)
 {
        model_t *model = ent->model;
        msurface_t *surface;
@@ -1889,7 +1899,7 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t
                                {
                                        if (surface->texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
                                                qglDisable(GL_CULL_FACE);
-                                       R_Shadow_RenderLighting(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle), surface->groupmesh->data_vertex3f, surface->groupmesh->data_svector3f, surface->groupmesh->data_tvector3f, surface->groupmesh->data_normal3f, surface->groupmesh->data_texcoordtexture2f, relativelightorigin, relativeeyeorigin, lightcolor, NULL, NULL, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, t->skin.base, NULL, NULL, t->skin.nmap, t->skin.gloss, lightcubemap, ambientscale, diffusescale, specularscale);
+                                       R_Shadow_RenderLighting(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle), surface->groupmesh->data_vertex3f, surface->groupmesh->data_svector3f, surface->groupmesh->data_tvector3f, surface->groupmesh->data_normal3f, surface->groupmesh->data_texcoordtexture2f, relativelightorigin, relativeeyeorigin, lightcolor, NULL, NULL, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, t->skin.base, NULL, NULL, t->skin.nmap, t->skin.gloss, lightcubemap, ambientscale, diffusescale, specularscale, visiblelighting);
                                        if (surface->texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
                                                qglEnable(GL_CULL_FACE);
                                }