From 2d6241b31e7fff3996998b3a9086af7effae9b95 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sat, 13 Apr 2024 14:44:03 +0300 Subject: [PATCH] renders: move lightmap calls to LM_CreateLightmapsPoligon --- src/client/refresh/gl1/gl1_lightmap.c | 19 +++++++++++++-- src/client/refresh/gl1/gl1_model.c | 33 +++------------------------ src/client/refresh/gl1/header/local.h | 3 +-- src/client/refresh/gl3/gl3_lightmap.c | 28 +++++++++++++++++++---- src/client/refresh/gl3/gl3_model.c | 33 +++------------------------ src/client/refresh/gl3/header/local.h | 3 +-- src/client/refresh/gl4/gl4_lightmap.c | 26 +++++++++++++++++---- src/client/refresh/gl4/gl4_model.c | 33 +++------------------------ src/client/refresh/gl4/header/local.h | 3 +-- src/client/refresh/vk/header/local.h | 7 +++--- src/client/refresh/vk/vk_lightmap.c | 28 +++++++++++++++++++---- src/client/refresh/vk/vk_model.c | 33 +++------------------------ 12 files changed, 103 insertions(+), 146 deletions(-) diff --git a/src/client/refresh/gl1/gl1_lightmap.c b/src/client/refresh/gl1/gl1_lightmap.c index 34d5ada2..6a0f069b 100644 --- a/src/client/refresh/gl1/gl1_lightmap.c +++ b/src/client/refresh/gl1/gl1_lightmap.c @@ -133,7 +133,7 @@ LM_AllocBlock(int w, int h, int *x, int *y) return true; } -void +static void LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa) { medge_t *pedges, *r_pedge; @@ -222,7 +222,7 @@ LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa) } } -void +static void LM_CreateSurfaceLightmap(msurface_t *surf) { int smax, tmax; @@ -260,6 +260,21 @@ LM_CreateSurfaceLightmap(msurface_t *surf) &r_newrefdef, r_modulate->value, r_framecount); } +void +LM_CreateLightmapsPoligon(model_t *currentmodel, msurface_t *fa) +{ + /* create lightmaps and polygons */ + if (!(fa->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) + { + LM_CreateSurfaceLightmap(fa); + } + + if (!(fa->texinfo->flags & SURF_WARP)) + { + LM_BuildPolygonFromSurface(currentmodel, fa); + } +} + void LM_BeginBuildingLightmaps(model_t *m) { diff --git a/src/client/refresh/gl1/gl1_model.c b/src/client/refresh/gl1/gl1_model.c index 4c4c631e..ef5fa702 100644 --- a/src/client/refresh/gl1/gl1_model.c +++ b/src/client/refresh/gl1/gl1_model.c @@ -290,16 +290,7 @@ Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l, } } - /* create lightmaps and polygons */ - if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) - { - LM_CreateSurfaceLightmap(out); - } - - if (!(out->texinfo->flags & SURF_WARP)) - { - LM_BuildPolygonFromSurface(loadmodel, out); - } + LM_CreateLightmapsPoligon(loadmodel, out); } } @@ -414,16 +405,7 @@ Mod_LoadRFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l, } } - /* create lightmaps and polygons */ - if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) - { - LM_CreateSurfaceLightmap(out); - } - - if (!(out->texinfo->flags & SURF_WARP)) - { - LM_BuildPolygonFromSurface(loadmodel, out); - } + LM_CreateLightmapsPoligon(loadmodel, out); } } @@ -538,16 +520,7 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l, } } - /* create lightmaps and polygons */ - if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) - { - LM_CreateSurfaceLightmap(out); - } - - if (!(out->texinfo->flags & SURF_WARP)) - { - LM_BuildPolygonFromSurface(loadmodel, out); - } + LM_CreateLightmapsPoligon(loadmodel, out); } } diff --git a/src/client/refresh/gl1/header/local.h b/src/client/refresh/gl1/header/local.h index a3714454..50e62272 100644 --- a/src/client/refresh/gl1/header/local.h +++ b/src/client/refresh/gl1/header/local.h @@ -393,8 +393,7 @@ typedef struct byte lightmap_buffer[LIGHTMAP_BYTES * BLOCK_WIDTH * BLOCK_HEIGHT]; } gllightmapstate_t; -void LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa); -void LM_CreateSurfaceLightmap(msurface_t *surf); +void LM_CreateLightmapsPoligon(model_t *currentmodel, msurface_t *fa); void LM_EndBuildingLightmaps(void); void LM_BeginBuildingLightmaps(model_t *m); diff --git a/src/client/refresh/gl3/gl3_lightmap.c b/src/client/refresh/gl3/gl3_lightmap.c index af6fcd43..6e7ff445 100644 --- a/src/client/refresh/gl3/gl3_lightmap.c +++ b/src/client/refresh/gl3/gl3_lightmap.c @@ -117,12 +117,12 @@ LM_AllocBlock(int w, int h, int *x, int *y) return true; } -void +static void LM_BuildPolygonFromSurface(gl3model_t *currentmodel, msurface_t *fa) { - int i, lnumverts; medge_t *pedges, *r_pedge; - float *vec; + int i, lnumverts; + const float *vec; mpoly_t *poly; vec3_t total; vec3_t normal; @@ -147,7 +147,10 @@ LM_BuildPolygonFromSurface(gl3model_t *currentmodel, msurface_t *fa) { // if for some reason the normal sticks to the back of the plane, invert it // so it's usable for the shader - for (i=0; i<3; ++i) normal[i] = -normal[i]; + for (i=0; i<3; ++i) + { + normal[i] = -normal[i]; + } } for (i = 0; i < lnumverts; i++) @@ -203,7 +206,7 @@ LM_BuildPolygonFromSurface(gl3model_t *currentmodel, msurface_t *fa) } } -void +static void LM_CreateSurfaceLightmap(msurface_t *surf) { int smax, tmax; @@ -234,6 +237,21 @@ LM_CreateSurfaceLightmap(msurface_t *surf) GL3_BuildLightMap(surf, (surf->light_t * BLOCK_WIDTH + surf->light_s) * LIGHTMAP_BYTES, BLOCK_WIDTH * LIGHTMAP_BYTES); } +void +LM_CreateLightmapsPoligon(gl3model_t *currentmodel, msurface_t *fa) +{ + /* create lightmaps and polygons */ + if (!(fa->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) + { + LM_CreateSurfaceLightmap(fa); + } + + if (!(fa->texinfo->flags & SURF_WARP)) + { + LM_BuildPolygonFromSurface(currentmodel, fa); + } +} + void LM_BeginBuildingLightmaps(gl3model_t *m) { diff --git a/src/client/refresh/gl3/gl3_model.c b/src/client/refresh/gl3/gl3_model.c index f8c78681..6502aba5 100644 --- a/src/client/refresh/gl3/gl3_model.c +++ b/src/client/refresh/gl3/gl3_model.c @@ -291,16 +291,7 @@ Mod_LoadFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l, } } - /* create lightmaps and polygons */ - if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) - { - LM_CreateSurfaceLightmap(out); - } - - if (!(out->texinfo->flags & SURF_WARP)) - { - LM_BuildPolygonFromSurface(loadmodel, out); - } + LM_CreateLightmapsPoligon(loadmodel, out); } } @@ -415,16 +406,7 @@ Mod_LoadRFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l, } } - /* create lightmaps and polygons */ - if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) - { - LM_CreateSurfaceLightmap(out); - } - - if (!(out->texinfo->flags & SURF_WARP)) - { - LM_BuildPolygonFromSurface(loadmodel, out); - } + LM_CreateLightmapsPoligon(loadmodel, out); } } @@ -539,16 +521,7 @@ Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l, } } - /* create lightmaps and polygons */ - if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) - { - LM_CreateSurfaceLightmap(out); - } - - if (!(out->texinfo->flags & SURF_WARP)) - { - LM_BuildPolygonFromSurface(loadmodel, out); - } + LM_CreateLightmapsPoligon(loadmodel, out); } } diff --git a/src/client/refresh/gl3/header/local.h b/src/client/refresh/gl3/header/local.h index a2987177..08cb0cda 100644 --- a/src/client/refresh/gl3/header/local.h +++ b/src/client/refresh/gl3/header/local.h @@ -462,8 +462,7 @@ extern void GL3_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride); extern void LM_InitBlock(void); extern void LM_UploadBlock(void); extern qboolean LM_AllocBlock(int w, int h, int *x, int *y); -extern void LM_BuildPolygonFromSurface(gl3model_t *currentmodel, msurface_t *fa); -extern void LM_CreateSurfaceLightmap(msurface_t *surf); +extern void LM_CreateLightmapsPoligon(gl3model_t *currentmodel, msurface_t *fa); extern void LM_BeginBuildingLightmaps(gl3model_t *m); extern void LM_EndBuildingLightmaps(void); diff --git a/src/client/refresh/gl4/gl4_lightmap.c b/src/client/refresh/gl4/gl4_lightmap.c index 54399f9c..85058e47 100644 --- a/src/client/refresh/gl4/gl4_lightmap.c +++ b/src/client/refresh/gl4/gl4_lightmap.c @@ -120,9 +120,9 @@ LM_AllocBlock(int w, int h, int *x, int *y) void LM_BuildPolygonFromSurface(gl4model_t *currentmodel, msurface_t *fa) { - int i, lnumverts; medge_t *pedges, *r_pedge; - float *vec; + int i, lnumverts; + const float *vec; mpoly_t *poly; vec3_t total; vec3_t normal; @@ -147,7 +147,10 @@ LM_BuildPolygonFromSurface(gl4model_t *currentmodel, msurface_t *fa) { // if for some reason the normal sticks to the back of the plane, invert it // so it's usable for the shader - for (i=0; i<3; ++i) normal[i] = -normal[i]; + for (i=0; i<3; ++i) + { + normal[i] = -normal[i]; + } } for (i = 0; i < lnumverts; i++) @@ -203,7 +206,7 @@ LM_BuildPolygonFromSurface(gl4model_t *currentmodel, msurface_t *fa) } } -void +static void LM_CreateSurfaceLightmap(msurface_t *surf) { int smax, tmax; @@ -234,6 +237,21 @@ LM_CreateSurfaceLightmap(msurface_t *surf) GL4_BuildLightMap(surf, (surf->light_t * BLOCK_WIDTH + surf->light_s) * LIGHTMAP_BYTES, BLOCK_WIDTH * LIGHTMAP_BYTES); } +void +LM_CreateLightmapsPoligon(gl4model_t *currentmodel, msurface_t *fa) +{ + /* create lightmaps and polygons */ + if (!(fa->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) + { + LM_CreateSurfaceLightmap(fa); + } + + if (!(fa->texinfo->flags & SURF_WARP)) + { + LM_BuildPolygonFromSurface(currentmodel, fa); + } +} + void LM_BeginBuildingLightmaps(gl4model_t *m) { diff --git a/src/client/refresh/gl4/gl4_model.c b/src/client/refresh/gl4/gl4_model.c index 679047ac..0cc0f35d 100644 --- a/src/client/refresh/gl4/gl4_model.c +++ b/src/client/refresh/gl4/gl4_model.c @@ -291,16 +291,7 @@ Mod_LoadFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l, } } - /* create lightmaps and polygons */ - if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) - { - LM_CreateSurfaceLightmap(out); - } - - if (!(out->texinfo->flags & SURF_WARP)) - { - LM_BuildPolygonFromSurface(loadmodel, out); - } + LM_CreateLightmapsPoligon(loadmodel, out); } } @@ -415,16 +406,7 @@ Mod_LoadRFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l, } } - /* create lightmaps and polygons */ - if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) - { - LM_CreateSurfaceLightmap(out); - } - - if (!(out->texinfo->flags & SURF_WARP)) - { - LM_BuildPolygonFromSurface(loadmodel, out); - } + LM_CreateLightmapsPoligon(loadmodel, out); } } @@ -539,16 +521,7 @@ Mod_LoadQFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l, } } - /* create lightmaps and polygons */ - if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) - { - LM_CreateSurfaceLightmap(out); - } - - if (!(out->texinfo->flags & SURF_WARP)) - { - LM_BuildPolygonFromSurface(loadmodel, out); - } + LM_CreateLightmapsPoligon(loadmodel, out); } } diff --git a/src/client/refresh/gl4/header/local.h b/src/client/refresh/gl4/header/local.h index e75988f6..742278f1 100644 --- a/src/client/refresh/gl4/header/local.h +++ b/src/client/refresh/gl4/header/local.h @@ -452,8 +452,7 @@ extern void GL4_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride); extern void LM_InitBlock(void); extern void LM_UploadBlock(void); extern qboolean LM_AllocBlock(int w, int h, int *x, int *y); -extern void LM_BuildPolygonFromSurface(gl4model_t *currentmodel, msurface_t *fa); -extern void LM_CreateSurfaceLightmap(msurface_t *surf); +extern void LM_CreateLightmapsPoligon(gl4model_t *currentmodel, msurface_t *fa); extern void LM_BeginBuildingLightmaps(gl4model_t *m); extern void LM_EndBuildingLightmaps(void); diff --git a/src/client/refresh/vk/header/local.h b/src/client/refresh/vk/header/local.h index edc0821a..f231c3af 100644 --- a/src/client/refresh/vk/header/local.h +++ b/src/client/refresh/vk/header/local.h @@ -227,10 +227,9 @@ void Vk_TextureMode( char *string ); void Vk_LmapTextureMode( char *string ); void Vk_ImageList_f (void); -void LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa); -void LM_CreateSurfaceLightmap (msurface_t *surf); -void LM_EndBuildingLightmaps (void); -void LM_BeginBuildingLightmaps (model_t *m); +void LM_CreateLightmapsPoligon(model_t *currentmodel, msurface_t *fa); +void LM_EndBuildingLightmaps(void); +void LM_BeginBuildingLightmaps(model_t *m); void Vk_InitImages (void); void Vk_ShutdownImages (void); diff --git a/src/client/refresh/vk/vk_lightmap.c b/src/client/refresh/vk/vk_lightmap.c index 901684cc..7e71c632 100644 --- a/src/client/refresh/vk/vk_lightmap.c +++ b/src/client/refresh/vk/vk_lightmap.c @@ -116,12 +116,12 @@ LM_AllocBlock(int w, int h, int *x, int *y) return true; } -void +static void LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa) { - int i, lnumverts; medge_t *pedges, *r_pedge; - float *vec; + int i, lnumverts; + const float *vec; mpoly_t *poly; vec3_t total; vec3_t normal; @@ -146,7 +146,10 @@ LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa) { // if for some reason the normal sticks to the back of the plane, invert it // so it's usable for the shader - for (i=0; i<3; ++i) normal[i] = -normal[i]; + for (i=0; i<3; ++i) + { + normal[i] = -normal[i]; + } } for (i = 0; i < lnumverts; i++) @@ -202,7 +205,7 @@ LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa) } } -void +static void LM_CreateSurfaceLightmap(msurface_t *surf) { int smax, tmax; @@ -240,6 +243,21 @@ LM_CreateSurfaceLightmap(msurface_t *surf) &r_newrefdef, r_modulate->value, r_framecount); } +void +LM_CreateLightmapsPoligon(model_t *currentmodel, msurface_t *fa) +{ + /* create lightmaps and polygons */ + if (!(fa->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) + { + LM_CreateSurfaceLightmap(fa); + } + + if (!(fa->texinfo->flags & SURF_WARP)) + { + LM_BuildPolygonFromSurface(currentmodel, fa); + } +} + void LM_BeginBuildingLightmaps(model_t *m) { diff --git a/src/client/refresh/vk/vk_model.c b/src/client/refresh/vk/vk_model.c index 8336037f..78f469bf 100644 --- a/src/client/refresh/vk/vk_model.c +++ b/src/client/refresh/vk/vk_model.c @@ -265,16 +265,7 @@ Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l, } } - /* create lightmaps and polygons */ - if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) - { - LM_CreateSurfaceLightmap(out); - } - - if (!(out->texinfo->flags & SURF_WARP)) - { - LM_BuildPolygonFromSurface(loadmodel, out); - } + LM_CreateLightmapsPoligon(loadmodel, out); } } @@ -389,16 +380,7 @@ Mod_LoadRFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l, } } - /* create lightmaps and polygons */ - if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) - { - LM_CreateSurfaceLightmap(out); - } - - if (!(out->texinfo->flags & SURF_WARP)) - { - LM_BuildPolygonFromSurface(loadmodel, out); - } + LM_CreateLightmapsPoligon(loadmodel, out); } } @@ -513,16 +495,7 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l, } } - /* create lightmaps and polygons */ - if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP))) - { - LM_CreateSurfaceLightmap(out); - } - - if (!(out->texinfo->flags & SURF_WARP)) - { - LM_BuildPolygonFromSurface(loadmodel, out); - } + LM_CreateLightmapsPoligon(loadmodel, out); } }