rd->cullradius2 = (2048.0f * 2048.0f);
rd->cullradius = sqrt(rd->cullradius2);
rd->subtract = 1.0f / rd->cullradius2;
- //rd->ent = cd->ent;
+ rd->ent = cd->ent;
c_dlights++; // count every dlight in use
}
}
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_ONE;
m.blendfunc2 = GL_ONE;
- m.wantoverbright = false;
m.depthdisable = true; // magic
m.tex[0] = R_GetTexture(lightcorona);
- Matrix4x4_CreateIdentity(&m.matrix);
+ R_Mesh_Matrix(&r_identitymatrix);
R_Mesh_State(&m);
viewdist = DotProduct(r_origin, vpn);
for (i = 0;i < r_numdlights;i++)
{
rd = r_dlight + i;
dist = (DotProduct(rd->origin, vpn) - viewdist);
- if (dist >= 24.0f && CL_TraceLine(rd->origin, r_origin, NULL, NULL, 0, true) == 1)
+ if (dist >= 24.0f && CL_TraceLine(rd->origin, r_origin, NULL, NULL, 0, true, NULL) == 1)
{
- scale = mesh_colorscale * (1.0f / 131072.0f);
+ scale = r_colorscale * (1.0f / 131072.0f);
if (gl_flashblend.integer)
scale *= 4.0f;
if (fogenabled)
VectorSubtract(rd->origin, r_origin, diff);
scale *= 1 - exp(fogdensity/DotProduct(diff,diff));
}
- varray_element[0] = 0;
- varray_element[1] = 1;
- varray_element[2] = 2;
- varray_element[3] = 0;
- varray_element[4] = 2;
- varray_element[5] = 3;
varray_color[ 0] = varray_color[ 4] = varray_color[ 8] = varray_color[12] = rd->light[0] * scale;
varray_color[ 1] = varray_color[ 5] = varray_color[ 9] = varray_color[13] = rd->light[1] * scale;
varray_color[ 2] = varray_color[ 6] = varray_color[10] = varray_color[14] = rd->light[2] * scale;
varray_vertex[12] = rd->origin[0] + vright[0] * scale - vup[0] * scale;
varray_vertex[13] = rd->origin[1] + vright[1] * scale - vup[1] * scale;
varray_vertex[14] = rd->origin[2] + vright[2] * scale - vup[2] * scale;
- R_Mesh_Draw(4, 2);
+ R_Mesh_Draw(4, 2, polygonelements);
}
}
}
R_MarkLights
=============
*/
+extern int r_pvsframecount;
static void R_OldMarkLights (entity_render_t *ent, vec3_t lightorigin, rdlight_t *rd, int bit, int bitindex, mnode_t *node)
{
float ndist, maxdist;
msurface_t *surf;
- int i;
+ int i, *surfacepvsframes;
int d, impacts, impactt;
float dist, dist2, impact[3];
// for comparisons to minimum acceptable light
maxdist = rd->cullradius2;
+ surfacepvsframes = ent->model->surfacepvsframes;
loc0:
if (node->contents < 0)
return;
surf = ent->model->surfaces + node->firstsurface;
for (i = 0;i < node->numsurfaces;i++, surf++)
{
- if (surf->visframe != r_framecount)
+ if (surfacepvsframes[surf->number] != r_pvsframecount)
continue;
dist = ndist;
if (surf->flags & SURF_PLANEBACK)
mleaf_t *pvsleaf;
vec3_t lightorigin;
model_t *model;
- int i, k, m, c, leafnum;
- msurface_t *surf, **mark;
+ int i, k, m, c, leafnum, *surfacepvsframes, *mark;
+ msurface_t *surf;
mleaf_t *leaf;
qbyte *in;
int row;
maxdist = rd->cullradius2;
row = (model->numleafs+7)>>3;
+ surfacepvsframes = model->surfacepvsframes;
k = 0;
while (k < row)
mark = leaf->firstmarksurface;
do
{
- surf = *mark++;
+ surf = model->surfaces + *mark++;
// if not visible in current frame, or already marked because it was in another leaf we passed, skip
if (surf->lightframe == lightframe)
continue;
surf->lightframe = lightframe;
- if (surf->visframe != r_framecount)
+ if (surfacepvsframes[surf->number] != r_pvsframecount)
continue;
dist = PlaneDiff(lightorigin, surf->plane);
if (surf->flags & SURF_PLANEBACK)
{
VectorSubtract (p, sl->origin, v);
f = ((1.0f / (DotProduct(v, v) * sl->falloff + sl->distbias)) - sl->subtract);
- if (f > 0 && CL_TraceLine(p, sl->origin, NULL, NULL, 0, false) == 1)
+ if (f > 0 && CL_TraceLine(p, sl->origin, NULL, NULL, 0, false, NULL) == 1)
{
f *= d_lightstylevalue[sl->style] * (1.0f / 65536.0f);
VectorMA(color, f, sl->light, color);
rd = r_dlight + i;
VectorSubtract (p, rd->origin, v);
f = DotProduct(v, v);
- if (f < rd->cullradius2 && CL_TraceLine(p, rd->origin, NULL, NULL, 0, false) == 1)
+ if (f < rd->cullradius2 && CL_TraceLine(p, rd->origin, NULL, NULL, 0, false, NULL) == 1)
{
f = (1.0f / (f + LIGHTOFFSET)) - rd->subtract;
VectorMA(color, f, rd->light, color);
VectorSubtract (v, rd->origin, v);
if (DotProduct(v, v) < rd->cullradius2)
{
- if (CL_TraceLine(ent->origin, rd->origin, NULL, NULL, 0, false) != 1)
+ if (CL_TraceLine(ent->origin, rd->origin, NULL, NULL, 0, false, NULL) != 1)
continue;
VectorSubtract (ent->origin, rd->origin, v);
f = ((1.0f / (DotProduct(v, v) + LIGHTOFFSET)) - rd->subtract);
ent->numentlights = 0;
if (cl.worldmodel)
for (i = 0, sl = cl.worldmodel->lights;i < cl.worldmodel->numlights && ent->numentlights < MAXENTLIGHTS;i++, sl++)
- if (CL_TraceLine(ent->origin, sl->origin, NULL, NULL, 0, false) == 1)
+ if (CL_TraceLine(ent->origin, sl->origin, NULL, NULL, 0, false, NULL) == 1)
ent->entlights[ent->numentlights++] = i;
}
ent->entlightsframe = r_framecount;