]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
restore the active rtlights check in bouncegrid
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Mar 2011 10:47:53 +0000 (10:47 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Mar 2011 10:47:53 +0000 (10:47 +0000)
memset the bouncegrid settings struct to make it consistently pass the
memcmp check even if some bytes are not set
improved bouncegrid dynamic mode size check to compare pixel count
rather than individual dimensions

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10976 d7cf8633-e32d-0410-b094-e92efae38249

r_shadow.c

index 7df13bfd8011136f1b8cf2aca037724cdf647014..fe18da6149d4ab2db21505743b0e4e5cb650ec68 100644 (file)
@@ -2386,6 +2386,28 @@ static void R_Shadow_UpdateBounceGridTexture(void)
 
        r_shadow_bouncegridintensity = r_shadow_bouncegrid_intensity.value;
 
+       // see if there are really any lights to render...
+       if (enable && r_shadow_bouncegrid_static.integer)
+       {
+               enable = false;
+               range = Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray); // checked
+               for (lightindex = 0;lightindex < range;lightindex++)
+               {
+                       light = (dlight_t *) Mem_ExpandableArray_RecordAtIndex(&r_shadow_worldlightsarray, lightindex);
+                       if (!light || !(light->flags & flag))
+                               continue;
+                       rtlight = &light->rtlight;
+                       // when static, we skip styled lights because they tend to change...
+                       if (rtlight->style > 0)
+                               continue;
+                       VectorScale(rtlight->color, (rtlight->ambientscale + rtlight->diffusescale + rtlight->specularscale), lightcolor);
+                       if (!VectorLength2(lightcolor))
+                               continue;
+                       enable = true;
+                       break;
+               }
+       }
+
        if (!enable)
        {
                if (r_shadow_bouncegridtexture)
@@ -2405,6 +2427,7 @@ static void R_Shadow_UpdateBounceGridTexture(void)
        }
 
        // build up a complete collection of the desired settings, so that memcmp can be used to compare parameters
+       memset(&settings, 0, sizeof(settings));
        settings.staticmode                    = r_shadow_bouncegrid_static.integer != 0;
        settings.bounceanglediffuse            = r_shadow_bouncegrid_bounceanglediffuse.integer != 0;
        settings.directionalshading            = (r_shadow_bouncegrid_static.integer != 0 ? r_shadow_bouncegrid_static_directionalshading.integer != 0 : r_shadow_bouncegrid_directionalshading.integer != 0) && allowdirectionalshading;
@@ -2466,7 +2489,7 @@ static void R_Shadow_UpdateBounceGridTexture(void)
 
        // if dynamic we may or may not want to use the world bounds
        // if the dynamic size is smaller than the world bounds, use it instead
-       if (!settings.staticmode && (r_shadow_bouncegrid_x.integer < resolution[0] || r_shadow_bouncegrid_y.integer < resolution[1] || r_shadow_bouncegrid_z.integer < resolution[2]))
+       if (!settings.staticmode && (r_shadow_bouncegrid_x.integer * r_shadow_bouncegrid_y.integer * r_shadow_bouncegrid_z.integer < resolution[0] * resolution[1] * resolution[2]))
        {
                // we know the resolution we want
                c[0] = r_shadow_bouncegrid_x.integer;