diff --git a/src/client/refresh/files/models.c b/src/client/refresh/files/models.c index 7c1aaec6..8603ab23 100644 --- a/src/client/refresh/files/models.c +++ b/src/client/refresh/files/models.c @@ -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]; diff --git a/src/client/refresh/gl1/gl1_model.c b/src/client/refresh/gl1/gl1_model.c index 9af59f3f..6484b09c 100644 --- a/src/client/refresh/gl1/gl1_model.c +++ b/src/client/refresh/gl1/gl1_model.c @@ -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, diff --git a/src/client/refresh/gl3/gl3_model.c b/src/client/refresh/gl3/gl3_model.c index b406bf87..1e6618f8 100644 --- a/src/client/refresh/gl3/gl3_model.c +++ b/src/client/refresh/gl3/gl3_model.c @@ -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, diff --git a/src/client/refresh/gl4/gl4_model.c b/src/client/refresh/gl4/gl4_model.c index 4bd077f5..d27bb542 100644 --- a/src/client/refresh/gl4/gl4_model.c +++ b/src/client/refresh/gl4/gl4_model.c @@ -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, diff --git a/src/client/refresh/ref_shared.h b/src/client/refresh/ref_shared.h index af684384..89cdc18f 100644 --- a/src/client/refresh/ref_shared.h +++ b/src/client/refresh/ref_shared.h @@ -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); diff --git a/src/client/refresh/soft/sw_model.c b/src/client/refresh/soft/sw_model.c index 89fa78d8..5c0316b1 100644 --- a/src/client/refresh/soft/sw_model.c +++ b/src/client/refresh/soft/sw_model.c @@ -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, diff --git a/src/client/refresh/vk/vk_model.c b/src/client/refresh/vk/vk_model.c index 3463036c..22d1bceb 100644 --- a/src/client/refresh/vk/vk_model.c +++ b/src/client/refresh/vk/vk_model.c @@ -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,