mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-21 03:11:57 +00:00
Share R_PushDlights between all renders
This commit is contained in:
parent
4dbb6eb4bc
commit
c91dc0b9b2
18 changed files with 50 additions and 89 deletions
|
@ -422,7 +422,7 @@ Set `0` by default.
|
|||
|
||||
* **r_dynamic**: Enamble dynamic light in gl1 and vk renders.
|
||||
|
||||
* **r_flashblend**: Flah blend enable in gl1, gl3 and vulkan.
|
||||
* **r_flashblend**: Flash blend enable in gl1, gl3 and vulkan.
|
||||
|
||||
## Graphics (GL renderers only)
|
||||
|
||||
|
|
|
@ -643,7 +643,7 @@ bit: 1 << i for light number i, will be or'ed into msurface_t::dlightbits
|
|||
if surface is affected by this light
|
||||
=============
|
||||
*/
|
||||
void
|
||||
static void
|
||||
R_MarkLights(dlight_t *light, int bit, mnode_t *node, int r_dlightframecount,
|
||||
msurface_t *surfaces)
|
||||
{
|
||||
|
@ -682,3 +682,18 @@ R_MarkLights(dlight_t *light, int bit, mnode_t *node, int r_dlightframecount,
|
|||
R_MarkLights(light, bit, node->children[1], r_dlightframecount,
|
||||
surfaces);
|
||||
}
|
||||
|
||||
void R_PushDlights(refdef_t *r_newrefdef, mnode_t *nodes, int r_dlightframecount,
|
||||
msurface_t *surfaces)
|
||||
{
|
||||
dlight_t *l;
|
||||
int i;
|
||||
|
||||
l = r_newrefdef->dlights;
|
||||
|
||||
for (i = 0; i < r_newrefdef->num_dlights; i++, l++)
|
||||
{
|
||||
R_MarkLights(l, 1 << i, nodes, r_dlightframecount, surfaces);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -116,11 +116,8 @@ R_RenderDlights(void)
|
|||
}
|
||||
|
||||
void
|
||||
R_PushDlights(void)
|
||||
RI_PushDlights(void)
|
||||
{
|
||||
dlight_t *l;
|
||||
int i;
|
||||
|
||||
if (r_flashblend->value)
|
||||
{
|
||||
return;
|
||||
|
@ -129,13 +126,8 @@ R_PushDlights(void)
|
|||
/* because the count hasn't advanced yet for this frame */
|
||||
r_dlightframecount = r_framecount + 1;
|
||||
|
||||
l = r_newrefdef.dlights;
|
||||
|
||||
for (i = 0; i < r_newrefdef.num_dlights; i++, l++)
|
||||
{
|
||||
R_MarkLights(l, 1 << i, r_worldmodel->nodes, r_dlightframecount,
|
||||
r_worldmodel->surfaces);
|
||||
}
|
||||
R_PushDlights(&r_newrefdef, r_worldmodel->nodes, r_dlightframecount,
|
||||
r_worldmodel->surfaces);
|
||||
}
|
||||
|
||||
float *s_blocklights = NULL, *s_blocklights_max = NULL;
|
||||
|
|
|
@ -1045,7 +1045,7 @@ R_RenderView(refdef_t *fd)
|
|||
c_alias_polys = 0;
|
||||
}
|
||||
|
||||
R_PushDlights();
|
||||
RI_PushDlights();
|
||||
|
||||
if (gl_finish->value)
|
||||
{
|
||||
|
|
|
@ -637,17 +637,8 @@ R_DrawInlineBModel(entity_t *currententity, const model_t *currentmodel)
|
|||
/* calculate dynamic lighting for bmodel */
|
||||
if (!r_flashblend->value)
|
||||
{
|
||||
dlight_t *lt;
|
||||
int k;
|
||||
|
||||
lt = r_newrefdef.dlights;
|
||||
|
||||
for (k = 0; k < r_newrefdef.num_dlights; k++, lt++)
|
||||
{
|
||||
R_MarkLights(lt, 1 << k,
|
||||
currentmodel->nodes + currentmodel->firstnode,
|
||||
r_dlightframecount, currentmodel->surfaces);
|
||||
}
|
||||
R_PushDlights(&r_newrefdef, currentmodel->nodes + currentmodel->firstnode,
|
||||
r_dlightframecount, currentmodel->surfaces);
|
||||
}
|
||||
|
||||
psurf = ¤tmodel->surfaces[currentmodel->firstmodelsurface];
|
||||
|
|
|
@ -233,7 +233,7 @@ void R_Bind(int texnum);
|
|||
|
||||
void R_TexEnv(GLenum value);
|
||||
|
||||
void R_PushDlights(void);
|
||||
void RI_PushDlights(void);
|
||||
|
||||
extern float *s_blocklights, *s_blocklights_max;
|
||||
extern model_t *r_worldmodel;
|
||||
|
|
|
@ -41,6 +41,9 @@ GL3_PushDlights(void)
|
|||
/* because the count hasn't advanced yet for this frame */
|
||||
r_dlightframecount = gl3_framecount + 1;
|
||||
|
||||
R_PushDlights(&gl3_newrefdef, gl3_worldmodel->nodes, r_dlightframecount,
|
||||
gl3_worldmodel->surfaces);
|
||||
|
||||
l = gl3_newrefdef.dlights;
|
||||
|
||||
gl3state.uniLightsData.numDynLights = gl3_newrefdef.num_dlights;
|
||||
|
@ -48,9 +51,6 @@ GL3_PushDlights(void)
|
|||
for (i = 0; i < gl3_newrefdef.num_dlights; i++, l++)
|
||||
{
|
||||
gl3UniDynLight* udl = &gl3state.uniLightsData.dynLights[i];
|
||||
R_MarkLights(l, 1 << i, gl3_worldmodel->nodes, r_dlightframecount,
|
||||
gl3_worldmodel->surfaces);
|
||||
|
||||
VectorCopy(l->origin, udl->origin);
|
||||
VectorCopy(l->color, udl->color);
|
||||
udl->intensity = l->intensity;
|
||||
|
|
|
@ -480,20 +480,14 @@ RenderLightmappedPoly(entity_t *currententity, msurface_t *surf)
|
|||
static void
|
||||
DrawInlineBModel(entity_t *currententity, gl3model_t *currentmodel)
|
||||
{
|
||||
int i, k;
|
||||
int i;
|
||||
cplane_t *pplane;
|
||||
float dot;
|
||||
msurface_t *psurf;
|
||||
dlight_t *lt;
|
||||
|
||||
/* calculate dynamic lighting for bmodel */
|
||||
lt = gl3_newrefdef.dlights;
|
||||
|
||||
for (k = 0; k < gl3_newrefdef.num_dlights; k++, lt++)
|
||||
{
|
||||
R_MarkLights(lt, 1 << k, currentmodel->nodes + currentmodel->firstnode,
|
||||
R_PushDlights(&gl3_newrefdef, currentmodel->nodes + currentmodel->firstnode,
|
||||
r_dlightframecount, currentmodel->surfaces);
|
||||
}
|
||||
|
||||
psurf = ¤tmodel->surfaces[currentmodel->firstmodelsurface];
|
||||
|
||||
|
|
|
@ -41,6 +41,9 @@ GL4_PushDlights(void)
|
|||
/* because the count hasn't advanced yet for this frame */
|
||||
r_dlightframecount = gl4_framecount + 1;
|
||||
|
||||
R_PushDlights(&gl4_newrefdef, gl4_worldmodel->nodes, r_dlightframecount,
|
||||
gl4_worldmodel->surfaces);
|
||||
|
||||
l = gl4_newrefdef.dlights;
|
||||
|
||||
gl4state.uniLightsData.numDynLights = gl4_newrefdef.num_dlights;
|
||||
|
@ -48,9 +51,6 @@ GL4_PushDlights(void)
|
|||
for (i = 0; i < gl4_newrefdef.num_dlights; i++, l++)
|
||||
{
|
||||
gl4UniDynLight* udl = &gl4state.uniLightsData.dynLights[i];
|
||||
R_MarkLights(l, 1 << i, gl4_worldmodel->nodes, r_dlightframecount,
|
||||
gl4_worldmodel->surfaces);
|
||||
|
||||
VectorCopy(l->origin, udl->origin);
|
||||
VectorCopy(l->color, udl->color);
|
||||
udl->intensity = l->intensity;
|
||||
|
|
|
@ -480,20 +480,13 @@ RenderLightmappedPoly(entity_t *currententity, msurface_t *surf)
|
|||
static void
|
||||
DrawInlineBModel(entity_t *currententity, gl4model_t *currentmodel)
|
||||
{
|
||||
int i, k;
|
||||
int i;
|
||||
cplane_t *pplane;
|
||||
float dot;
|
||||
msurface_t *psurf;
|
||||
dlight_t *lt;
|
||||
|
||||
/* calculate dynamic lighting for bmodel */
|
||||
lt = gl4_newrefdef.dlights;
|
||||
|
||||
for (k = 0; k < gl4_newrefdef.num_dlights; k++, lt++)
|
||||
{
|
||||
R_MarkLights(lt, 1 << k, currentmodel->nodes + currentmodel->firstnode,
|
||||
R_PushDlights(&gl4_newrefdef, currentmodel->nodes + currentmodel->firstnode,
|
||||
r_dlightframecount, currentmodel->surfaces);
|
||||
}
|
||||
|
||||
psurf = ¤tmodel->surfaces[currentmodel->firstmodelsurface];
|
||||
|
||||
|
|
|
@ -362,8 +362,8 @@ extern int Mod_LoadFile(char *name, void **buffer);
|
|||
/* Surface logic */
|
||||
#define DLIGHT_CUTOFF 64
|
||||
|
||||
extern void R_MarkLights (dlight_t *light, int bit, mnode_t *node, int r_dlightframecount,
|
||||
msurface_t *surfaces);
|
||||
extern void R_PushDlights(refdef_t *r_newrefdef, mnode_t *nodes, int r_dlightframecount,
|
||||
msurface_t *surfaces);
|
||||
extern struct image_s *R_TextureAnimation(const entity_t *currententity,
|
||||
const mtexinfo_t *tex);
|
||||
extern qboolean R_AreaVisible(const byte *areabits, mleaf_t *pleaf);
|
||||
|
|
|
@ -451,7 +451,7 @@ void R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *
|
|||
void R_AliasDrawModel(entity_t *currententity, const model_t *currentmodel);
|
||||
void R_BeginEdgeFrame(void);
|
||||
void R_ScanEdges(entity_t *currententity, surf_t *surface);
|
||||
void R_PushDlights(const model_t *model);
|
||||
void RI_PushDlights(const model_t *model);
|
||||
void R_RotateBmodel(const entity_t *currententity);
|
||||
|
||||
extern int c_faceclip;
|
||||
|
|
|
@ -34,21 +34,14 @@ DYNAMIC LIGHTS
|
|||
|
||||
/*
|
||||
=============
|
||||
R_PushDlights
|
||||
RI_PushDlights
|
||||
=============
|
||||
*/
|
||||
void
|
||||
R_PushDlights(const model_t *model)
|
||||
RI_PushDlights(const model_t *model)
|
||||
{
|
||||
int i;
|
||||
dlight_t *l;
|
||||
|
||||
for (i=0, l = r_newrefdef.dlights ; i<r_newrefdef.num_dlights ; i++, l++)
|
||||
{
|
||||
R_MarkLights(l, 1<<i,
|
||||
model->nodes + model->firstnode,
|
||||
r_framecount, model->surfaces);
|
||||
}
|
||||
R_PushDlights(&r_newrefdef, model->nodes + model->firstnode,
|
||||
r_framecount, model->surfaces);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1128,7 +1128,7 @@ R_DrawBEntitiesOnList (void)
|
|||
R_RotateBmodel(currententity);
|
||||
|
||||
// calculate dynamic lighting for bmodel
|
||||
R_PushDlights (currentmodel);
|
||||
RI_PushDlights (currentmodel);
|
||||
|
||||
if (topnode->contents == CONTENTS_NODE)
|
||||
{
|
||||
|
@ -1369,7 +1369,7 @@ RE_RenderFrame (refdef_t *fd)
|
|||
R_MarkLeaves (); // done here so we know if we're in water
|
||||
|
||||
// For each dlight_t* passed via r_newrefdef.dlights, mark polygons affected by a light.
|
||||
R_PushDlights (r_worldmodel);
|
||||
RI_PushDlights (r_worldmodel);
|
||||
|
||||
// TODO: rearrange code same as in GL*_DrawWorld?
|
||||
/* auto cycle the world frame for texture animation */
|
||||
|
|
|
@ -185,7 +185,7 @@ void Vk_ScreenShot_f (void);
|
|||
void Vk_Strings_f(void);
|
||||
void Vk_Mem_f(void);
|
||||
|
||||
void R_PushDlights(void);
|
||||
void RI_PushDlights(void);
|
||||
|
||||
void R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel);
|
||||
void R_DrawBrushModel(entity_t *currententity, const model_t *currentmodel);
|
||||
|
|
|
@ -106,11 +106,8 @@ R_RenderDlights(void)
|
|||
}
|
||||
|
||||
void
|
||||
R_PushDlights(void)
|
||||
RI_PushDlights(void)
|
||||
{
|
||||
dlight_t *l;
|
||||
int i;
|
||||
|
||||
if (r_flashblend->value)
|
||||
{
|
||||
return;
|
||||
|
@ -119,13 +116,8 @@ R_PushDlights(void)
|
|||
/* because the count hasn't advanced yet for this frame */
|
||||
r_dlightframecount = r_framecount + 1;
|
||||
|
||||
l = r_newrefdef.dlights;
|
||||
|
||||
for (i = 0; i < r_newrefdef.num_dlights; i++, l++)
|
||||
{
|
||||
R_MarkLights(l, 1 << i, r_worldmodel->nodes, r_dlightframecount,
|
||||
r_worldmodel->surfaces);
|
||||
}
|
||||
R_PushDlights(&r_newrefdef, r_worldmodel->nodes,
|
||||
r_dlightframecount, r_worldmodel->surfaces);
|
||||
}
|
||||
|
||||
float *s_blocklights = NULL, *s_blocklights_max = NULL;
|
||||
|
|
|
@ -936,7 +936,7 @@ RE_RenderView(refdef_t *fd)
|
|||
|
||||
vkCmdSetScissor(vk_activeCmdbuffer, 0, 1, &scissor);
|
||||
|
||||
R_PushDlights();
|
||||
RI_PushDlights();
|
||||
|
||||
// added for compatibility sake with OpenGL implementation - don't use it!
|
||||
if (vk_finish->value)
|
||||
|
|
|
@ -603,17 +603,8 @@ R_DrawInlineBModel(entity_t *currententity, const model_t *currentmodel, float *
|
|||
/* calculate dynamic lighting for bmodel */
|
||||
if (!r_flashblend->value)
|
||||
{
|
||||
dlight_t *lt;
|
||||
int k;
|
||||
|
||||
lt = r_newrefdef.dlights;
|
||||
|
||||
for (k = 0; k < r_newrefdef.num_dlights; k++, lt++)
|
||||
{
|
||||
R_MarkLights(lt, 1 << k,
|
||||
currentmodel->nodes + currentmodel->firstnode,
|
||||
r_dlightframecount, currentmodel->surfaces);
|
||||
}
|
||||
R_PushDlights(&r_newrefdef, currentmodel->nodes + currentmodel->firstnode,
|
||||
r_dlightframecount, currentmodel->surfaces);
|
||||
}
|
||||
|
||||
psurf = ¤tmodel->surfaces[currentmodel->firstmodelsurface];
|
||||
|
|
Loading…
Reference in a new issue