mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-30 00:10:53 +00:00
Share Mod_LoadQBSPMarksurfaces between renders
This commit is contained in:
parent
d6de468c49
commit
d2468c9b66
7 changed files with 109 additions and 335 deletions
|
@ -2196,6 +2196,97 @@ Mod_LoadBSPXDecoupledLM(const dlminfo_t* lminfos, int surfnum, msurface_t *out)
|
||||||
return LittleLong(lminfo->lightofs);
|
return LittleLong(lminfo->lightofs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
Mod_LoadMarksurfaces(const char *name, msurface_t ***marksurfaces, int *nummarksurfaces,
|
||||||
|
msurface_t *surfaces, int numsurfaces, const byte *mod_base, const lump_t *l)
|
||||||
|
{
|
||||||
|
int i, count;
|
||||||
|
short *in;
|
||||||
|
msurface_t **out;
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
*marksurfaces = out;
|
||||||
|
*nummarksurfaces = count;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
|
||||||
|
j = LittleShort(in[i]);
|
||||||
|
|
||||||
|
if ((j < 0) || (j >= numsurfaces))
|
||||||
|
{
|
||||||
|
ri.Sys_Error(ERR_DROP, "%s: bad surface number",
|
||||||
|
__func__);
|
||||||
|
}
|
||||||
|
|
||||||
|
out[i] = surfaces + j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
Mod_LoadQMarksurfaces(const char *name, msurface_t ***marksurfaces, int *nummarksurfaces,
|
||||||
|
msurface_t *surfaces, int numsurfaces, const byte *mod_base, const lump_t *l)
|
||||||
|
{
|
||||||
|
int i, count;
|
||||||
|
int *in;
|
||||||
|
msurface_t **out;
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
*marksurfaces = out;
|
||||||
|
*nummarksurfaces = count;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
j = LittleLong(in[i]);
|
||||||
|
|
||||||
|
if ((j < 0) || (j >= numsurfaces))
|
||||||
|
{
|
||||||
|
ri.Sys_Error(ERR_DROP, "%s: bad surface number",
|
||||||
|
__func__);
|
||||||
|
}
|
||||||
|
|
||||||
|
out[i] = surfaces + j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Mod_LoadQBSPMarksurfaces(const char *name, msurface_t ***marksurfaces, int *nummarksurfaces,
|
||||||
|
msurface_t *surfaces, int numsurfaces, const byte *mod_base, const lump_t *l, int ident)
|
||||||
|
{
|
||||||
|
if (ident == IDBSPHEADER)
|
||||||
|
{
|
||||||
|
Mod_LoadMarksurfaces(name, marksurfaces, nummarksurfaces,
|
||||||
|
surfaces, numsurfaces, mod_base, l);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Mod_LoadQMarksurfaces(name, marksurfaces, nummarksurfaces,
|
||||||
|
surfaces, numsurfaces, mod_base, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Mod_LoadLeafs(const char *name, mleaf_t **leafs, int *numleafs,
|
Mod_LoadLeafs(const char *name, mleaf_t **leafs, int *numleafs,
|
||||||
msurface_t **marksurfaces, int nummarksurfaces,
|
msurface_t **marksurfaces, int nummarksurfaces,
|
||||||
|
|
|
@ -587,79 +587,6 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
||||||
LM_EndBuildingLightmaps();
|
LM_EndBuildingLightmaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
Mod_LoadMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
|
||||||
{
|
|
||||||
int i, count;
|
|
||||||
short *in;
|
|
||||||
msurface_t **out;
|
|
||||||
|
|
||||||
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->marksurfaces = out;
|
|
||||||
loadmodel->nummarksurfaces = count;
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
j = LittleShort(in[i]);
|
|
||||||
|
|
||||||
if ((j < 0) || (j >= loadmodel->numsurfaces))
|
|
||||||
{
|
|
||||||
ri.Sys_Error(ERR_DROP, "%s: bad surface number",
|
|
||||||
__func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
out[i] = loadmodel->surfaces + j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
Mod_LoadQMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
|
||||||
{
|
|
||||||
int i, count;
|
|
||||||
int *in;
|
|
||||||
msurface_t **out;
|
|
||||||
|
|
||||||
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->marksurfaces = out;
|
|
||||||
loadmodel->nummarksurfaces = count;
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
j = LittleLong(in[i]);
|
|
||||||
|
|
||||||
if ((j < 0) || (j >= loadmodel->numsurfaces))
|
|
||||||
{
|
|
||||||
ri.Sys_Error(ERR_DROP, "%s: bad surface number",
|
|
||||||
__func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
out[i] = loadmodel->surfaces + j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||||
{
|
{
|
||||||
|
@ -789,13 +716,14 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||||
if (header->ident == IDBSPHEADER)
|
if (header->ident == IDBSPHEADER)
|
||||||
{
|
{
|
||||||
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
||||||
Mod_LoadMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Mod_LoadQFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
Mod_LoadQFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
||||||
Mod_LoadQMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
|
||||||
}
|
}
|
||||||
|
Mod_LoadQBSPMarksurfaces(mod->name, &mod->marksurfaces, &mod->nummarksurfaces,
|
||||||
|
mod->surfaces, mod->numsurfaces, mod_base, &header->lumps[LUMP_LEAFFACES],
|
||||||
|
header->ident);
|
||||||
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
||||||
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
|
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
|
||||||
mod->marksurfaces, mod->nummarksurfaces, mod_base,
|
mod->marksurfaces, mod->nummarksurfaces, mod_base,
|
||||||
|
|
|
@ -553,79 +553,6 @@ Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
||||||
GL3_LM_EndBuildingLightmaps();
|
GL3_LM_EndBuildingLightmaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
Mod_LoadMarksurfaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
|
||||||
{
|
|
||||||
int i, count;
|
|
||||||
short *in;
|
|
||||||
msurface_t **out;
|
|
||||||
|
|
||||||
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->marksurfaces = out;
|
|
||||||
loadmodel->nummarksurfaces = count;
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
j = LittleShort(in[i]);
|
|
||||||
|
|
||||||
if ((j < 0) || (j >= loadmodel->numsurfaces))
|
|
||||||
{
|
|
||||||
ri.Sys_Error(ERR_DROP, "%s: bad surface number",
|
|
||||||
__func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
out[i] = loadmodel->surfaces + j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
Mod_LoadQMarksurfaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
|
||||||
{
|
|
||||||
int i, count;
|
|
||||||
int *in;
|
|
||||||
msurface_t **out;
|
|
||||||
|
|
||||||
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->marksurfaces = out;
|
|
||||||
loadmodel->nummarksurfaces = count;
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
j = LittleLong(in[i]);
|
|
||||||
|
|
||||||
if ((j < 0) || (j >= loadmodel->numsurfaces))
|
|
||||||
{
|
|
||||||
ri.Sys_Error(ERR_DROP, "%s: bad surface number",
|
|
||||||
__func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
out[i] = loadmodel->surfaces + j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
|
Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
|
||||||
{
|
{
|
||||||
|
@ -755,13 +682,14 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
|
||||||
if (header->ident == IDBSPHEADER)
|
if (header->ident == IDBSPHEADER)
|
||||||
{
|
{
|
||||||
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
||||||
Mod_LoadMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Mod_LoadQFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
Mod_LoadQFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
||||||
Mod_LoadQMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
|
||||||
}
|
}
|
||||||
|
Mod_LoadQBSPMarksurfaces(mod->name, &mod->marksurfaces, &mod->nummarksurfaces,
|
||||||
|
mod->surfaces, mod->numsurfaces, mod_base, &header->lumps[LUMP_LEAFFACES],
|
||||||
|
header->ident);
|
||||||
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
||||||
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
|
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
|
||||||
mod->marksurfaces, mod->nummarksurfaces, mod_base,
|
mod->marksurfaces, mod->nummarksurfaces, mod_base,
|
||||||
|
|
|
@ -409,40 +409,6 @@ Mod_LoadLeafs(gl4model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
Mod_LoadMarksurfaces(gl4model_t *loadmodel, byte *mod_base, lump_t *l)
|
|
||||||
{
|
|
||||||
int i, j, count;
|
|
||||||
short *in;
|
|
||||||
msurface_t **out;
|
|
||||||
|
|
||||||
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->marksurfaces = out;
|
|
||||||
loadmodel->nummarksurfaces = count;
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
j = LittleShort(in[i]);
|
|
||||||
|
|
||||||
if ((j < 0) || (j >= loadmodel->numsurfaces))
|
|
||||||
{
|
|
||||||
ri.Sys_Error(ERR_DROP, "%s: bad surface number", __func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
out[i] = loadmodel->surfaces + j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
|
Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
|
||||||
{
|
{
|
||||||
|
@ -531,7 +497,9 @@ Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
|
||||||
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);
|
||||||
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES]);
|
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES]);
|
||||||
Mod_LoadMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
Mod_LoadQBSPMarksurfaces(mod->name, &mod->marksurfaces, &mod->nummarksurfaces,
|
||||||
|
mod->surfaces, mod->numsurfaces, mod_base, &header->lumps[LUMP_LEAFFACES],
|
||||||
|
header->ident);
|
||||||
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
||||||
Mod_LoadLeafs(mod, mod_base, &header->lumps[LUMP_LEAFS]);
|
Mod_LoadLeafs(mod, mod_base, &header->lumps[LUMP_LEAFS]);
|
||||||
Mod_LoadQBSPNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
|
Mod_LoadQBSPNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
|
||||||
|
|
|
@ -328,6 +328,9 @@ extern struct image_s *GetTexImage(const char *name, findimage_t find_image);
|
||||||
extern struct image_s *R_FindPic(const char *name, findimage_t find_image);
|
extern struct image_s *R_FindPic(const char *name, findimage_t find_image);
|
||||||
extern struct image_s* R_LoadImage(const char *name, const char* namewe, const char *ext,
|
extern struct image_s* R_LoadImage(const char *name, const char* namewe, const char *ext,
|
||||||
imagetype_t type, qboolean r_retexturing, loadimage_t load_image);
|
imagetype_t type, qboolean r_retexturing, loadimage_t load_image);
|
||||||
|
extern void Mod_LoadQBSPMarksurfaces(const char *name, msurface_t ***marksurfaces,
|
||||||
|
int *nummarksurfaces, msurface_t *surfaces, int numsurfaces,
|
||||||
|
const byte *mod_base, const lump_t *l, int ident);
|
||||||
extern void Mod_LoadQBSPNodes(const char *name, cplane_t *planes, int numplanes,
|
extern void Mod_LoadQBSPNodes(const char *name, cplane_t *planes, int numplanes,
|
||||||
mleaf_t *leafs, int numleafs, mnode_t **nodes, int *numnodes,
|
mleaf_t *leafs, int numleafs, mnode_t **nodes, int *numnodes,
|
||||||
const byte *mod_base, const lump_t *l, int ident);
|
const byte *mod_base, const lump_t *l, int ident);
|
||||||
|
|
|
@ -402,79 +402,6 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
Mod_LoadMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
|
||||||
{
|
|
||||||
int i, count;
|
|
||||||
short *in;
|
|
||||||
msurface_t **out;
|
|
||||||
|
|
||||||
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->marksurfaces = out;
|
|
||||||
loadmodel->nummarksurfaces = count;
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
j = LittleShort(in[i]);
|
|
||||||
|
|
||||||
if ((j < 0) || (j >= loadmodel->numsurfaces))
|
|
||||||
{
|
|
||||||
ri.Sys_Error(ERR_DROP, "%s: bad surface number",
|
|
||||||
__func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
out[i] = loadmodel->surfaces + j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
Mod_LoadQMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
|
||||||
{
|
|
||||||
int i, count;
|
|
||||||
int *in;
|
|
||||||
msurface_t **out;
|
|
||||||
|
|
||||||
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->marksurfaces = out;
|
|
||||||
loadmodel->nummarksurfaces = count;
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
j = LittleLong(in[i]);
|
|
||||||
|
|
||||||
if ((j < 0) || (j >= loadmodel->numsurfaces))
|
|
||||||
{
|
|
||||||
ri.Sys_Error(ERR_DROP, "%s: bad surface number",
|
|
||||||
__func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
out[i] = loadmodel->surfaces + j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||||
{
|
{
|
||||||
|
@ -607,13 +534,14 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||||
if (header->ident == IDBSPHEADER)
|
if (header->ident == IDBSPHEADER)
|
||||||
{
|
{
|
||||||
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
||||||
Mod_LoadMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Mod_LoadQFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
Mod_LoadQFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
||||||
Mod_LoadQMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
|
||||||
}
|
}
|
||||||
|
Mod_LoadQBSPMarksurfaces(mod->name, &mod->marksurfaces, &mod->nummarksurfaces,
|
||||||
|
mod->surfaces, mod->numsurfaces, mod_base, &header->lumps[LUMP_LEAFFACES],
|
||||||
|
header->ident);
|
||||||
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
||||||
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
|
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
|
||||||
mod->marksurfaces, mod->nummarksurfaces, mod_base,
|
mod->marksurfaces, mod->nummarksurfaces, mod_base,
|
||||||
|
|
|
@ -557,79 +557,6 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
||||||
Vk_EndBuildingLightmaps();
|
Vk_EndBuildingLightmaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
Mod_LoadMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
|
||||||
{
|
|
||||||
int i, count;
|
|
||||||
short *in;
|
|
||||||
msurface_t **out;
|
|
||||||
|
|
||||||
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->marksurfaces = out;
|
|
||||||
loadmodel->nummarksurfaces = count;
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
j = LittleShort(in[i]);
|
|
||||||
|
|
||||||
if ((j < 0) || (j >= loadmodel->numsurfaces))
|
|
||||||
{
|
|
||||||
ri.Sys_Error(ERR_DROP, "%s: bad surface number",
|
|
||||||
__func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
out[i] = loadmodel->surfaces + j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
Mod_LoadQMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
|
||||||
{
|
|
||||||
int i, count;
|
|
||||||
int *in;
|
|
||||||
msurface_t **out;
|
|
||||||
|
|
||||||
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->marksurfaces = out;
|
|
||||||
loadmodel->nummarksurfaces = count;
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
j = LittleLong(in[i]);
|
|
||||||
|
|
||||||
if ((j < 0) || (j >= loadmodel->numsurfaces))
|
|
||||||
{
|
|
||||||
ri.Sys_Error(ERR_DROP, "%s: bad surface number",
|
|
||||||
__func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
out[i] = loadmodel->surfaces + j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||||
{
|
{
|
||||||
|
@ -759,13 +686,14 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||||
if (header->ident == IDBSPHEADER)
|
if (header->ident == IDBSPHEADER)
|
||||||
{
|
{
|
||||||
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
||||||
Mod_LoadMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Mod_LoadQFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
Mod_LoadQFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
||||||
Mod_LoadQMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
|
||||||
}
|
}
|
||||||
|
Mod_LoadQBSPMarksurfaces(mod->name, &mod->marksurfaces, &mod->nummarksurfaces,
|
||||||
|
mod->surfaces, mod->numsurfaces, mod_base, &header->lumps[LUMP_LEAFFACES],
|
||||||
|
header->ident);
|
||||||
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
Mod_LoadVisibility(&mod->vis, mod_base, &header->lumps[LUMP_VISIBILITY]);
|
||||||
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
|
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
|
||||||
mod->marksurfaces, mod->nummarksurfaces, mod_base,
|
mod->marksurfaces, mod->nummarksurfaces, mod_base,
|
||||||
|
|
Loading…
Reference in a new issue