void R_DrawCoronas(void)
{
int i, lnum, flag;
- float cscale, scale, viewdist, dist;
+ float cscale, scale;
dlight_t *light;
rtlight_t *rtlight;
- if (r_coronas.value < 0.01)
+ if (r_coronas.value < (1.0f / 256.0f) && !gl_flashblend.integer)
return;
R_Mesh_Matrix(&identitymatrix);
- viewdist = DotProduct(r_view.origin, r_view.forward);
flag = r_refdef.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE;
// FIXME: these traces should scan all render entities instead of cl.world
for (lnum = 0, light = r_shadow_worldlightchain;light;light = light->next, lnum++)
{
- if ((light->flags & flag) && light->corona * r_coronas.value > 0 && (r_shadow_debuglight.integer < 0 || r_shadow_debuglight.integer == lnum) && (dist = (DotProduct(light->rtlight.shadoworigin, r_view.forward) - viewdist)) >= 24.0f && CL_Move(light->rtlight.shadoworigin, vec3_origin, vec3_origin, r_view.origin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction == 1)
- {
- cscale = light->rtlight.corona * r_coronas.value * 0.25f;
- scale = light->rtlight.radius * light->rtlight.coronasizescale;
- R_DrawSprite(GL_ONE, GL_ONE, lightcorona, NULL, true, light->rtlight.shadoworigin, r_view.right, r_view.up, scale, -scale, -scale, scale, light->rtlight.color[0] * cscale, light->rtlight.color[1] * cscale, light->rtlight.color[2] * cscale, 1);
- }
+ 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 != lnum)
+ continue;
+ cscale = rtlight->corona * r_coronas.value* 0.25f;
+ scale = rtlight->radius * rtlight->coronasizescale;
+ if (VectorDistance2(rtlight->shadoworigin, r_view.origin) < 32.0f * 32.0f)
+ continue;
+ if (CL_Move(rtlight->shadoworigin, vec3_origin, vec3_origin, r_view.origin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction < 1)
+ continue;
+ R_DrawSprite(GL_ONE, GL_ONE, lightcorona, NULL, true, rtlight->shadoworigin, r_view.right, r_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.numlights;i++)
{
rtlight = &r_refdef.lights[i];
- if ((rtlight->flags & flag) && rtlight->corona * r_coronas.value > 0 && (dist = (DotProduct(rtlight->shadoworigin, r_view.forward) - viewdist)) >= 24.0f && CL_Move(rtlight->shadoworigin, vec3_origin, vec3_origin, r_view.origin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction == 1)
+ if (!(rtlight->flags & flag))
+ continue;
+ if (rtlight->corona <= 0)
+ continue;
+ if (VectorDistance2(rtlight->shadoworigin, r_view.origin) < 16.0f * 16.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;
+ cscale = rtlight->corona * r_coronas.value* 0.25f;
scale = rtlight->radius * rtlight->coronasizescale;
- if (gl_flashblend.integer)
- {
- cscale *= 4.0f;
- scale *= 2.0f;
- }
- R_DrawSprite(GL_ONE, GL_ONE, lightcorona, NULL, true, rtlight->shadoworigin, r_view.right, r_view.up, scale, -scale, -scale, scale, rtlight->color[0] * cscale, rtlight->color[1] * cscale, rtlight->color[2] * cscale, 1);
}
+ if (VectorLength(rtlight->color) * cscale < (1.0f / 256.0f))
+ continue;
+ if (CL_Move(rtlight->shadoworigin, vec3_origin, vec3_origin, r_view.origin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction < 1)
+ continue;
+ R_DrawSprite(GL_ONE, GL_ONE, lightcorona, NULL, true, rtlight->shadoworigin, r_view.right, r_view.up, scale, -scale, -scale, scale, rtlight->color[0] * cscale, rtlight->color[1] * cscale, rtlight->color[2] * cscale, 1);
}
}