Share Mod_LoadQBSPEdges between renders

This commit is contained in:
Denis Pauk 2023-10-07 16:37:42 +03:00
parent d2468c9b66
commit b1b3ff1992
7 changed files with 70 additions and 110 deletions

View file

@ -1860,7 +1860,7 @@ Mod_LoadEdges
extra is used for skybox, which adds 6 surfaces
=================
*/
void
static void
Mod_LoadEdges(const char *name, medge_t **edges, int *numedges,
const byte *mod_base, const lump_t *l, int extra)
{
@ -1895,7 +1895,7 @@ Mod_LoadQEdges
extra is used for skybox, which adds 6 surfaces
=================
*/
void
static void
Mod_LoadQEdges(const char *name, medge_t **edges, int *numedges,
const byte *mod_base, const lump_t *l, int extra)
{
@ -1923,6 +1923,20 @@ Mod_LoadQEdges(const char *name, medge_t **edges, int *numedges,
}
}
void
Mod_LoadQBSPEdges(const char *name, medge_t **edges, int *numedges,
const byte *mod_base, const lump_t *l, int extra, int ident)
{
if (ident == IDBSPHEADER)
{
Mod_LoadEdges(name, edges, numedges, mod_base, l, extra);
}
else
{
Mod_LoadQEdges(name, edges, numedges, mod_base, l, extra);
}
}
/*
=================
Mod_LoadPlanes
@ -2437,7 +2451,7 @@ static float ReadFloat(struct rctx_s *ctx)
}
bspxlightgrid_t*
BSPX_LightGridLoad(const bspx_header_t *bspx_header, const byte *mod_base)
Mod_LoadBSPXLightGrid(const bspx_header_t *bspx_header, const byte *mod_base)
{
vec3_t step, mins;
int size[3];

View file

@ -590,10 +590,10 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
static void
Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
{
const bspx_header_t *bspx_header;
byte *mod_base;
dheader_t *header;
int i;
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
dheader_t *header;
byte *mod_base;
if (mod != mod_known)
{
@ -669,14 +669,10 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(model_t), 0);
/* Get size of octree on disk, need to recheck real size */
if (Mod_LoadBSPXFindLump(bspx_header, "LIGHTGRID_OCTREE", &lightgridsize, mod_base))
{
int lightgridsize = 0;
/* Get size of octree on disk, need to recheck real size */
if (Mod_LoadBSPXFindLump(bspx_header, "LIGHTGRID_OCTREE", &lightgridsize, mod_base))
{
hunkSize += lightgridsize * 4;
}
hunkSize += lightgridsize * 4;
}
mod->extradata = Hunk_Begin(hunkSize);
@ -684,7 +680,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
if (bspx_header)
{
mod->grid = BSPX_LightGridLoad(bspx_header, mod_base);
mod->grid = Mod_LoadBSPXLightGrid(bspx_header, mod_base);
}
else
{
@ -694,16 +690,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
/* load into heap */
Mod_LoadVertexes(mod->name, &mod->vertexes, &mod->numvertexes, mod_base,
&header->lumps[LUMP_VERTEXES], 0);
if (header->ident == IDBSPHEADER)
{
Mod_LoadEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 1);
}
else
{
Mod_LoadQEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 1);
}
Mod_LoadQBSPEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 1, header->ident);
Mod_LoadSurfedges(mod->name, &mod->surfedges, &mod->numsurfedges,
mod_base, &header->lumps[LUMP_SURFEDGES], 0);
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,

View file

