mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 20:51:31 +00:00
Share Mod_LoadQBSPLeafs between renders
This commit is contained in:
parent
073f9896f4
commit
1121407e39
6 changed files with 134 additions and 394 deletions
|
@ -2189,6 +2189,123 @@ Mod_LoadBSPXDecoupledLM(const dlminfo_t* lminfos, int surfnum, msurface_t *out)
|
|||
return LittleLong(lminfo->lightofs);
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadLeafs(const char *name, mleaf_t **leafs, int *numleafs,
|
||||
msurface_t **marksurfaces, int nummarksurfaces,
|
||||
const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dleaf_t *in;
|
||||
mleaf_t *out;
|
||||
int i, j, count;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
if (l->filelen % sizeof(*in))
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
|
||||
__func__, name);
|
||||
}
|
||||
|
||||
count = l->filelen / sizeof(*in);
|
||||
out = Hunk_Alloc(count * sizeof(*out));
|
||||
|
||||
*leafs = out;
|
||||
*numleafs = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
unsigned firstleafface;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
out->minmaxs[j] = LittleShort(in->mins[j]);
|
||||
out->minmaxs[3 + j] = LittleShort(in->maxs[j]);
|
||||
}
|
||||
|
||||
out->contents = LittleLong(in->contents);
|
||||
out->cluster = LittleShort(in->cluster);
|
||||
out->area = LittleShort(in->area);
|
||||
|
||||
// make unsigned long from signed short
|
||||
firstleafface = LittleShort(in->firstleafface) & 0xFFFF;
|
||||
out->nummarksurfaces = LittleShort(in->numleaffaces) & 0xFFFF;
|
||||
|
||||
out->firstmarksurface = marksurfaces + firstleafface;
|
||||
if ((firstleafface + out->nummarksurfaces) > nummarksurfaces)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
|
||||
__func__, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadQLeafs(const char *name, mleaf_t **leafs, int *numleafs,
|
||||
msurface_t **marksurfaces, int nummarksurfaces,
|
||||
const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dqleaf_t *in;
|
||||
mleaf_t *out;
|
||||
int i, j, count;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
if (l->filelen % sizeof(*in))
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
|
||||
__func__, name);
|
||||
}
|
||||
|
||||
count = l->filelen / sizeof(*in);
|
||||
out = Hunk_Alloc(count * sizeof(*out));
|
||||
|
||||
*leafs = out;
|
||||
*numleafs = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
unsigned firstleafface;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
out->minmaxs[j] = LittleFloat(in->mins[j]);
|
||||
out->minmaxs[3 + j] = LittleFloat(in->maxs[j]);
|
||||
}
|
||||
|
||||
out->contents = LittleLong(in->contents);
|
||||
out->cluster = LittleLong(in->cluster);
|
||||
out->area = LittleLong(in->area);
|
||||
|
||||
// make unsigned long from signed short
|
||||
firstleafface = LittleLong(in->firstleafface) & 0xFFFFFFFF;
|
||||
out->nummarksurfaces = LittleLong(in->numleaffaces) & 0xFFFFFFFF;
|
||||
|
||||
out->firstmarksurface = marksurfaces + firstleafface;
|
||||
if ((firstleafface + out->nummarksurfaces) > nummarksurfaces)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
|
||||
__func__, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (ident == IDBSPHEADER)
|
||||
{
|
||||
Mod_LoadLeafs(name, leafs, numleafs, marksurfaces, nummarksurfaces,
|
||||
mod_base, l);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mod_LoadQLeafs(name, leafs, numleafs, marksurfaces, nummarksurfaces,
|
||||
mod_base, l);
|
||||
}
|
||||
}
|
||||
|
||||
/* Need to clean */
|
||||
struct rctx_s {
|
||||
const byte *data;
|
||||
|
|
|
@ -587,102 +587,6 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
LM_EndBuildingLightmaps();
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadLeafs(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dleaf_t *in;
|
||||
mleaf_t *out;
|
||||
int i, j, count;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
if (l->filelen % sizeof(*in))
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
|
||||
count = l->filelen / sizeof(*in);
|
||||
out = Hunk_Alloc(count * sizeof(*out));
|
||||
|
||||
loadmodel->leafs = out;
|
||||
loadmodel->numleafs = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
unsigned firstleafface;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
out->minmaxs[j] = LittleShort(in->mins[j]);
|
||||
out->minmaxs[3 + j] = LittleShort(in->maxs[j]);
|
||||
}
|
||||
|
||||
out->contents = LittleLong(in->contents);
|
||||
out->cluster = LittleShort(in->cluster);
|
||||
out->area = LittleShort(in->area);
|
||||
|
||||
// make unsigned long from signed short
|
||||
firstleafface = LittleShort(in->firstleafface) & 0xFFFF;
|
||||
out->nummarksurfaces = LittleShort(in->numleaffaces) & 0xFFFF;
|
||||
|
||||
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
|
||||
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadQLeafs(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dqleaf_t *in;
|
||||
mleaf_t *out;
|
||||
int i, j, count;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
if (l->filelen % sizeof(*in))
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
|
||||
count = l->filelen / sizeof(*in);
|
||||
out = Hunk_Alloc(count * sizeof(*out));
|
||||
|
||||
loadmodel->leafs = out;
|
||||
loadmodel->numleafs = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
unsigned firstleafface;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
out->minmaxs[j] = LittleFloat(in->mins[j]);
|
||||
out->minmaxs[3 + j] = LittleFloat(in->maxs[j]);
|
||||
}
|
||||
|
||||
out->contents = LittleLong(in->contents);
|
||||
out->cluster = LittleLong(in->cluster);
|
||||
out->area = LittleLong(in->area);
|
||||
|
||||
// make unsigned long from signed short
|
||||
firstleafface = LittleLong(in->firstleafface) & 0xFFFFFFFF;
|
||||
out->nummarksurfaces = LittleLong(in->numleaffaces) & 0xFFFFFFFF;
|
||||
|
||||
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
|
||||
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
|
@ -893,16 +797,17 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
|||
Mod_LoadQMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
||||
}
|
||||
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
||||
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
|
||||
mod->marksurfaces, mod->nummarksurfaces, mod_base,
|
||||
&header->lumps[LUMP_LEAFS], header->ident);
|
||||
if (header->ident == IDBSPHEADER)
|
||||
{
|
||||
Mod_LoadLeafs(mod, mod_base, &header->lumps[LUMP_LEAFS]);
|
||||
Mod_LoadNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
|
||||
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
|
||||
&header->lumps[LUMP_NODES]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mod_LoadQLeafs(mod, mod_base, &header->lumps[LUMP_LEAFS]);
|
||||
Mod_LoadQNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
|
||||
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
|
||||
&header->lumps[LUMP_NODES]);
|
||||
|
|
|
@ -553,102 +553,6 @@ Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
GL3_LM_EndBuildingLightmaps();
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadLeafs(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dleaf_t *in;
|
||||
mleaf_t *out;
|
||||
int i, j, count;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
if (l->filelen % sizeof(*in))
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
|
||||
count = l->filelen / sizeof(*in);
|
||||
out = Hunk_Alloc(count * sizeof(*out));
|
||||
|
||||
loadmodel->leafs = out;
|
||||
loadmodel->numleafs = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
unsigned firstleafface;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
out->minmaxs[j] = LittleShort(in->mins[j]);
|
||||
out->minmaxs[3 + j] = LittleShort(in->maxs[j]);
|
||||
}
|
||||
|
||||
out->contents = LittleLong(in->contents);
|
||||
out->cluster = LittleShort(in->cluster);
|
||||
out->area = LittleShort(in->area);
|
||||
|
||||
// make unsigned long from signed short
|
||||
firstleafface = LittleShort(in->firstleafface) & 0xFFFF;
|
||||
out->nummarksurfaces = LittleShort(in->numleaffaces) & 0xFFFF;
|
||||
|
||||
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
|
||||
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadQLeafs(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dqleaf_t *in;
|
||||
mleaf_t *out;
|
||||
int i, j, count;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
if (l->filelen % sizeof(*in))
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
|
||||
count = l->filelen / sizeof(*in);
|
||||
out = Hunk_Alloc(count * sizeof(*out));
|
||||
|
||||
loadmodel->leafs = out;
|
||||
loadmodel->numleafs = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
unsigned firstleafface;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
out->minmaxs[j] = LittleFloat(in->mins[j]);
|
||||
out->minmaxs[3 + j] = LittleFloat(in->maxs[j]);
|
||||
}
|
||||
|
||||
out->contents = LittleLong(in->contents);
|
||||
out->cluster = LittleLong(in->cluster);
|
||||
out->area = LittleLong(in->area);
|
||||
|
||||
// make unsigned long from signed short
|
||||
firstleafface = LittleLong(in->firstleafface) & 0xFFFFFFFF;
|
||||
out->nummarksurfaces = LittleLong(in->numleaffaces) & 0xFFFFFFFF;
|
||||
|
||||
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
|
||||
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadMarksurfaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
|
@ -859,16 +763,17 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
|
|||
Mod_LoadQMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
||||
}
|
||||
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
||||
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
|
||||
mod->marksurfaces, mod->nummarksurfaces, mod_base,
|
||||
&header->lumps[LUMP_LEAFS], header->ident);
|
||||
if (header->ident == IDBSPHEADER)
|
||||
{
|
||||
Mod_LoadLeafs(mod, mod_base, &header->lumps[LUMP_LEAFS]);
|
||||
Mod_LoadNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
|
||||
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
|
||||
&header->lumps[LUMP_NODES]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mod_LoadQLeafs(mod, mod_base, &header->lumps[LUMP_LEAFS]);
|
||||
Mod_LoadQNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
|
||||
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
|
||||
&header->lumps[LUMP_NODES]);
|
||||
|
|
|
@ -348,10 +348,13 @@ 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,
|
||||
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);
|
||||
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 int Mod_CalcLumpHunkSize(const lump_t *l, int inSize, int outSize, int extra);
|
||||
extern mleaf_t *Mod_PointInLeaf(const vec3_t p, mnode_t *node);
|
||||
extern const void *Mod_LoadBSPXFindLump(const bspx_header_t *bspx_header,
|
||||
|
|
|
@ -402,102 +402,6 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadLeafs(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dleaf_t *in;
|
||||
mleaf_t *out;
|
||||
int i, j, count;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
if (l->filelen % sizeof(*in))
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
|
||||
count = l->filelen / sizeof(*in);
|
||||
out = Hunk_Alloc(count * sizeof(*out));
|
||||
|
||||
loadmodel->leafs = out;
|
||||
loadmodel->numleafs = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
unsigned firstleafface;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
out->minmaxs[j] = LittleShort(in->mins[j]);
|
||||
out->minmaxs[3 + j] = LittleShort(in->maxs[j]);
|
||||
}
|
||||
|
||||
out->contents = LittleLong(in->contents);
|
||||
out->cluster = LittleShort(in->cluster);
|
||||
out->area = LittleShort(in->area);
|
||||
|
||||
// make unsigned long from signed short
|
||||
firstleafface = LittleShort(in->firstleafface) & 0xFFFF;
|
||||
out->nummarksurfaces = LittleShort(in->numleaffaces) & 0xFFFF;
|
||||
|
||||
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
|
||||
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadQLeafs(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dqleaf_t *in;
|
||||
mleaf_t *out;
|
||||
int i, j, count;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
if (l->filelen % sizeof(*in))
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
|
||||
count = l->filelen / sizeof(*in);
|
||||
out = Hunk_Alloc(count * sizeof(*out));
|
||||
|
||||
loadmodel->leafs = out;
|
||||
loadmodel->numleafs = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
unsigned firstleafface;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
out->minmaxs[j] = LittleFloat(in->mins[j]);
|
||||
out->minmaxs[3 + j] = LittleFloat(in->maxs[j]);
|
||||
}
|
||||
|
||||
out->contents = LittleLong(in->contents);
|
||||
out->cluster = LittleLong(in->cluster);
|
||||
out->area = LittleLong(in->area);
|
||||
|
||||
// make unsigned long from signed short
|
||||
firstleafface = LittleLong(in->firstleafface) & 0xFFFFFFFF;
|
||||
out->nummarksurfaces = LittleLong(in->numleaffaces) & 0xFFFFFFFF;
|
||||
|
||||
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
|
||||
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
|
@ -711,16 +615,17 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
|||
Mod_LoadQMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
||||
}
|
||||
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
||||
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
|
||||
mod->marksurfaces, mod->nummarksurfaces, mod_base,
|
||||
&header->lumps[LUMP_LEAFS], header->ident);
|
||||
if (header->ident == IDBSPHEADER)
|
||||
{
|
||||
Mod_LoadLeafs(mod, mod_base, &header->lumps[LUMP_LEAFS]);
|
||||
Mod_LoadNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
|
||||
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
|
||||
&header->lumps[LUMP_NODES]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mod_LoadQLeafs(mod, mod_base, &header->lumps[LUMP_LEAFS]);
|
||||
Mod_LoadQNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
|
||||
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
|
||||
&header->lumps[LUMP_NODES]);
|
||||
|
|
|
@ -557,102 +557,6 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
Vk_EndBuildingLightmaps();
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadLeafs(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dleaf_t *in;
|
||||
mleaf_t *out;
|
||||
int i, j, count;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
if (l->filelen % sizeof(*in))
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
|
||||
count = l->filelen / sizeof(*in);
|
||||
out = Hunk_Alloc(count * sizeof(*out));
|
||||
|
||||
loadmodel->leafs = out;
|
||||
loadmodel->numleafs = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
unsigned firstleafface;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
out->minmaxs[j] = LittleShort(in->mins[j]);
|
||||
out->minmaxs[3 + j] = LittleShort(in->maxs[j]);
|
||||
}
|
||||
|
||||
out->contents = LittleLong(in->contents);
|
||||
out->cluster = LittleShort(in->cluster);
|
||||
out->area = LittleShort(in->area);
|
||||
|
||||
// make unsigned long from signed short
|
||||
firstleafface = LittleShort(in->firstleafface) & 0xFFFF;
|
||||
out->nummarksurfaces = LittleShort(in->numleaffaces) & 0xFFFF;
|
||||
|
||||
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
|
||||
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadQLeafs(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dqleaf_t *in;
|
||||
mleaf_t *out;
|
||||
int i, j, count;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
if (l->filelen % sizeof(*in))
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
|
||||
count = l->filelen / sizeof(*in);
|
||||
out = Hunk_Alloc(count * sizeof(*out));
|
||||
|
||||
loadmodel->leafs = out;
|
||||
loadmodel->numleafs = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
unsigned firstleafface;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
out->minmaxs[j] = LittleFloat(in->mins[j]);
|
||||
out->minmaxs[3 + j] = LittleFloat(in->maxs[j]);
|
||||
}
|
||||
|
||||
out->contents = LittleLong(in->contents);
|
||||
out->cluster = LittleLong(in->cluster);
|
||||
out->area = LittleLong(in->area);
|
||||
|
||||
// make unsigned long from signed short
|
||||
firstleafface = LittleLong(in->firstleafface) & 0xFFFFFFFF;
|
||||
out->nummarksurfaces = LittleLong(in->numleaffaces) & 0xFFFFFFFF;
|
||||
|
||||
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
|
||||
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
|
||||
__func__, loadmodel->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
|
@ -863,16 +767,17 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
|||
Mod_LoadQMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
||||
}
|
||||
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
||||
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
|
||||
mod->marksurfaces, mod->nummarksurfaces, mod_base,
|
||||
&header->lumps[LUMP_LEAFS], header->ident);
|
||||
if (header->ident == IDBSPHEADER)
|
||||
{
|
||||
Mod_LoadLeafs(mod, mod_base, &header->lumps[LUMP_LEAFS]);
|
||||
Mod_LoadNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
|
||||
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
|
||||
&header->lumps[LUMP_NODES]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mod_LoadQLeafs(mod, mod_base, &header->lumps[LUMP_LEAFS]);
|
||||
Mod_LoadQNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
|
||||
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
|
||||
&header->lumps[LUMP_NODES]);
|
||||
|
|
Loading…
Reference in a new issue