]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - r_light.c
Added the drawing functions and added also probably menu only message functions
[xonotic/darkplaces.git] / r_light.c
index 6a49a87fcf6fb8e88c10077e913ba3be9ec7a904..c393f558e3a248c81e1a9a517853a912c14d8ab9 100644 (file)
--- a/r_light.c
+++ b/r_light.c
@@ -252,8 +252,7 @@ static void R_RecursiveMarkLights(entity_render_t *ent, vec3_t lightorigin, rdli
                        {
                                surf->dlightbits[0] = surf->dlightbits[1] = surf->dlightbits[2] = surf->dlightbits[3] = surf->dlightbits[4] = surf->dlightbits[5] = surf->dlightbits[6] = surf->dlightbits[7] = 0;
                                surf->dlightframe = r_framecount;
-                               if (r_dlightmap.integer)
-                                       surf->cached_dlight = true;
+                               surf->cached_dlight = true;
                        }
                        surf->dlightbits[bitindex] |= bit;
                }
@@ -365,7 +364,7 @@ static nearlight_t nearlight[MAX_DLIGHTS];
 int R_LightModel(float *ambient4f, float *diffusecolor, float *diffusenormal, const entity_render_t *ent, float colorr, float colorg, float colorb, float colora, int worldcoords)
 {
        int i, j, maxnearlights;
-       float v[3], f, mscale, stylescale, intensity, ambientcolor[3];
+       float v[3], f, mscale, stylescale, intensity, ambientcolor[3], tempdiffusenormal[3];
        nearlight_t *nl;
        mlight_t *sl;
        rdlight_t *rd;
@@ -386,7 +385,11 @@ int R_LightModel(float *ambient4f, float *diffusecolor, float *diffusenormal, co
        else
        {
                if (cl.worldmodel && cl.worldmodel->brush.LightPoint)
-                       cl.worldmodel->brush.LightPoint(cl.worldmodel, ent->origin, ambient4f, diffusecolor, diffusenormal);
+               {
+                       cl.worldmodel->brush.LightPoint(cl.worldmodel, ent->origin, ambient4f, diffusecolor, tempdiffusenormal);
+                       Matrix4x4_Transform3x3(&ent->inversematrix, tempdiffusenormal, diffusenormal);
+                       VectorNormalize(diffusenormal);
+               }
                else
                        VectorSet(ambient4f, 1, 1, 1);
        }
@@ -536,7 +539,9 @@ void R_LightModel_CalcVertexColors(const float *ambientcolor4f, const float *dif
        float color[4], v[3], dot, dist2, f, dnormal[3];
        nearlight_t *nl;
        usediffuse = DotProduct(diffusecolor, diffusecolor) > 0;
-       VectorCopy(diffusenormal, dnormal);
+       // negate the diffuse normal to avoid the need to negate the
+       // dotproduct on each vertex
+       VectorNegate(diffusenormal, dnormal);
        if (usediffuse)
                VectorNormalize(dnormal);
        // directional shading code here