@ -556,10 +556,10 @@ Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
static void
Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
{
const bspx_header_t *bspx_header;
byte *mod_base;
dheader_t *header;
int i;
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
dheader_t *header;
byte *mod_base;
if (mod != mod_known)
{
@ -635,14 +635,10 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(gl3model_t), 0);
/* Get size of octree on disk, need to recheck real size */
if (Mod_LoadBSPXFindLump(bspx_header, "LIGHTGRID_OCTREE", &lightgridsize, mod_base))
{
int lightgridsize = 0;
/* Get size of octree on disk, need to recheck real size */
if (Mod_LoadBSPXFindLump(bspx_header, "LIGHTGRID_OCTREE", &lightgridsize, mod_base))
{
hunkSize += lightgridsize * 4;
}
hunkSize += lightgridsize * 4;
}
mod->extradata = Hunk_Begin(hunkSize);
@ -650,7 +646,7 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
if (bspx_header)
{
mod->grid = BSPX_LightGridLoad(bspx_header, mod_base);
mod->grid = Mod_LoadBSPXLightGrid(bspx_header, mod_base);
}
else
{
@ -660,16 +656,8 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
/* load into heap */
Mod_LoadVertexes(mod->name, &mod->vertexes, &mod->numvertexes, mod_base,
&header->lumps[LUMP_VERTEXES], 0);
if (header->ident == IDBSPHEADER)
{
Mod_LoadEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 1);
}
else
{
Mod_LoadQEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 1);
}
Mod_LoadQBSPEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 1, header->ident);
Mod_LoadSurfedges(mod->name, &mod->surfedges, &mod->numsurfedges,
mod_base, &header->lumps[LUMP_SURFEDGES], 0);
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,

View file

@ -412,10 +412,10 @@ Mod_LoadLeafs(gl4model_t *loadmodel, byte *mod_base, lump_t *l)
static void
Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
{
const bspx_header_t *bspx_header;
byte *mod_base;
dheader_t *header;
int i;
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
dheader_t *header;
byte *mod_base;
if (mod != mod_known)
{
@ -460,14 +460,10 @@ Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES], sizeof(dnode_t), sizeof(mnode_t), 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(gl4model_t), 0);
/* Get size of octree on disk, need to recheck real size */
if (Mod_LoadBSPXFindLump(bspx_header, "LIGHTGRID_OCTREE", &lightgridsize, mod_base))
{
int lightgridsize = 0;
/* Get size of octree on disk, need to recheck real size */
if (Mod_LoadBSPXFindLump(bspx_header, "LIGHTGRID_OCTREE", &lightgridsize, mod_base))
{
hunkSize += lightgridsize * 4;
}
hunkSize += lightgridsize * 4;
}
mod->extradata = Hunk_Begin(hunkSize);
@ -475,7 +471,7 @@ Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
if (bspx_header)
{
mod->grid = BSPX_LightGridLoad(bspx_header, mod_base);
mod->grid = Mod_LoadBSPXLightGrid(bspx_header, mod_base);
}
else
{
@ -485,8 +481,8 @@ Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
/* load into heap */
Mod_LoadVertexes(mod->name, &mod->vertexes, &mod->numvertexes, mod_base,
&header->lumps[LUMP_VERTEXES], 0);
Mod_LoadEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 1);
Mod_LoadQBSPEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 1, header->ident);
Mod_LoadSurfedges(mod->name, &mod->surfedges, &mod->numsurfedges,
mod_base, &header->lumps[LUMP_SURFEDGES], 0);
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,

View file

