mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-23 04:11:53 +00:00
Might as well optimise it while its still present.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3275 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
91da30299d
commit
9ad2588aed
1 changed files with 30 additions and 5 deletions
|
@ -299,10 +299,17 @@ void Q1BSP_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
|||
msurface_t *surf;
|
||||
int i;
|
||||
|
||||
float l, maxdist;
|
||||
int j, s, t;
|
||||
vec3_t impact;
|
||||
|
||||
if (node->contents < 0)
|
||||
return;
|
||||
|
||||
splitplane = node->plane;
|
||||
if (splitplane->type < 3)
|
||||
dist = light->origin[splitplane->type] - splitplane->dist;
|
||||
else
|
||||
dist = DotProduct (light->origin, splitplane->normal) - splitplane->dist;
|
||||
|
||||
if (dist > light->radius)
|
||||
|
@ -316,17 +323,35 @@ void Q1BSP_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
|||
return;
|
||||
}
|
||||
|
||||
maxdist = light->radius*light->radius;
|
||||
|
||||
// mark the polygons
|
||||
surf = currentmodel->surfaces + node->firstsurface;
|
||||
for (i=0 ; i<node->numsurfaces ; i++, surf++)
|
||||
{
|
||||
//Yeah, you can blame LordHavoc for this alternate code here.
|
||||
for (j=0 ; j<3 ; j++)
|
||||
impact[j] = light->origin[j] - surf->plane->normal[j]*dist;
|
||||
|
||||
// clamp center of light to corner and check brightness
|
||||
l = DotProduct (impact, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3] - surf->texturemins[0];
|
||||
s = l+0.5;if (s < 0) s = 0;else if (s > surf->extents[0]) s = surf->extents[0];
|
||||
s = l - s;
|
||||
l = DotProduct (impact, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3] - surf->texturemins[1];
|
||||
t = l+0.5;if (t < 0) t = 0;else if (t > surf->extents[1]) t = surf->extents[1];
|
||||
t = l - t;
|
||||
// compare to minimum light
|
||||
if ((s*s+t*t+dist*dist) < maxdist)
|
||||
{
|
||||
if (surf->dlightframe != r_dlightframecount)
|
||||
{
|
||||
surf->dlightbits = 0;
|
||||
surf->dlightbits = bit;
|
||||
surf->dlightframe = r_dlightframecount;
|
||||
}
|
||||
else
|
||||
surf->dlightbits |= bit;
|
||||
}
|
||||
}
|
||||
|
||||
Q1BSP_MarkLights (light, bit, node->children[0]);
|
||||
Q1BSP_MarkLights (light, bit, node->children[1]);
|
||||
|
|
Loading…
Reference in a new issue