]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - r_shadow.c
suppress shadow entities when preparing an rtlight with shadows
[xonotic/darkplaces.git] / r_shadow.c
index c183be35e4de69a5f5229a6c440add86008aaf80..a5f34d5badc47948a843fee762c36383c737cf02 100644 (file)
@@ -3933,6 +3933,7 @@ static void R_Shadow_PrepareLight(rtlight_t *rtlight)
        static entity_render_t *shadowentities[MAX_EDICTS];
        static entity_render_t *shadowentities_noselfshadow[MAX_EDICTS];
        qboolean nolight;
+       qboolean castshadows;
 
        rtlight->draw = false;
        rtlight->cached_numlightentities               = 0;
@@ -4128,6 +4129,11 @@ static void R_Shadow_PrepareLight(rtlight_t *rtlight)
        // flag it as worth drawing later
        rtlight->draw = true;
 
+       // if we have shadows disabled, don't count the shadow entities, this way we don't do the R_AnimCache_GetEntity on each one
+       castshadows = numsurfaces + numshadowentities + numshadowentities_noselfshadow > 0 && rtlight->shadow && (rtlight->isstatic ? r_refdef.scene.rtworldshadows : r_refdef.scene.rtdlightshadows);
+       if (!castshadows)
+               numshadowentities = numshadowentities_noselfshadow = 0;
+
        // cache all the animated entities that cast a shadow but are not visible
        for (i = 0;i < numshadowentities;i++)
                R_AnimCache_GetEntity(shadowentities[i], false, false);