@ -337,6 +337,8 @@ extern void Mod_LoadQBSPNodes(const char *name, cplane_t *planes, int numplanes,
extern void Mod_LoadQBSPLeafs(const char *name, mleaf_t **leafs, int *numleafs,
msurface_t **marksurfaces, int nummarksurfaces,
const byte *mod_base, const lump_t *l, int ident);
extern void Mod_LoadQBSPEdges(const char *name, medge_t **edges, int *numedges,
const byte *mod_base, const lump_t *l, int extra, int ident);
extern void Mod_LoadVertexes(const char *name, mvertex_t **vertexes, int *numvertexes,
const byte *mod_base, const lump_t *l, int extra);
extern void Mod_LoadVisibility(dvis_t **vis, const byte *mod_base, const lump_t *l);
@ -347,10 +349,6 @@ extern void Mod_CalcSurfaceExtents(int *surfedges, mvertex_t *vertexes, medge_t
extern void Mod_LoadTexinfo(const char *name, mtexinfo_t **texinfo, int *numtexinfo,
const byte *mod_base, const lump_t *l, findimage_t find_image,
struct image_s *notexture, int extra);
extern void Mod_LoadEdges(const char *name, medge_t **edges, int *numedges,
const byte *mod_base, const lump_t *l, int extra);
extern void Mod_LoadQEdges(const char *name, medge_t **edges, int *numedges,
const byte *mod_base, const lump_t *l, int extra);
extern void Mod_LoadPlanes(const char *name, cplane_t **planes, int *numplanes,
const byte *mod_base, const lump_t *l, int extra);
extern void Mod_LoadSurfedges(const char *name, int **surfedges, int *numsurfedges,
@ -379,7 +377,7 @@ extern void R_SetFrustum(vec3_t vup, vec3_t vpn, vec3_t vright, vec3_t r_origin,
extern void R_BoundPoly(int numverts, float *verts, vec3_t mins, vec3_t maxs);
/* Lights logic */
extern bspxlightgrid_t *BSPX_LightGridLoad(const bspx_header_t *bspx_header, const byte *mod_base);
extern bspxlightgrid_t *Mod_LoadBSPXLightGrid(const bspx_header_t *bspx_header, const byte *mod_base);
extern void R_LightPoint(const bspxlightgrid_t *grid, const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot);

View file

@ -405,10 +405,10 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
static void
Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
{
const bspx_header_t *bspx_header;
byte *mod_base;
dheader_t *header;
int i;
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
dheader_t *header;
byte *mod_base;
if (mod != mod_known)
{
@ -487,14 +487,10 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
hunkSize += 5000000; // and 5MB extra just in case
/* Get size of octree on disk, need to recheck real size */
if (Mod_LoadBSPXFindLump(bspx_header, "LIGHTGRID_OCTREE", &lightgridsize, mod_base))
{
int lightgridsize = 0;
/* Get size of octree on disk, need to recheck real size */
if (Mod_LoadBSPXFindLump(bspx_header, "LIGHTGRID_OCTREE", &lightgridsize, mod_base))
{
hunkSize += lightgridsize * 4;
}
hunkSize += lightgridsize * 4;
}
mod->extradata = Hunk_Begin(hunkSize);
@ -502,7 +498,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
if (bspx_header)
{
mod->grid = BSPX_LightGridLoad(bspx_header, mod_base);
mod->grid = Mod_LoadBSPXLightGrid(bspx_header, mod_base);
}
else
{
@ -512,16 +508,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
/* load into heap */
Mod_LoadVertexes(mod->name, &mod->vertexes, &mod->numvertexes, mod_base,
&header->lumps[LUMP_VERTEXES], 8);
if (header->ident == IDBSPHEADER)
{
Mod_LoadEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 13);
}
else
{
Mod_LoadQEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 13);
}
Mod_LoadQBSPEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 13, header->ident);
Mod_LoadSurfedges(mod->name, &mod->surfedges, &mod->numsurfedges,
mod_base, &header->lumps[LUMP_SURFEDGES], 24);
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,

View file

@ -560,10 +560,10 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
static void
Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
{
const bspx_header_t *bspx_header;
byte *mod_base;
dheader_t *header;
int i;
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
dheader_t *header;
byte *mod_base;
if (mod != models_known)
{
@ -639,14 +639,10 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(model_t), 0);
/* Get size of octree on disk, need to recheck real size */
if (Mod_LoadBSPXFindLump(bspx_header, "LIGHTGRID_OCTREE", &lightgridsize, mod_base))
{
int lightgridsize = 0;
/* Get size of octree on disk, need to recheck real size */
if (Mod_LoadBSPXFindLump(bspx_header, "LIGHTGRID_OCTREE", &lightgridsize, mod_base))
{
hunkSize += lightgridsize * 4;
}
hunkSize += lightgridsize * 4;
}
mod->extradata = Hunk_Begin(hunkSize);
@ -654,7 +650,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
if (bspx_header)
{
mod->grid = BSPX_LightGridLoad(bspx_header, mod_base);
mod->grid = Mod_LoadBSPXLightGrid(bspx_header, mod_base);
}
else
{
@ -664,16 +660,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
/* load into heap */
Mod_LoadVertexes(mod->name, &mod->vertexes, &mod->numvertexes, mod_base,
&header->lumps[LUMP_VERTEXES], 0);
if (header->ident == IDBSPHEADER)
{
Mod_LoadEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 1);
}
else
{
Mod_LoadQEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 1);
}
Mod_LoadQBSPEdges(mod->name, &mod->edges, &mod->numedges,
mod_base, &header->lumps[LUMP_EDGES], 1, header->ident);
Mod_LoadSurfedges(mod->name, &mod->surfedges, &mod->numsurfedges,
mod_base, &header->lumps[LUMP_SURFEDGES], 0);
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,