]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - r_light.c
changed brush model API - now uses function pointers for some of the brush model...
[xonotic/darkplaces.git] / r_light.c
index d8708134d3aad0f207ed0e166a01116231270fd6..7da1daa005f448b648ad92b8d80846fbc6684483 100644 (file)
--- a/r_light.c
+++ b/r_light.c
@@ -141,18 +141,11 @@ void R_BuildLightList(void)
 void R_DrawCoronas(void)
 {
        int i;
-       rmeshstate_t m;
-       float scale, viewdist, diff[3], dist;
+       float cscale, scale, viewdist, dist;
        rdlight_t *rd;
        if (!r_coronas.integer)
                return;
-       memset(&m, 0, sizeof(m));
-       m.blendfunc1 = GL_ONE;
-       m.blendfunc2 = GL_ONE;
-       m.depthdisable = true; // magic
-       m.tex[0] = R_GetTexture(lightcorona);
        R_Mesh_Matrix(&r_identitymatrix);
-       R_Mesh_State(&m);
        viewdist = DotProduct(r_origin, vpn);
        for (i = 0;i < r_numdlights;i++)
        {
@@ -160,19 +153,14 @@ void R_DrawCoronas(void)
                dist = (DotProduct(rd->origin, vpn) - viewdist);
                if (dist >= 24.0f && CL_TraceLine(rd->origin, r_origin, NULL, NULL, 0, true, NULL) == 1)
                {
-                       scale = r_colorscale * (1.0f / 131072.0f);
-                       if (gl_flashblend.integer)
-                               scale *= 4.0f;
-                       if (fogenabled)
-                       {
-                               VectorSubtract(rd->origin, r_origin, diff);
-                               scale *= 1 - exp(fogdensity/DotProduct(diff,diff));
-                       }
-                       GL_Color(rd->light[0] * scale, rd->light[1] * scale, rd->light[2] * scale, 1);
+                       cscale = (1.0f / 131072.0f);
                        scale = rd->cullradius * 0.25f;
                        if (gl_flashblend.integer)
+                       {
+                               cscale *= 4.0f;
                                scale *= 2.0f;
-                       R_DrawSpriteMesh(rd->origin, vright, vup, scale, -scale, -scale, scale);
+                       }
+                       R_DrawSprite(GL_ONE, GL_ONE, lightcorona, true, rd->origin, vright, vup, scale, -scale, -scale, scale, rd->light[0] * cscale, rd->light[1] * cscale, rd->light[2] * cscale, 1);
                }
        }
 }
@@ -316,7 +304,7 @@ static void R_VisMarkLights (entity_render_t *ent, rdlight_t *rd, int bit, int b
        Matrix4x4_Transform(&ent->inversematrix, rd->origin, lightorigin);
 
        model = ent->model;
-       pvsleaf = Mod_PointInLeaf (lightorigin, model);
+       pvsleaf = model->PointInLeaf(model, lightorigin);
        if (pvsleaf == NULL)
                return;
 
@@ -592,7 +580,7 @@ void R_CompleteLightPoint (vec3_t color, const vec3_t p, int dynamic, const mlea
        rdlight_t *rd;
        mlight_t *sl;
        if (leaf == NULL)
-               leaf = Mod_PointInLeaf(p, cl.worldmodel);
+               leaf = cl.worldmodel->PointInLeaf(cl.worldmodel, p);
        if (!leaf || leaf->contents == CONTENTS_SOLID || r_fullbright.integer || !cl.worldmodel->lightdata)
        {
                color[0] = color[1] = color[2] = 1;
@@ -693,7 +681,7 @@ int R_LightModel(float *ambient4f, const entity_render_t *ent, float colorr, flo
                ambient4f[3] = colora;
                return false;
        }
-       leaf = Mod_PointInLeaf(ent->origin, cl.worldmodel);
+       leaf = cl.worldmodel->PointInLeaf(cl.worldmodel, ent->origin);
        if (!leaf || leaf->contents == CONTENTS_SOLID || !cl.worldmodel->lightdata)
                ambient4f[0] = ambient4f[1] = ambient4f[2] = 1;
        else