From 600e7ecbeaa158bc04abf7be2707b97d3b231dd1 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 10 May 2022 17:03:14 +0900 Subject: [PATCH] [renderer] Resurrect r_dlightframecount This fixes dynamic light map updates for gl, glsl, and sw, but gl has problems with map submodels not being dynamically lit. --- include/r_local.h | 3 --- libs/video/renderer/r_light.c | 10 +++++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/r_local.h b/include/r_local.h index 4ea9d6795..33ef06469 100644 --- a/include/r_local.h +++ b/include/r_local.h @@ -292,7 +292,6 @@ extern int r_maxsurfsseen, r_maxedgesseen; extern qboolean r_dowarpold, r_viewchanged; extern int r_clipflags; -extern int r_dlightframecount; extern struct entqueue_s *r_ent_queue; struct dlight_s; @@ -311,8 +310,6 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1); void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip); void R_RecursiveMarkLights (mod_brush_t *brush, const vec3_t lightorigin, struct dlight_s *light, int bit, mnode_t *node); -void R_MarkLights (const vec3_t lightorigin, struct dlight_s *light, int bit, - model_t *model); void R_LoadSkys (const char *); //void Vulkan_R_LoadSkys (const char *, struct vulkan_ctx_s *ctx); diff --git a/libs/video/renderer/r_light.c b/libs/video/renderer/r_light.c index 654748dfb..4949ad3e4 100644 --- a/libs/video/renderer/r_light.c +++ b/libs/video/renderer/r_light.c @@ -50,6 +50,7 @@ dlight_t *r_dlights; vec3_t ambientcolor; unsigned int r_maxdlights; +static int r_dlightframecount; void R_FindNearLights (vec4f_t pos, int count, dlight_t **lights) @@ -179,9 +180,9 @@ real_mark_surfaces (float dist, msurface_t *surf, const vec3_t lightorigin, if (is * is + it * it > dist2) return; - if (surf->dlightframe != r_framecount) { + if (surf->dlightframe != r_dlightframecount) { memset (surf->dlightbits, 0, sizeof (surf->dlightbits)); - surf->dlightframe = r_framecount; + surf->dlightframe = r_dlightframecount; } ind = lightnum / 32; bit = 1 << (lightnum % 32); @@ -260,7 +261,7 @@ loc0: } -void +static void R_MarkLights (const vec3_t lightorigin, dlight_t *light, int lightnum, model_t *model) { @@ -321,6 +322,9 @@ R_PushDlights (const vec3_t entorigin) dlight_t *l; vec3_t lightorigin; + // because the count hasn't advanced yet for this frame + r_dlightframecount = r_framecount + 1; + if (!r_dlight_lightmap) return;