renders: reuse Mod_CalcNonModelLumpHunkSize

This commit is contained in:
Denis Pauk 2024-04-07 00:52:38 +03:00
parent d2e5955547
commit e90fa70680
7 changed files with 34 additions and 112 deletions

View file

@ -1358,11 +1358,33 @@ calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *t
}
int
calcTexinfoFacesLeafsSize(const byte *mod_base, const dheader_t *header,
Mod_CalcNonModelLumpHunkSize(const byte *mod_base, const dheader_t *header,
maptype_t maptype)
{
int hunkSize = 0;
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VERTEXES],
sizeof(dvertex_t), sizeof(mvertex_t), EXTRA_LUMP_VERTEXES);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
sizeof(dedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
sizeof(dqedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES],
sizeof(int), sizeof(int), EXTRA_LUMP_SURFEDGES);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING],
1, 1, 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{

View file

@ -438,8 +438,8 @@ 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)
{
int i, lightgridsize = 0, hunkSize;
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
maptype_t maptype;
dheader_t *header;
byte *mod_base;
@ -490,27 +490,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
bspx_header = Mod_LoadBSPX(modfilelen, (byte*)header, maptype);
// calculate the needed hunksize from the lumps
int hunkSize = 0;
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VERTEXES],
sizeof(dvertex_t), sizeof(mvertex_t), EXTRA_LUMP_VERTEXES);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
sizeof(dedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
sizeof(dqedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES],
sizeof(int), sizeof(int), EXTRA_LUMP_SURFEDGES);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING],
1, 1, 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES);
hunkSize += calcTexinfoFacesLeafsSize(mod_base, header, maptype);
hunkSize = Mod_CalcNonModelLumpHunkSize(mod_base, header, maptype);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS],
sizeof(dmodel_t), sizeof(model_t), 0);

View file

@ -439,8 +439,8 @@ 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)
{
int i, lightgridsize = 0, hunkSize;
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
maptype_t maptype;
dheader_t *header;
byte *mod_base;
@ -491,27 +491,7 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
bspx_header = Mod_LoadBSPX(modfilelen, (byte*)header, maptype);
// calculate the needed hunksize from the lumps
int hunkSize = 0;
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VERTEXES],
sizeof(dvertex_t), sizeof(mvertex_t), EXTRA_LUMP_VERTEXES);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
sizeof(dedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
sizeof(dqedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES],
sizeof(int), sizeof(int), EXTRA_LUMP_SURFEDGES);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING],
1, 1, 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES);
hunkSize += calcTexinfoFacesLeafsSize(mod_base, header, maptype);
hunkSize = Mod_CalcNonModelLumpHunkSize(mod_base, header, maptype);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS],
sizeof(dmodel_t), sizeof(gl3model_t), 0);

View file

@ -439,8 +439,8 @@ Mod_LoadQFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
static void
Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
{
int i, lightgridsize = 0, hunkSize;
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
maptype_t maptype;
dheader_t *header;
byte *mod_base;
@ -491,27 +491,7 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
bspx_header = Mod_LoadBSPX(modfilelen, (byte*)header, maptype);
// calculate the needed hunksize from the lumps
int hunkSize = 0;
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VERTEXES],
sizeof(dvertex_t), sizeof(mvertex_t), EXTRA_LUMP_VERTEXES);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
sizeof(dedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
sizeof(dqedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES],
sizeof(int), sizeof(int), EXTRA_LUMP_SURFEDGES);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING],
1, 1, 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES);
hunkSize += calcTexinfoFacesLeafsSize(mod_base, header, maptype);
hunkSize = Mod_CalcNonModelLumpHunkSize(mod_base, header, maptype);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS],
sizeof(dmodel_t), sizeof(gl4model_t), 0);

View file

@ -369,7 +369,7 @@ extern const bspx_header_t *Mod_LoadBSPX(int filesize, const byte *mod_base,
maptype_t maptype);
extern int Mod_LoadBSPXDecoupledLM(const dlminfo_t* lminfos, int surfnum, msurface_t *out);
extern int Mod_LoadFile(const char *name, void **buffer);
extern int calcTexinfoFacesLeafsSize(const byte *mod_base, const dheader_t *header,
extern int Mod_CalcNonModelLumpHunkSize(const byte *mod_base, const dheader_t *header,
maptype_t maptype);
/* Surface logic */

View file

@ -425,8 +425,8 @@ 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)
{
int i, lightgridsize = 0, hunkSize;
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
maptype_t maptype;
dheader_t *header;
byte *mod_base;
@ -477,27 +477,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
bspx_header = Mod_LoadBSPX(modfilelen, (byte*)header, maptype);
// calculate the needed hunksize from the lumps
int hunkSize = 0;
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VERTEXES],
sizeof(dvertex_t), sizeof(mvertex_t), EXTRA_LUMP_VERTEXES);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
sizeof(dedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
sizeof(dqedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES],
sizeof(int), sizeof(int), EXTRA_LUMP_SURFEDGES);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING],
1, 1, 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES);
hunkSize += calcTexinfoFacesLeafsSize(mod_base, header, maptype);
hunkSize = Mod_CalcNonModelLumpHunkSize(mod_base, header, maptype);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS],
sizeof(dmodel_t), sizeof(model_t), 0);

View file

@ -413,8 +413,8 @@ 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)
{
int i, lightgridsize = 0, hunkSize;
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
maptype_t maptype;
dheader_t *header;
byte *mod_base;
@ -465,27 +465,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
bspx_header = Mod_LoadBSPX(modfilelen, (byte*)header, maptype);
// calculate the needed hunksize from the lumps
int hunkSize = 0;
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VERTEXES],
sizeof(dvertex_t), sizeof(mvertex_t), EXTRA_LUMP_VERTEXES);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
sizeof(dedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
sizeof(dqedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES],
sizeof(int), sizeof(int), EXTRA_LUMP_SURFEDGES);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING],
1, 1, 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES);
hunkSize += calcTexinfoFacesLeafsSize(mod_base, header, maptype);
hunkSize = Mod_CalcNonModelLumpHunkSize(mod_base, header, maptype);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS],
sizeof(dmodel_t), sizeof(model_t), 0);