mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-30 12:40:42 +00:00
hopefully more correct surface marking for dlights
This commit is contained in:
parent
6c1c39c4d2
commit
4f79d8ce0a
1 changed files with 18 additions and 30 deletions
|
@ -97,41 +97,29 @@ static inline void
|
||||||
real_mark_surfaces (float dist, msurface_t *surf, const vec3_t lightorigin,
|
real_mark_surfaces (float dist, msurface_t *surf, const vec3_t lightorigin,
|
||||||
dlight_t *light, int bit)
|
dlight_t *light, int bit)
|
||||||
{
|
{
|
||||||
float dist2, d;
|
float dist2, is, it;
|
||||||
float maxdist = light->radius * light->radius;
|
float maxdist = light->radius * light->radius;
|
||||||
vec3_t impact;
|
vec3_t impact;
|
||||||
|
|
||||||
dist2 = dist * dist;
|
dist2 = maxdist - dist * dist;
|
||||||
VectorMultSub (light->origin, dist, surf->plane->normal, impact);
|
VectorMultSub (light->origin, dist, surf->plane->normal, impact);
|
||||||
|
|
||||||
d = DotProduct (impact, surf->texinfo->vecs[0])
|
is = DotProduct (impact, surf->texinfo->vecs[0])
|
||||||
+ surf->texinfo->vecs[0][3] - surf->texturemins[0];
|
+ surf->texinfo->vecs[0][3] - surf->texturemins[0];
|
||||||
if (d < 0) {
|
it = DotProduct (impact, surf->texinfo->vecs[1])
|
||||||
dist2 += d * d;
|
|
||||||
if (dist2 >= maxdist)
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
d -= surf->extents[0] + 16;
|
|
||||||
if (d > 0) {
|
|
||||||
dist2 += d * d;
|
|
||||||
if (dist2 >= maxdist)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
d = DotProduct (impact, surf->texinfo->vecs[1])
|
|
||||||
+ surf->texinfo->vecs[1][3] - surf->texturemins[1];
|
+ surf->texinfo->vecs[1][3] - surf->texturemins[1];
|
||||||
if (d < 0) {
|
|
||||||
dist2 += d * d;
|
// compress the square to a point
|
||||||
if (dist2 >= maxdist)
|
if (is > surf->extents[0])
|
||||||
return;
|
is -= surf->extents[0];
|
||||||
} else {
|
else if (is > 0)
|
||||||
d -= surf->extents[1] + 16;
|
is = 0;
|
||||||
if (d > 0) {
|
if (it > surf->extents[1])
|
||||||
dist2 += d * d;
|
it -= surf->extents[1];
|
||||||
if (dist2 >= maxdist)
|
else if (it > 0)
|
||||||
return;
|
it = 0;
|
||||||
}
|
if (is * is + it * it > dist2)
|
||||||
}
|
return;
|
||||||
|
|
||||||
if (surf->dlightframe != r_framecount) {
|
if (surf->dlightframe != r_framecount) {
|
||||||
surf->dlightbits = 0;
|
surf->dlightbits = 0;
|
||||||
|
@ -149,7 +137,7 @@ mark_surfaces (msurface_t *surf, const vec3_t lightorigin, dlight_t *light,
|
||||||
dist = PlaneDiff(lightorigin, surf->plane);
|
dist = PlaneDiff(lightorigin, surf->plane);
|
||||||
if (surf->flags & SURF_PLANEBACK)
|
if (surf->flags & SURF_PLANEBACK)
|
||||||
dist = -dist;
|
dist = -dist;
|
||||||
if ((dist < -0.25f && !(surf->flags & SURF_LIGHTBOTHSIDES))
|
if ((dist < 0 && !(surf->flags & SURF_LIGHTBOTHSIDES))
|
||||||
|| dist > light->radius)
|
|| dist > light->radius)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue