renders: move lightmap calls to LM_CreateLightmapsPoligon

This commit is contained in:
Denis Pauk 2024-04-13 14:44:03 +03:00
parent 02b8e85c01
commit 2d6241b31e
12 changed files with 103 additions and 146 deletions

View file

@ -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)
{

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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)
{

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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)
{

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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);

View file

@ -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)
{

View file

@ -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);
}
}