+void R_DrawCoronas(void)
+{
+ int i, flag;
+ float cscale, scale;
+ size_t lightindex;
+ dlight_t *light;
+ rtlight_t *rtlight;
+ if (r_coronas.value < (1.0f / 256.0f) && !gl_flashblend.integer)
+ return;
+ R_Mesh_Matrix(&identitymatrix);
+ flag = r_refdef.scene.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE;
+ // FIXME: these traces should scan all render entities instead of cl.world
+ for (lightindex = 0;lightindex < Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray);lightindex++)
+ {
+ light = Mem_ExpandableArray_RecordAtIndex(&r_shadow_worldlightsarray, lightindex);
+ if (!light)
+ continue;
+ rtlight = &light->rtlight;
+ if (!(rtlight->flags & flag))
+ continue;
+ if (rtlight->corona * r_coronas.value <= 0)
+ continue;
+ if (r_shadow_debuglight.integer >= 0 && r_shadow_debuglight.integer != (int)lightindex)
+ continue;
+ cscale = rtlight->corona * r_coronas.value* 0.25f;
+ scale = rtlight->radius * rtlight->coronasizescale;
+ if (VectorDistance2(rtlight->shadoworigin, r_refdef.view.origin) < 16.0f * 16.0f)
+ continue;
+ if (CL_Move(r_refdef.view.origin, vec3_origin, vec3_origin, rtlight->shadoworigin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction < 1)
+ continue;
+ R_DrawSprite(GL_ONE, GL_ONE, r_shadow_lightcorona, NULL, true, false, rtlight->shadoworigin, r_refdef.view.right, r_refdef.view.up, scale, -scale, -scale, scale, rtlight->color[0] * cscale, rtlight->color[1] * cscale, rtlight->color[2] * cscale, 1);
+ }
+ for (i = 0;i < r_refdef.scene.numlights;i++)
+ {
+ rtlight = &r_refdef.scene.lights[i];
+ if (!(rtlight->flags & flag))
+ continue;
+ if (rtlight->corona <= 0)
+ continue;
+ if (VectorDistance2(rtlight->shadoworigin, r_refdef.view.origin) < 32.0f * 32.0f)
+ continue;
+ if (gl_flashblend.integer)
+ {
+ cscale = rtlight->corona * 1.0f;
+ scale = rtlight->radius * rtlight->coronasizescale * 2.0f;
+ }
+ else
+ {
+ cscale = rtlight->corona * r_coronas.value* 0.25f;
+ scale = rtlight->radius * rtlight->coronasizescale;
+ }
+ if (VectorLength(rtlight->color) * cscale < (1.0f / 256.0f))
+ continue;
+ if (CL_Move(r_refdef.view.origin, vec3_origin, vec3_origin, rtlight->shadoworigin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction < 1)
+ continue;
+ R_DrawSprite(GL_ONE, GL_ONE, r_shadow_lightcorona, NULL, true, false, rtlight->shadoworigin, r_refdef.view.right, r_refdef.view.up, scale, -scale, -scale, scale, rtlight->color[0] * cscale, rtlight->color[1] * cscale, rtlight->color[2] * cscale, 1);
+ }
+}
+
+