renders: reuse CalcLumpHunkSize for Leaf and Nodes

This commit is contained in:
Denis Pauk 2024-04-07 00:16:43 +03:00
parent 851c72f7b4
commit d2e5955547
7 changed files with 37 additions and 137 deletions

View file

@ -1358,7 +1358,8 @@ calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *t
} }
int int
calcTexinfoFacesLeafsSize(const byte *mod_base, const dheader_t *header) calcTexinfoFacesLeafsSize(const byte *mod_base, const dheader_t *header,
maptype_t maptype)
{ {
int hunkSize = 0; int hunkSize = 0;
@ -1378,6 +1379,34 @@ calcTexinfoFacesLeafsSize(const byte *mod_base, const dheader_t *header)
sizeof(int), sizeof(msurface_t *), 0); // yes, out is indeed a pointer! sizeof(int), sizeof(msurface_t *), 0); // yes, out is indeed a pointer!
} }
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VISIBILITY],
1, 1, 0);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
if ((maptype == map_daikatana) &&
(header->lumps[LUMP_LEAFS].filelen % sizeof(ddkleaf_t) == 0))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(ddkleaf_t), sizeof(mleaf_t), 0);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dqleaf_t), sizeof(mleaf_t), 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dqnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
hunkSize += 5000000; // and 5MB extra just in case hunkSize += 5000000; // and 5MB extra just in case
return hunkSize; return hunkSize;

View file

@ -510,34 +510,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
1, 1, 0); 1, 1, 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES], hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES); sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES);
hunkSize += calcTexinfoFacesLeafsSize(mod_base, header); hunkSize += calcTexinfoFacesLeafsSize(mod_base, header, maptype);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VISIBILITY],
1, 1, 0);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
if ((maptype == map_daikatana) &&
(header->lumps[LUMP_LEAFS].filelen % sizeof(ddkleaf_t) == 0))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(ddkleaf_t), sizeof(mleaf_t), 0);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dqleaf_t), sizeof(mleaf_t), 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dqnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS], hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS],
sizeof(dmodel_t), sizeof(model_t), 0); sizeof(dmodel_t), sizeof(model_t), 0);

View file

@ -511,34 +511,8 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
1, 1, 0); 1, 1, 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES], hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES); sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES);
hunkSize += calcTexinfoFacesLeafsSize(mod_base, header); hunkSize += calcTexinfoFacesLeafsSize(mod_base, header, maptype);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VISIBILITY],
1, 1, 0);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
if ((maptype == map_daikatana) &&
(header->lumps[LUMP_LEAFS].filelen % sizeof(ddkleaf_t) == 0))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(ddkleaf_t), sizeof(mleaf_t), 0);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dqleaf_t), sizeof(mleaf_t), 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dqnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS], hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS],
sizeof(dmodel_t), sizeof(gl3model_t), 0); sizeof(dmodel_t), sizeof(gl3model_t), 0);

View file

@ -511,34 +511,8 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
1, 1, 0); 1, 1, 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES], hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES); sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES);
hunkSize += calcTexinfoFacesLeafsSize(mod_base, header); hunkSize += calcTexinfoFacesLeafsSize(mod_base, header, maptype);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VISIBILITY],
1, 1, 0);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
if ((maptype == map_daikatana) &&
(header->lumps[LUMP_LEAFS].filelen % sizeof(ddkleaf_t) == 0))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(ddkleaf_t), sizeof(mleaf_t), 0);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dqleaf_t), sizeof(mleaf_t), 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dqnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS], hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS],
sizeof(dmodel_t), sizeof(gl4model_t), 0); sizeof(dmodel_t), sizeof(gl4model_t), 0);

View file

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

View file

@ -497,34 +497,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
1, 1, 0); 1, 1, 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES], hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES); sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES);
hunkSize += calcTexinfoFacesLeafsSize(mod_base, header); hunkSize += calcTexinfoFacesLeafsSize(mod_base, header, maptype);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VISIBILITY],
1, 1, 0);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
if ((maptype == map_daikatana) &&
(header->lumps[LUMP_LEAFS].filelen % sizeof(ddkleaf_t) == 0))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(ddkleaf_t), sizeof(mleaf_t), 0);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dqleaf_t), sizeof(mleaf_t), 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dqnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS], hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS],
sizeof(dmodel_t), sizeof(model_t), 0); sizeof(dmodel_t), sizeof(model_t), 0);

View file

@ -485,34 +485,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
1, 1, 0); 1, 1, 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES], hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES); sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES);
hunkSize += calcTexinfoFacesLeafsSize(mod_base, header); hunkSize += calcTexinfoFacesLeafsSize(mod_base, header, maptype);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VISIBILITY],
1, 1, 0);
if ((header->ident == IDBSPHEADER) ||
(header->ident == RBSPHEADER))
{
if ((maptype == map_daikatana) &&
(header->lumps[LUMP_LEAFS].filelen % sizeof(ddkleaf_t) == 0))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(ddkleaf_t), sizeof(mleaf_t), 0);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dqleaf_t), sizeof(mleaf_t), 0);
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dqnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS], hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS],
sizeof(dmodel_t), sizeof(model_t), 0); sizeof(dmodel_t), sizeof(model_t), 0);