mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-03-06 09:31:55 +00:00
Reuse Mod_LoadPlanes in renders and collision
This commit is contained in:
parent
6f0bf02ece
commit
c5ed6f6ad8
10 changed files with 84 additions and 119 deletions
src
client/refresh
common
|
@ -1907,54 +1907,6 @@ Mod_LoadQBSPEdges(const char *name, medge_t **edges, int *numedges,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
Mod_LoadPlanes
|
|
||||||
|
|
||||||
extra is used for skybox, which adds 6 surfaces
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Mod_LoadPlanes(const char *name, cplane_t **planes, int *numplanes,
|
|
||||||
const byte *mod_base, const lump_t *l, int extra)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
cplane_t *out;
|
|
||||||
dplane_t *in;
|
|
||||||
int count;
|
|
||||||
|
|
||||||
in = (void *)(mod_base + l->fileofs);
|
|
||||||
|
|
||||||
if (l->filelen % sizeof(*in))
|
|
||||||
{
|
|
||||||
Com_Error(ERR_DROP, "%s: funny lump size in %s",
|
|
||||||
__func__, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
count = l->filelen / sizeof(*in);
|
|
||||||
out = Hunk_Alloc((count + extra) * sizeof(*out));
|
|
||||||
|
|
||||||
*planes = out;
|
|
||||||
*numplanes = count;
|
|
||||||
|
|
||||||
for ( i=0 ; i < count ; i++, in++, out++)
|
|
||||||
{
|
|
||||||
int bits, j;
|
|
||||||
|
|
||||||
bits = 0;
|
|
||||||
for (j=0 ; j<3 ; j++)
|
|
||||||
{
|
|
||||||
out->normal[j] = LittleFloat (in->normal[j]);
|
|
||||||
if (out->normal[j] < 0)
|
|
||||||
bits |= 1<<j;
|
|
||||||
}
|
|
||||||
|
|
||||||
out->dist = LittleFloat (in->dist);
|
|
||||||
out->type = LittleLong (in->type);
|
|
||||||
out->signbits = bits;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
Mod_LoadSurfedges
|
Mod_LoadSurfedges
|
||||||
|
|
|
@ -648,7 +648,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||||
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
|
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 0);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1, 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1, 0);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES], sizeof(dplane_t), sizeof(cplane_t)*2, 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
|
||||||
|
sizeof(dplane_t), sizeof(cplane_t), 12);
|
||||||
if (header->ident == IDBSPHEADER)
|
if (header->ident == IDBSPHEADER)
|
||||||
{
|
{
|
||||||
hunkSize += calcTexinfoAndFacesSize(mod_base, &header->lumps[LUMP_FACES], &header->lumps[LUMP_TEXINFO]);
|
hunkSize += calcTexinfoAndFacesSize(mod_base, &header->lumps[LUMP_FACES], &header->lumps[LUMP_TEXINFO]);
|
||||||
|
@ -700,7 +701,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||||
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,
|
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,
|
||||||
&header->lumps[LUMP_LIGHTING]);
|
&header->lumps[LUMP_LIGHTING]);
|
||||||
Mod_LoadPlanes(mod->name, &mod->planes, &mod->numplanes,
|
Mod_LoadPlanes(mod->name, &mod->planes, &mod->numplanes,
|
||||||
mod_base, &header->lumps[LUMP_PLANES], 0);
|
mod_base, &header->lumps[LUMP_PLANES]);
|
||||||
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
|
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
|
||||||
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)R_FindImage,
|
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)R_FindImage,
|
||||||
r_notexture, 0);
|
r_notexture, 0);
|
||||||
|
|
|
@ -611,7 +611,8 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
|
||||||
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
|
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 0);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1, 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1, 0);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES], sizeof(dplane_t), sizeof(cplane_t)*2, 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
|
||||||
|
sizeof(dplane_t), sizeof(cplane_t), 12);
|
||||||
if (header->ident == IDBSPHEADER)
|
if (header->ident == IDBSPHEADER)
|
||||||
{
|
{
|
||||||
hunkSize += calcTexinfoAndFacesSize(mod_base, &header->lumps[LUMP_FACES], &header->lumps[LUMP_TEXINFO]);
|
hunkSize += calcTexinfoAndFacesSize(mod_base, &header->lumps[LUMP_FACES], &header->lumps[LUMP_TEXINFO]);
|
||||||
|
@ -663,7 +664,7 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
|
||||||
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,
|
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,
|
||||||
&header->lumps[LUMP_LIGHTING]);
|
&header->lumps[LUMP_LIGHTING]);
|
||||||
Mod_LoadPlanes(mod->name, &mod->planes, &mod->numplanes,
|
Mod_LoadPlanes(mod->name, &mod->planes, &mod->numplanes,
|
||||||
mod_base, &header->lumps[LUMP_PLANES], 0);
|
mod_base, &header->lumps[LUMP_PLANES]);
|
||||||
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
|
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
|
||||||
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)GL3_FindImage,
|
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)GL3_FindImage,
|
||||||
gl3_notexture, 0);
|
gl3_notexture, 0);
|
||||||
|
|
|
@ -451,7 +451,8 @@ Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
|
||||||
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
|
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 0);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1, 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1, 0);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES], sizeof(dplane_t), sizeof(cplane_t)*2, 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
|
||||||
|
sizeof(dplane_t), sizeof(cplane_t), 12);
|
||||||
hunkSize += calcTexinfoAndFacesSize(mod_base, &header->lumps[LUMP_FACES], &header->lumps[LUMP_TEXINFO]);
|
hunkSize += calcTexinfoAndFacesSize(mod_base, &header->lumps[LUMP_FACES], &header->lumps[LUMP_TEXINFO]);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFFACES], sizeof(short), sizeof(msurface_t *), 0); // yes, out is indeed a pointer!
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFFACES], sizeof(short), sizeof(msurface_t *), 0); // yes, out is indeed a pointer!
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VISIBILITY], 1, 1, 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VISIBILITY], 1, 1, 0);
|
||||||
|
@ -487,7 +488,7 @@ Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
|
||||||
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,
|
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,
|
||||||
&header->lumps[LUMP_LIGHTING]);
|
&header->lumps[LUMP_LIGHTING]);
|
||||||
Mod_LoadPlanes (mod->name, &mod->planes, &mod->numplanes,
|
Mod_LoadPlanes (mod->name, &mod->planes, &mod->numplanes,
|
||||||
mod_base, &header->lumps[LUMP_PLANES], 0);
|
mod_base, &header->lumps[LUMP_PLANES]);
|
||||||
Mod_LoadTexinfo (mod->name, &mod->texinfo, &mod->numtexinfo,
|
Mod_LoadTexinfo (mod->name, &mod->texinfo, &mod->numtexinfo,
|
||||||
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)GL4_FindImage,
|
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)GL4_FindImage,
|
||||||
gl4_notexture, 0);
|
gl4_notexture, 0);
|
||||||
|
|
|
@ -350,8 +350,6 @@ extern void Mod_CalcSurfaceExtents(int *surfedges, mvertex_t *vertexes, medge_t
|
||||||
extern void Mod_LoadTexinfo(const char *name, mtexinfo_t **texinfo, int *numtexinfo,
|
extern void Mod_LoadTexinfo(const char *name, mtexinfo_t **texinfo, int *numtexinfo,
|
||||||
const byte *mod_base, const lump_t *l, findimage_t find_image,
|
const byte *mod_base, const lump_t *l, findimage_t find_image,
|
||||||
struct image_s *notexture, int extra);
|
struct image_s *notexture, 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,
|
extern void Mod_LoadSurfedges(const char *name, int **surfedges, int *numsurfedges,
|
||||||
const byte *mod_base, const lump_t *l, int extra);
|
const byte *mod_base, const lump_t *l, int extra);
|
||||||
extern mleaf_t *Mod_PointInLeaf(const vec3_t p, mnode_t *node);
|
extern mleaf_t *Mod_PointInLeaf(const vec3_t p, mnode_t *node);
|
||||||
|
|
|
@ -462,7 +462,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 24);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 24);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_TEXINFO], sizeof(texinfo_t), sizeof(mtexinfo_t), 6);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_TEXINFO], sizeof(texinfo_t), sizeof(mtexinfo_t), 6);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1, 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1, 0);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES], sizeof(dplane_t), sizeof(cplane_t)*2, 6);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
|
||||||
|
sizeof(dplane_t), sizeof(cplane_t), 12);
|
||||||
if (header->ident == IDBSPHEADER)
|
if (header->ident == IDBSPHEADER)
|
||||||
{
|
{
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_FACES], sizeof(dface_t), sizeof(msurface_t), 6);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_FACES], sizeof(dface_t), sizeof(msurface_t), 6);
|
||||||
|
@ -516,7 +517,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||||
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,
|
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,
|
||||||
&header->lumps[LUMP_LIGHTING]);
|
&header->lumps[LUMP_LIGHTING]);
|
||||||
Mod_LoadPlanes(mod->name, &mod->planes, &mod->numplanes,
|
Mod_LoadPlanes(mod->name, &mod->planes, &mod->numplanes,
|
||||||
mod_base, &header->lumps[LUMP_PLANES], 6);
|
mod_base, &header->lumps[LUMP_PLANES]);
|
||||||
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
|
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
|
||||||
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)R_FindImage,
|
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)R_FindImage,
|
||||||
r_notexture_mip, 6);
|
r_notexture_mip, 6);
|
||||||
|
|
|
@ -618,7 +618,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||||
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
|
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 0);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1, 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1, 0);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES], sizeof(dplane_t), sizeof(cplane_t)*2, 0);
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
|
||||||
|
sizeof(dplane_t), sizeof(cplane_t), 12);
|
||||||
if (header->ident == IDBSPHEADER)
|
if (header->ident == IDBSPHEADER)
|
||||||
{
|
{
|
||||||
hunkSize += calcTexinfoAndFacesSize(mod_base, &header->lumps[LUMP_FACES], &header->lumps[LUMP_TEXINFO]);
|
hunkSize += calcTexinfoAndFacesSize(mod_base, &header->lumps[LUMP_FACES], &header->lumps[LUMP_TEXINFO]);
|
||||||
|
@ -670,7 +671,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||||
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,
|
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,
|
||||||
&header->lumps[LUMP_LIGHTING]);
|
&header->lumps[LUMP_LIGHTING]);
|
||||||
Mod_LoadPlanes(mod->name, &mod->planes, &mod->numplanes,
|
Mod_LoadPlanes(mod->name, &mod->planes, &mod->numplanes,
|
||||||
mod_base, &header->lumps[LUMP_PLANES], 0);
|
mod_base, &header->lumps[LUMP_PLANES]);
|
||||||
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
|
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
|
||||||
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)Vk_FindImage,
|
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)Vk_FindImage,
|
||||||
r_notexture, 0);
|
r_notexture, 0);
|
||||||
|
|
|
@ -88,3 +88,58 @@ Mod_LoadVisibility(const char *name, dvis_t **vis, int *numvisibility,
|
||||||
out->bitofs[i][1] = LittleLong(out->bitofs[i][1]);
|
out->bitofs[i][1] = LittleLong(out->bitofs[i][1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Mod_LoadPlanes
|
||||||
|
|
||||||
|
extra is used for skybox, which adds 12 surfaces
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Mod_LoadPlanes(const char *name, cplane_t **planes, int *numplanes,
|
||||||
|
const byte *mod_base, const lump_t *l)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
cplane_t *out;
|
||||||
|
dplane_t *in;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
in = (void *)(mod_base + l->fileofs);
|
||||||
|
|
||||||
|
if (l->filelen % sizeof(*in))
|
||||||
|
{
|
||||||
|
Com_Error(ERR_DROP, "%s: Map %s has funny lump size",
|
||||||
|
__func__, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
count = l->filelen / sizeof(*in);
|
||||||
|
if (count < 1)
|
||||||
|
{
|
||||||
|
Com_Error(ERR_DROP, "%s: Map %s with no planes", __func__, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
out = Hunk_Alloc((count + 12) * sizeof(*out));
|
||||||
|
|
||||||
|
*planes = out;
|
||||||
|
*numplanes = count;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++, in++, out++)
|
||||||
|
{
|
||||||
|
int bits, j;
|
||||||
|
|
||||||
|
bits = 0;
|
||||||
|
for (j = 0; j < 3; j++)
|
||||||
|
{
|
||||||
|
out->normal[j] = LittleFloat(in->normal[j]);
|
||||||
|
if (out->normal[j] < 0)
|
||||||
|
{
|
||||||
|
bits |= 1<<j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out->dist = LittleFloat(in->dist);
|
||||||
|
out->type = LittleLong(in->type);
|
||||||
|
out->signbits = bits;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
char name[MAX_QPATH];
|
char name[MAX_QPATH];
|
||||||
|
|
||||||
cplane_t map_planes[MAX_MAP_PLANES+6]; /* extra for box hull */
|
cplane_t *map_planes; /* extra 6 for box hull */
|
||||||
int numplanes;
|
int numplanes;
|
||||||
|
|
||||||
cbrush_t *map_brushes;
|
cbrush_t *map_brushes;
|
||||||
|
@ -351,7 +351,7 @@ CM_InitBoxHull(void)
|
||||||
(cmod.numbrushes <= 0) ||
|
(cmod.numbrushes <= 0) ||
|
||||||
(numleafbrushes + 1 > MAX_MAP_LEAFBRUSHES) ||
|
(numleafbrushes + 1 > MAX_MAP_LEAFBRUSHES) ||
|
||||||
(cmod.numbrushsides <= 0) ||
|
(cmod.numbrushsides <= 0) ||
|
||||||
(cmod.numplanes + 12 > MAX_MAP_PLANES))
|
(cmod.numplanes <= 0))
|
||||||
{
|
{
|
||||||
Com_Error(ERR_DROP, "%s: Not enough room for box tree", __func__);
|
Com_Error(ERR_DROP, "%s: Not enough room for box tree", __func__);
|
||||||
}
|
}
|
||||||
|
@ -1539,58 +1539,6 @@ CMod_LoadQLeafs(int *numclusters, const byte *cmod_base, const lump_t *l)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
CMod_LoadPlanes(const byte *cmod_base, const lump_t *l)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
cplane_t *out;
|
|
||||||
dplane_t *in;
|
|
||||||
int count;
|
|
||||||
int bits;
|
|
||||||
|
|
||||||
in = (void *)(cmod_base + l->fileofs);
|
|
||||||
|
|
||||||
if (l->filelen % sizeof(*in))
|
|
||||||
{
|
|
||||||
Com_Error(ERR_DROP, "%s: funny lump size", __func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
count = l->filelen / sizeof(*in);
|
|
||||||
|
|
||||||
if (count < 1)
|
|
||||||
{
|
|
||||||
Com_Error(ERR_DROP, "%s: Map with no planes", __func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* need to save space for box planes */
|
|
||||||
if (count > MAX_MAP_PLANES)
|
|
||||||
{
|
|
||||||
Com_Error(ERR_DROP, "%s: Map has too many planes", __func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
out = cmod.map_planes;
|
|
||||||
cmod.numplanes = count;
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++, in++, out++)
|
|
||||||
{
|
|
||||||
bits = 0;
|
|
||||||
|
|
||||||
for (j = 0; j < 3; j++)
|
|
||||||
{
|
|
||||||
out->normal[j] = LittleFloat(in->normal[j]);
|
|
||||||
|
|
||||||
if (out->normal[j] < 0)
|
|
||||||
{
|
|
||||||
bits |= 1 << j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
out->dist = LittleFloat(in->dist);
|
|
||||||
out->type = LittleLong(in->type);
|
|
||||||
out->signbits = bits;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CMod_LoadLeafBrushes(const byte *cmod_base, const lump_t *l)
|
CMod_LoadLeafBrushes(const byte *cmod_base, const lump_t *l)
|
||||||
{
|
{
|
||||||
|
@ -1994,14 +1942,14 @@ CM_LoadMap(char *name, qboolean clientload, unsigned *checksum)
|
||||||
CMod_LoadQLeafs(&cmod.numclusters, cmod_base, &header.lumps[LUMP_LEAFS]);
|
CMod_LoadQLeafs(&cmod.numclusters, cmod_base, &header.lumps[LUMP_LEAFS]);
|
||||||
CMod_LoadQLeafBrushes(cmod_base, &header.lumps[LUMP_LEAFBRUSHES]);
|
CMod_LoadQLeafBrushes(cmod_base, &header.lumps[LUMP_LEAFBRUSHES]);
|
||||||
}
|
}
|
||||||
/* TODO: could be shared? Mod_LoadPlanes */
|
|
||||||
CMod_LoadPlanes(cmod_base, &header.lumps[LUMP_PLANES]);
|
|
||||||
|
|
||||||
/* load into heap */
|
/* load into heap */
|
||||||
strcpy(cmod.name, name);
|
strcpy(cmod.name, name);
|
||||||
|
|
||||||
int hunkSize = 0;
|
int hunkSize = 0;
|
||||||
|
|
||||||
|
hunkSize += Mod_CalcLumpHunkSize(&header.lumps[LUMP_PLANES],
|
||||||
|
sizeof(dplane_t), sizeof(cplane_t), 12);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header.lumps[LUMP_BRUSHES],
|
hunkSize += Mod_CalcLumpHunkSize(&header.lumps[LUMP_BRUSHES],
|
||||||
sizeof(dbrush_t), sizeof(cbrush_t), 1);
|
sizeof(dbrush_t), sizeof(cbrush_t), 1);
|
||||||
|
|
||||||
|
@ -2024,11 +1972,15 @@ CM_LoadMap(char *name, qboolean clientload, unsigned *checksum)
|
||||||
sizeof(darea_t), sizeof(carea_t), 0);
|
sizeof(darea_t), sizeof(carea_t), 0);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header.lumps[LUMP_AREAPORTALS],
|
hunkSize += Mod_CalcLumpHunkSize(&header.lumps[LUMP_AREAPORTALS],
|
||||||
sizeof(dareaportal_t), sizeof(dareaportal_t), 0);
|
sizeof(dareaportal_t), sizeof(dareaportal_t), 0);
|
||||||
hunkSize += header.lumps[LUMP_VISIBILITY].filelen;
|
hunkSize += Mod_CalcLumpHunkSize(&header.lumps[LUMP_VISIBILITY],
|
||||||
hunkSize += header.lumps[LUMP_ENTITIES].filelen + MAX_MAP_ENTSTRING;
|
1, 1, 0);
|
||||||
|
hunkSize += Mod_CalcLumpHunkSize(&header.lumps[LUMP_ENTITIES],
|
||||||
|
1, 1, MAX_MAP_ENTSTRING);
|
||||||
|
|
||||||
cmod.extradata = Hunk_Begin(hunkSize);
|
cmod.extradata = Hunk_Begin(hunkSize);
|
||||||
|
|
||||||
|
Mod_LoadPlanes(cmod.name, &cmod.map_planes, &cmod.numplanes,
|
||||||
|
cmod_base, &header.lumps[LUMP_PLANES]);
|
||||||
CMod_LoadBrushes(cmod.name, &cmod.map_brushes, &cmod.numbrushes,
|
CMod_LoadBrushes(cmod.name, &cmod.map_brushes, &cmod.numbrushes,
|
||||||
cmod_base, &header.lumps[LUMP_BRUSHES]);
|
cmod_base, &header.lumps[LUMP_BRUSHES]);
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
#define COMMON_CMODEL_H
|
#define COMMON_CMODEL_H
|
||||||
|
|
||||||
extern int Mod_CalcLumpHunkSize(const lump_t *l, int inSize, int outSize, int extra);
|
extern int Mod_CalcLumpHunkSize(const lump_t *l, int inSize, int outSize, int extra);
|
||||||
extern void Mod_LoadVisibility(const char *name, dvis_t **vis, int *numvisibility, const byte *mod_base, const lump_t *l);
|
extern void Mod_LoadVisibility(const char *name, dvis_t **vis, int *numvisibility,
|
||||||
|
const byte *mod_base, const lump_t *l);
|
||||||
|
extern void Mod_LoadPlanes(const char *name, cplane_t **planes, int *numplanes,
|
||||||
|
const byte *mod_base, const lump_t *l);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue