renders: move lightmap creation call outside of LoadFace code

This commit is contained in:
Denis Pauk 2024-04-13 00:15:19 +03:00
parent 310c0fdb58
commit 4ab6777e1f
6 changed files with 36 additions and 58 deletions

View file

@ -163,7 +163,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++)

View file

@ -211,8 +211,6 @@ Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
lminfos = NULL;
}
LM_BeginBuildingLightmaps(loadmodel);
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum, lightofs;
@ -303,8 +301,6 @@ Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
LM_BuildPolygonFromSurface(loadmodel, out);
}
}
LM_EndBuildingLightmaps();
}
static void
@ -339,8 +335,6 @@ Mod_LoadRFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
lminfos = NULL;
}
LM_BeginBuildingLightmaps(loadmodel);
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum, lightofs;
@ -431,8 +425,6 @@ Mod_LoadRFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
LM_BuildPolygonFromSurface(loadmodel, out);
}
}
LM_EndBuildingLightmaps();
}
static void
@ -467,8 +459,6 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
lminfos = NULL;
}
LM_BeginBuildingLightmaps(loadmodel);
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum, lightofs;
@ -559,8 +549,6 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
LM_BuildPolygonFromSurface(loadmodel, out);
}
}
LM_EndBuildingLightmaps();
}
static void
@ -655,6 +643,9 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)R_FindImage,
r_notexture, maptype);
LM_BeginBuildingLightmaps(mod);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
@ -671,6 +662,9 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
{
Mod_LoadQFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
}
LM_EndBuildingLightmaps();
Mod_LoadQBSPMarksurfaces(mod->name, &mod->marksurfaces, &mod->nummarksurfaces,
mod->surfaces, mod->numsurfaces, mod_base, &header->lumps[LUMP_LEAFFACES],
header->ident);

View file

@ -212,8 +212,6 @@ Mod_LoadFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
lminfos = NULL;
}
LM_BeginBuildingLightmaps(loadmodel);
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum, lightofs;
@ -304,8 +302,6 @@ Mod_LoadFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
LM_BuildPolygonFromSurface(loadmodel, out);
}
}
LM_EndBuildingLightmaps();
}
static void
@ -340,8 +336,6 @@ Mod_LoadRFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
lminfos = NULL;
}
LM_BeginBuildingLightmaps(loadmodel);
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum, lightofs;
@ -432,8 +426,6 @@ Mod_LoadRFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
LM_BuildPolygonFromSurface(loadmodel, out);
}
}
LM_EndBuildingLightmaps();
}
static void
@ -468,8 +460,6 @@ Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
lminfos = NULL;
}
LM_BeginBuildingLightmaps(loadmodel);
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum, lightofs;
@ -560,8 +550,6 @@ Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
LM_BuildPolygonFromSurface(loadmodel, out);
}
}
LM_EndBuildingLightmaps();
}
static void
@ -656,6 +644,9 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)GL3_FindImage,
gl3_notexture, maptype);
LM_BeginBuildingLightmaps(mod);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
@ -672,6 +663,9 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
{
Mod_LoadQFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
}
LM_EndBuildingLightmaps();
Mod_LoadQBSPMarksurfaces(mod->name, &mod->marksurfaces, &mod->nummarksurfaces,
mod->surfaces, mod->numsurfaces, mod_base, &header->lumps[LUMP_LEAFFACES],
header->ident);

View file

@ -212,8 +212,6 @@ Mod_LoadFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
lminfos = NULL;
}
LM_BeginBuildingLightmaps(loadmodel);
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum, lightofs;
@ -304,8 +302,6 @@ Mod_LoadFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
LM_BuildPolygonFromSurface(loadmodel, out);
}
}
LM_EndBuildingLightmaps();
}
static void
@ -340,8 +336,6 @@ Mod_LoadRFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
lminfos = NULL;
}
LM_BeginBuildingLightmaps(loadmodel);
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum, lightofs;
@ -432,8 +426,6 @@ Mod_LoadRFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
LM_BuildPolygonFromSurface(loadmodel, out);
}
}
LM_EndBuildingLightmaps();
}
static void
@ -468,8 +460,6 @@ Mod_LoadQFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
lminfos = NULL;
}
LM_BeginBuildingLightmaps(loadmodel);
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum, lightofs;
@ -560,8 +550,6 @@ Mod_LoadQFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
LM_BuildPolygonFromSurface(loadmodel, out);
}
}
LM_EndBuildingLightmaps();
}
static void
@ -656,6 +644,9 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)GL4_FindImage,
gl4_notexture, maptype);
LM_BeginBuildingLightmaps(mod);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
@ -672,6 +663,9 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
{
Mod_LoadQFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
}
LM_EndBuildingLightmaps();
Mod_LoadQBSPMarksurfaces(mod->name, &mod->marksurfaces, &mod->nummarksurfaces,
mod->surfaces, mod->numsurfaces, mod_base, &header->lumps[LUMP_LEAFFACES],
header->ident);

View file

@ -32,11 +32,10 @@
static YQ2_ALIGNAS_TYPE(int) byte mod_novis[MAX_MAP_LEAFS / 8];
static model_t mod_known[MAX_MOD_KNOWN];
static int mod_numknown = 0;
static int mod_max = 0;
int registration_sequence;
static model_t mod_known[MAX_MOD_KNOWN];
static int mod_numknown = 0;
static int mod_max = 0;
int registration_sequence;
//===============================================================================
@ -330,7 +329,7 @@ Mod_LoadRFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
int side, ti, planenum, lightofs;
out->firstedge = LittleLong(in->firstedge);
out->numedges = LittleLong(in->numedges);
out->numedges = LittleShort(in->numedges);
if (out->numedges < 3)
{
@ -340,8 +339,8 @@ Mod_LoadRFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
out->flags = 0;
out->polys = NULL;
planenum = LittleLong(in->planenum);
side = LittleLong(in->side);
planenum = LittleShort(in->planenum);
side = LittleShort(in->side);
if (side)
{
@ -355,7 +354,7 @@ Mod_LoadRFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
}
out->plane = loadmodel->planes + planenum;
ti = LittleLong(in->texinfo);
ti = LittleShort(in->texinfo);
if ((ti < 0) || (ti >= loadmodel->numtexinfo))
{

View file

@ -186,8 +186,6 @@ Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
lminfos = NULL;
}
LM_BeginBuildingLightmaps(loadmodel);
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum, lightofs;
@ -278,8 +276,6 @@ Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
LM_BuildPolygonFromSurface(loadmodel, out);
}
}
LM_EndBuildingLightmaps();
}
static void
@ -314,8 +310,6 @@ Mod_LoadRFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
lminfos = NULL;
}
LM_BeginBuildingLightmaps(loadmodel);
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum, lightofs;
@ -406,8 +400,6 @@ Mod_LoadRFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
LM_BuildPolygonFromSurface(loadmodel, out);
}
}
LM_EndBuildingLightmaps();
}
static void
@ -442,8 +434,6 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
lminfos = NULL;
}
LM_BeginBuildingLightmaps(loadmodel);
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum, lightofs;
@ -534,8 +524,6 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
LM_BuildPolygonFromSurface(loadmodel, out);
}
}
LM_EndBuildingLightmaps();
}
static void
@ -630,6 +618,9 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)Vk_FindImage,
r_notexture, maptype);
LM_BeginBuildingLightmaps(mod);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
@ -646,6 +637,9 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
{
Mod_LoadQFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
}
LM_EndBuildingLightmaps();
Mod_LoadQBSPMarksurfaces(mod->name, &mod->marksurfaces, &mod->nummarksurfaces,
mod->surfaces, mod->numsurfaces, mod_base, &header->lumps[LUMP_LEAFFACES],
header->ident);