mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-10 06:42:26 +00:00
Dynamic lighting fixes. (relative bmodel lighting, mainly)
This commit is contained in:
parent
e73700f4e8
commit
0793a90813
6 changed files with 32 additions and 29 deletions
|
@ -214,31 +214,30 @@ R_MarkLights
|
|||
*/
|
||||
// LordHavoc: heavily modified, to eliminate unnecessary texture uploads,
|
||||
// and support bmodel lighting better
|
||||
void R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
||||
void R_MarkLights (vec3_t lightorigin, dlight_t *light, int bit, mnode_t *node)
|
||||
{
|
||||
mplane_t *splitplane;
|
||||
float dist, l, maxdist;
|
||||
msurface_t *surf;
|
||||
int i, j, s, t;
|
||||
vec3_t impact, lightorigin;
|
||||
vec3_t impact;
|
||||
|
||||
if (node->contents < 0)
|
||||
return;
|
||||
|
||||
VectorSubtract(light->origin, currententity->origin, lightorigin);
|
||||
splitplane = node->plane;
|
||||
dist = DotProduct (lightorigin, splitplane->normal) - splitplane->dist;
|
||||
|
||||
if (dist > light->radius)
|
||||
{
|
||||
if (node->children[0]->contents >= 0) // save some time by not pushing another stack frame
|
||||
R_MarkLights (light, bit, node->children[0]);
|
||||
R_MarkLights (lightorigin, light, bit, node->children[0]);
|
||||
return;
|
||||
}
|
||||
if (dist < -light->radius)
|
||||
{
|
||||
if (node->children[1]->contents >= 0) // save some time by not pushing another stack frame
|
||||
R_MarkLights (light, bit, node->children[1]);
|
||||
R_MarkLights (lightorigin, light, bit, node->children[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -273,9 +272,9 @@ void R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
|||
}
|
||||
|
||||
if (node->children[0]->contents >= 0) // save some time by not pushing another stack frame
|
||||
R_MarkLights (light, bit, node->children[0]);
|
||||
R_MarkLights (lightorigin, light, bit, node->children[0]);
|
||||
if (node->children[1]->contents >= 0) // save some time by not pushing another stack frame
|
||||
R_MarkLights (light, bit, node->children[1]);
|
||||
R_MarkLights (lightorigin, light, bit, node->children[1]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -284,10 +283,11 @@ void R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
|||
R_PushDlights
|
||||
=============
|
||||
*/
|
||||
void R_PushDlights (void)
|
||||
void R_PushDlights (vec3_t entorigin)
|
||||
{
|
||||
int i;
|
||||
dlight_t *l;
|
||||
vec3_t lightorigin;
|
||||
|
||||
if (gl_flashblend->value)
|
||||
return;
|
||||
|
@ -300,7 +300,8 @@ void R_PushDlights (void)
|
|||
{
|
||||
if (l->die < cl.time || !l->radius)
|
||||
continue;
|
||||
R_MarkLights ( l, 1<<i, cl.worldmodel->nodes );
|
||||
VectorSubtract(l->origin, entorigin, lightorigin);
|
||||
R_MarkLights (lightorigin, l, 1<<i, cl.worldmodel->nodes );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -861,13 +861,15 @@ void R_DrawBrushModel (entity_t *e)
|
|||
// instanced model
|
||||
if (clmodel->firstmodelsurface != 0 && !gl_flashblend->value)
|
||||
{
|
||||
vec3_t lightorigin;
|
||||
for (k=0 ; k<MAX_DLIGHTS ; k++)
|
||||
{
|
||||
if ((cl_dlights[k].die < cl.time) ||
|
||||
(!cl_dlights[k].radius))
|
||||
continue;
|
||||
|
||||
R_MarkLights (&cl_dlights[k], 1<<k,
|
||||
VectorSubtract(cl_dlights[k].origin, e->origin, lightorigin);
|
||||
R_MarkLights (lightorigin, &cl_dlights[k], 1<<k,
|
||||
clmodel->nodes + clmodel->hulls[0].firstclipnode);
|
||||
}
|
||||
}
|
||||
|
@ -1044,8 +1046,6 @@ void R_DrawWorld (void)
|
|||
|
||||
currententity = &ent;
|
||||
|
||||
R_PushDlights (); // LordHavoc: moved from V_RenderView to R_DrawWorld
|
||||
|
||||
glColor3f (1.0, 1.0, 1.0);
|
||||
memset (lightmap_polys, 0, sizeof(lightmap_polys));
|
||||
// Be sure to clear the skybox --KB
|
||||
|
|
|
@ -76,7 +76,7 @@ DYNAMIC LIGHTS
|
|||
R_MarkLights
|
||||
=============
|
||||
*/
|
||||
void R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
||||
void R_MarkLights (vec3_t lightorigin, dlight_t *light, int bit, mnode_t *node)
|
||||
{
|
||||
mplane_t *splitplane;
|
||||
float dist;
|
||||
|
@ -87,16 +87,16 @@ void R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
|||
return;
|
||||
|
||||
splitplane = node->plane;
|
||||
dist = DotProduct (light->origin, splitplane->normal) - splitplane->dist;
|
||||
dist = DotProduct (lightorigin, splitplane->normal) - splitplane->dist;
|
||||
|
||||
if (dist > light->radius)
|
||||
{
|
||||
R_MarkLights (light, bit, node->children[0]);
|
||||
R_MarkLights (lightorigin, light, bit, node->children[0]);
|
||||
return;
|
||||
}
|
||||
if (dist < -light->radius)
|
||||
{
|
||||
R_MarkLights (light, bit, node->children[1]);
|
||||
R_MarkLights (lightorigin, light, bit, node->children[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,8 @@ void R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
|||
surf->dlightbits |= bit;
|
||||
}
|
||||
|
||||
R_MarkLights (light, bit, node->children[0]);
|
||||
R_MarkLights (light, bit, node->children[1]);
|
||||
R_MarkLights (lightorigin, light, bit, node->children[0]);
|
||||
R_MarkLights (lightorigin, light, bit, node->children[1]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,10 +122,11 @@ void R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
|||
R_PushDlights
|
||||
=============
|
||||
*/
|
||||
void R_PushDlights (void)
|
||||
void R_PushDlights (vec3_t entorigin)
|
||||
{
|
||||
int i;
|
||||
dlight_t *l;
|
||||
vec3_t lightorigin;
|
||||
|
||||
r_dlightframecount = r_framecount + 1; // because the count hasn't
|
||||
// advanced yet for this frame
|
||||
|
@ -135,7 +136,8 @@ void R_PushDlights (void)
|
|||
{
|
||||
if (l->die < cl.time || !l->radius)
|
||||
continue;
|
||||
R_MarkLights ( l, 1<<i, cl.worldmodel->nodes );
|
||||
VectorSubtract(l->origin, entorigin, lightorigin);
|
||||
R_MarkLights (lightorigin, l, 1<<i, cl.worldmodel->nodes );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -831,15 +831,15 @@ void R_DrawBEntitiesOnList (void)
|
|||
// instanced model
|
||||
if (clmodel->firstmodelsurface != 0)
|
||||
{
|
||||
vec3_t lightorigin;
|
||||
for (k=0 ; k<MAX_DLIGHTS ; k++)
|
||||
{
|
||||
if ((cl_dlights[k].die < cl.time) ||
|
||||
(!cl_dlights[k].radius))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
R_MarkLights (&cl_dlights[k], 1<<k,
|
||||
VectorSubtract(cl_dlights[k].origin, currententity->origin, lightorigin);
|
||||
R_MarkLights (lightorigin, &cl_dlights[k], 1<<k,
|
||||
clmodel->nodes + clmodel->hulls[0].firstclipnode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ void R_AddDynamicLights (void)
|
|||
int lnum;
|
||||
int sd, td;
|
||||
float dist, rad, minlight;
|
||||
vec3_t impact, local;
|
||||
vec3_t impact, local, lightorigin;
|
||||
int s, t;
|
||||
int i;
|
||||
int smax, tmax;
|
||||
|
@ -91,8 +91,9 @@ void R_AddDynamicLights (void)
|
|||
if ( !(surf->dlightbits & (1<<lnum) ) )
|
||||
continue; // not lit by this light
|
||||
|
||||
VectorSubtract(cl_dlights[lnum].origin, currententity->origin, lightorigin);
|
||||
rad = cl_dlights[lnum].radius;
|
||||
dist = DotProduct (cl_dlights[lnum].origin, surf->plane->normal) -
|
||||
dist = DotProduct (lightorigin, surf->plane->normal) -
|
||||
surf->plane->dist;
|
||||
rad -= fabs(dist);
|
||||
minlight = cl_dlights[lnum].minlight;
|
||||
|
@ -101,10 +102,7 @@ void R_AddDynamicLights (void)
|
|||
minlight = rad - minlight;
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
impact[i] = cl_dlights[lnum].origin[i] -
|
||||
surf->plane->normal[i]*dist;
|
||||
}
|
||||
impact[i] = lightorigin[i] - surf->plane->normal[i]*dist;
|
||||
|
||||
local[0] = DotProduct (impact, tex->vecs[0]) + tex->vecs[0][3];
|
||||
local[1] = DotProduct (impact, tex->vecs[1]) + tex->vecs[1][3];
|
||||
|
|
|
@ -811,6 +811,8 @@ void V_RenderView (void)
|
|||
V_CalcRefdef ();
|
||||
}
|
||||
|
||||
R_PushDlights (vec3_origin);
|
||||
|
||||
R_RenderView ();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue