mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
Bugfix - make dlights move correctly with respect to moving bsp entities, instead of the light being in the wrong place.
Obviously this doesn't affect baked lights, but at least mappers have more control over those.
This commit is contained in:
parent
9d1c386a1b
commit
f6d31e9db9
4 changed files with 18 additions and 12 deletions
|
@ -166,7 +166,7 @@ DYNAMIC LIGHTS
|
|||
R_MarkLights -- johnfitz -- rewritten to use LordHavoc's lighting speedup
|
||||
=============
|
||||
*/
|
||||
void R_MarkLights (dlight_t *light, int num, mnode_t *node)
|
||||
void R_MarkLights (dlight_t *light, vec3_t lightorg, int num, mnode_t *node)
|
||||
{
|
||||
mplane_t *splitplane;
|
||||
msurface_t *surf;
|
||||
|
@ -182,9 +182,9 @@ start:
|
|||
|
||||
splitplane = node->plane;
|
||||
if (splitplane->type < 3)
|
||||
dist = light->origin[splitplane->type] - splitplane->dist;
|
||||
dist = lightorg[splitplane->type] - splitplane->dist;
|
||||
else
|
||||
dist = DotProduct (light->origin, splitplane->normal) - splitplane->dist;
|
||||
dist = DotProduct (lightorg, splitplane->normal) - splitplane->dist;
|
||||
|
||||
if (dist > light->radius)
|
||||
{
|
||||
|
@ -203,7 +203,7 @@ start:
|
|||
for (i=0 ; i<node->numsurfaces ; i++, surf++)
|
||||
{
|
||||
for (j=0 ; j<3 ; j++)
|
||||
impact[j] = light->origin[j] - surf->plane->normal[j]*dist;
|
||||
impact[j] = lightorg[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];
|
||||
|
@ -225,9 +225,9 @@ start:
|
|||
}
|
||||
|
||||
if (node->children[0]->contents >= 0)
|
||||
R_MarkLights (light, num, node->children[0]);
|
||||
R_MarkLights (light, lightorg, num, node->children[0]);
|
||||
if (node->children[1]->contents >= 0)
|
||||
R_MarkLights (light, num, node->children[1]);
|
||||
R_MarkLights (light, lightorg, num, node->children[1]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -251,7 +251,7 @@ void R_PushDlights (void)
|
|||
{
|
||||
if (l->die < cl.time || !l->radius)
|
||||
continue;
|
||||
R_MarkLights (l, i, cl.worldmodel->nodes);
|
||||
R_MarkLights (l, l->origin, i, cl.worldmodel->nodes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -917,6 +917,8 @@ R_RenderScene
|
|||
*/
|
||||
void R_RenderScene (void)
|
||||
{
|
||||
static entity_t r_worldentity; //so we can make sure currententity is valid
|
||||
currententity = &r_worldentity;
|
||||
R_SetupScene (); //johnfitz -- this does everything that should be done once per call to RenderScene
|
||||
|
||||
Fog_EnableGFog (); //johnfitz
|
||||
|
@ -924,6 +926,7 @@ void R_RenderScene (void)
|
|||
Sky_DrawSky (); //johnfitz
|
||||
|
||||
R_DrawWorld ();
|
||||
currententity = NULL;
|
||||
|
||||
S_ExtraUpdate (); // don't let sound get messed up if going slow
|
||||
|
||||
|
|
|
@ -376,7 +376,7 @@ qboolean R_CullBox (vec3_t emins, vec3_t emaxs);
|
|||
void R_StoreEfrags (efrag_t **ppefrag);
|
||||
qboolean R_CullModelForEntity (entity_t *e);
|
||||
void R_RotateForEntity (vec3_t origin, vec3_t angles, unsigned char scale);
|
||||
void R_MarkLights (dlight_t *light, int num, mnode_t *node);
|
||||
void R_MarkLights (dlight_t *light, vec3_t lightorg, int num, mnode_t *node);
|
||||
|
||||
void R_InitParticles (void);
|
||||
void R_DrawParticles (void);
|
||||
|
|
|
@ -504,6 +504,7 @@ void R_DrawBrushModel (entity_t *e)
|
|||
float dot;
|
||||
mplane_t *pplane;
|
||||
qmodel_t *clmodel;
|
||||
vec3_t lightorg;
|
||||
|
||||
if (R_CullModelForEntity(e))
|
||||
return;
|
||||
|
@ -536,7 +537,8 @@ void R_DrawBrushModel (entity_t *e)
|
|||
(!cl_dlights[k].radius))
|
||||
continue;
|
||||
|
||||
R_MarkLights (&cl_dlights[k], k,
|
||||
VectorSubtract(cl_dlights[k].origin, e->origin, lightorg);
|
||||
R_MarkLights (&cl_dlights[k], lightorg, k,
|
||||
clmodel->nodes + clmodel->hulls[0].firstclipnode);
|
||||
}
|
||||
}
|
||||
|
@ -1057,6 +1059,7 @@ void R_AddDynamicLights (msurface_t *surf)
|
|||
float cred, cgreen, cblue, brightness;
|
||||
unsigned *bl;
|
||||
//johnfitz
|
||||
vec3_t lightofs; //Spike: light surfaces based upon where they are now instead of their default position.
|
||||
int lmscale;
|
||||
|
||||
smax = (surf->extents[0]>>surf->lmshift)+1;
|
||||
|
@ -1070,8 +1073,8 @@ void R_AddDynamicLights (msurface_t *surf)
|
|||
continue; // not lit by this light
|
||||
|
||||
rad = cl_dlights[lnum].radius;
|
||||
dist = DotProduct (cl_dlights[lnum].origin, surf->plane->normal) -
|
||||
surf->plane->dist;
|
||||
VectorSubtract(cl_dlights[lnum].origin, currententity->origin, lightofs);
|
||||
dist = DotProduct (lightofs, surf->plane->normal) - surf->plane->dist;
|
||||
rad -= fabs(dist);
|
||||
minlight = cl_dlights[lnum].minlight;
|
||||
if (rad < minlight)
|
||||
|
@ -1080,7 +1083,7 @@ void R_AddDynamicLights (msurface_t *surf)
|
|||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
impact[i] = cl_dlights[lnum].origin[i] -
|
||||
impact[i] = lightofs[i] -
|
||||
surf->plane->normal[i]*dist;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue