mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Share Mod_Load* functions
This commit is contained in:
parent
4463e1fcd7
commit
442fe10f27
7 changed files with 521 additions and 919 deletions
|
@ -292,7 +292,7 @@ Mod_ReLoadSkins(struct image_s **skins, findimage_t find_image, void *extradata,
|
|||
skins[i] = find_image ((char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME, it_skin);
|
||||
return pheader->num_frames;
|
||||
}
|
||||
// Unknow format, no images associated with it
|
||||
/* Unknow format, no images associated with it */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -314,18 +314,53 @@ Mod_SetParent(mnode_t *node, mnode_t *parent)
|
|||
Mod_SetParent (node->children[1], node);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_NumberLeafs
|
||||
=================
|
||||
*/
|
||||
static void
|
||||
Mod_NumberLeafs(mleaf_t *leafs, mnode_t *node, int *r_leaftovis, int *r_vistoleaf,
|
||||
int *numvisleafs)
|
||||
{
|
||||
if (node->contents != CONTENTS_NODE)
|
||||
{
|
||||
mleaf_t *leaf;
|
||||
int leafnum;
|
||||
|
||||
leaf = (mleaf_t *)node;
|
||||
leafnum = leaf - leafs;
|
||||
if (leaf->contents & CONTENTS_SOLID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
r_leaftovis[leafnum] = *numvisleafs;
|
||||
r_vistoleaf[*numvisleafs] = leafnum;
|
||||
(*numvisleafs) ++;
|
||||
return;
|
||||
}
|
||||
|
||||
Mod_NumberLeafs(leafs, node->children[0], r_leaftovis, r_vistoleaf,
|
||||
numvisleafs);
|
||||
Mod_NumberLeafs(leafs, node->children[1], r_leaftovis, r_vistoleaf,
|
||||
numvisleafs);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadNodes
|
||||
=================
|
||||
*/
|
||||
void
|
||||
Mod_LoadNodes(const char *name, cplane_t *planes, struct mleaf_s *leafs,
|
||||
mnode_t **nodes, int *numnodes, const byte *mod_base, const lump_t *l)
|
||||
Mod_LoadNodes(const char *name, cplane_t *planes, int numplanes, mleaf_t *leafs,
|
||||
int numleafs, mnode_t **nodes, int *numnodes, const byte *mod_base,
|
||||
const lump_t *l)
|
||||
{
|
||||
int i, count;
|
||||
dnode_t *in;
|
||||
mnode_t *out;
|
||||
int r_leaftovis[MAX_MAP_LEAFS], r_vistoleaf[MAX_MAP_LEAFS];
|
||||
int i, count, numvisleafs;
|
||||
dnode_t *in;
|
||||
mnode_t *out;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
|
@ -343,7 +378,7 @@ Mod_LoadNodes(const char *name, cplane_t *planes, struct mleaf_s *leafs,
|
|||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
int j, p;
|
||||
int j, planenum;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
|
@ -351,8 +386,13 @@ Mod_LoadNodes(const char *name, cplane_t *planes, struct mleaf_s *leafs,
|
|||
out->minmaxs[3 + j] = LittleShort(in->maxs[j]);
|
||||
}
|
||||
|
||||
p = LittleLong(in->planenum);
|
||||
out->plane = planes + p;
|
||||
planenum = LittleLong(in->planenum);
|
||||
if (planenum < 0 || planenum >= numplanes)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: Incorrect %d < %d planenum.",
|
||||
__func__, planenum, numplanes);
|
||||
}
|
||||
out->plane = planes + planenum;
|
||||
|
||||
out->firstsurface = LittleShort(in->firstface);
|
||||
out->numsurfaces = LittleShort(in->numfaces);
|
||||
|
@ -360,18 +400,353 @@ Mod_LoadNodes(const char *name, cplane_t *planes, struct mleaf_s *leafs,
|
|||
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
p = LittleLong(in->children[j]);
|
||||
int leafnum;
|
||||
|
||||
if (p >= 0)
|
||||
leafnum = LittleLong(in->children[j]);
|
||||
|
||||
if (leafnum >= 0)
|
||||
{
|
||||
out->children[j] = *nodes + p;
|
||||
if (leafnum < 0 || leafnum >= *numnodes)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: Incorrect %d nodenum as leaf.",
|
||||
__func__, leafnum);
|
||||
}
|
||||
|
||||
out->children[j] = *nodes + leafnum;
|
||||
}
|
||||
else
|
||||
{
|
||||
out->children[j] = (mnode_t *)(leafs + (-1 - p));
|
||||
leafnum = -1 - leafnum;
|
||||
if (leafnum < 0 || leafnum >= numleafs)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: Incorrect %d leafnum.",
|
||||
__func__, leafnum);
|
||||
}
|
||||
|
||||
out->children[j] = (mnode_t *)(leafs + leafnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Mod_SetParent(*nodes, NULL); /* sets nodes and leafs */
|
||||
|
||||
numvisleafs = 0;
|
||||
Mod_NumberLeafs (leafs, *nodes, r_leaftovis, r_vistoleaf, &numvisleafs);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadVisibility
|
||||
=================
|
||||
*/
|
||||
void
|
||||
Mod_LoadVisibility (dvis_t **vis, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dvis_t *out;
|
||||
int i;
|
||||
|
||||
if (!l->filelen)
|
||||
{
|
||||
*vis = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
out = Hunk_Alloc(l->filelen);
|
||||
*vis = out;
|
||||
memcpy(out, mod_base + l->fileofs, l->filelen);
|
||||
|
||||
out->numclusters = LittleLong(out->numclusters);
|
||||
|
||||
for (i = 0; i < out->numclusters; i++)
|
||||
{
|
||||
out->bitofs[i][0] = LittleLong(out->bitofs[i][0]);
|
||||
out->bitofs[i][1] = LittleLong(out->bitofs[i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadVertexes
|
||||
|
||||
extra for skybox
|
||||
=================
|
||||
*/
|
||||
void
|
||||
Mod_LoadVertexes(const char *name, mvertex_t **vertexes, int *numvertexes,
|
||||
const byte *mod_base, const lump_t *l, int extra)
|
||||
{
|
||||
dvertex_t *in;
|
||||
mvertex_t *out;
|
||||
int i, 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 + extra)*sizeof(*out));
|
||||
|
||||
/*
|
||||
* FIXME: Recheck with soft render
|
||||
* Fix for the problem where the games dumped core
|
||||
* when changing levels.
|
||||
*/
|
||||
memset(out, 0, (count + extra) * sizeof(*out));
|
||||
|
||||
*vertexes = out;
|
||||
*numvertexes = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
out->position[0] = LittleFloat(in->point[0]);
|
||||
out->position[1] = LittleFloat(in->point[1]);
|
||||
out->position[2] = LittleFloat(in->point[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadLighting
|
||||
=================
|
||||
*/
|
||||
void
|
||||
Mod_LoadLighting(byte **lightdata, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
int size;
|
||||
|
||||
if (!l->filelen)
|
||||
{
|
||||
*lightdata = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
size = l->filelen;
|
||||
*lightdata = Hunk_Alloc(size);
|
||||
memcpy(*lightdata, mod_base + l->fileofs, size);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadTexinfo
|
||||
|
||||
extra for skybox in soft render
|
||||
=================
|
||||
*/
|
||||
void
|
||||
Mod_LoadTexinfo(const char *name, mtexinfo_t **texinfo, int *numtexinfo,
|
||||
const byte *mod_base, const lump_t *l, findimage_t find_image,
|
||||
struct image_s *notexture, int extra)
|
||||
{
|
||||
texinfo_t *in;
|
||||
mtexinfo_t *out, *step;
|
||||
int i, 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 + extra)*sizeof(*out));
|
||||
|
||||
*texinfo = out;
|
||||
*numtexinfo = count;
|
||||
|
||||
for ( i=0 ; i<count ; i++, in++, out++)
|
||||
{
|
||||
struct image_s *image;
|
||||
int j, next;
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
out->vecs[0][j] = LittleFloat(in->vecs[0][j]);
|
||||
out->vecs[1][j] = LittleFloat(in->vecs[1][j]);
|
||||
}
|
||||
|
||||
out->flags = LittleLong (in->flags);
|
||||
|
||||
next = LittleLong (in->nexttexinfo);
|
||||
if (next > 0)
|
||||
{
|
||||
out->next = *texinfo + next;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Fix for the problem where the game
|
||||
* domed core when loading a new level.
|
||||
*/
|
||||
out->next = NULL;
|
||||
}
|
||||
|
||||
image = GetTexImage(in->texture, find_image);
|
||||
if (!image)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: Couldn't load %s\n",
|
||||
__func__, in->texture);
|
||||
image = notexture;
|
||||
}
|
||||
|
||||
out->image = image;
|
||||
}
|
||||
|
||||
// count animation frames
|
||||
for (i=0 ; i<count ; i++)
|
||||
{
|
||||
out = (*texinfo) + i;
|
||||
out->numframes = 1;
|
||||
for (step = out->next ; step && step != out ; step=step->next)
|
||||
{
|
||||
out->numframes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadEdges
|
||||
|
||||
extra is used for skybox, which adds 6 surfaces
|
||||
=================
|
||||
*/
|
||||
void
|
||||
Mod_LoadEdges(const char *name, medge_t **edges, int *numedges,
|
||||
const byte *mod_base, const lump_t *l, int extra)
|
||||
{
|
||||
dedge_t *in;
|
||||
medge_t *out;
|
||||
int i, 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 + extra) * sizeof(*out));
|
||||
|
||||
*edges = out;
|
||||
*numedges = count;
|
||||
|
||||
for ( i=0 ; i<count ; i++, in++, out++)
|
||||
{
|
||||
out->v[0] = (unsigned short)LittleShort(in->v[0]);
|
||||
out->v[1] = (unsigned short)LittleShort(in->v[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
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))
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
|
||||
__func__, name);
|
||||
}
|
||||
|
||||
count = l->filelen / sizeof(*in);
|
||||
// FIXME: why double of count
|
||||
out = Hunk_Alloc((count * 2 + 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
|
||||
=================
|
||||
*/
|
||||
void
|
||||
Mod_LoadSurfedges(const char *name, int **surfedges, int *numsurfedges,
|
||||
const byte *mod_base, const lump_t *l, int extra)
|
||||
{
|
||||
int i, count;
|
||||
int *in, *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 + extra)*sizeof(*out)); // extra for skybox
|
||||
|
||||
*surfedges = out;
|
||||
*numsurfedges = count;
|
||||
|
||||
for ( i=0 ; i<count ; i++)
|
||||
out[i] = LittleLong (in[i]);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadSurfedges
|
||||
|
||||
calculate the size that Hunk_Alloc(), called by Mod_Load*() from Mod_LoadBrushModel(),
|
||||
will use (=> includes its padding), so we'll know how big the hunk needs to be
|
||||
extra is used for skybox, which adds 6 surfaces
|
||||
=================
|
||||
*/
|
||||
int
|
||||
Mod_CalcLumpHunkSize(const lump_t *l, int inSize, int outSize, int extra)
|
||||
{
|
||||
if (l->filelen % inSize)
|
||||
{
|
||||
// Mod_Load*() will error out on this because of "funny size"
|
||||
// don't error out here because in Mod_Load*() it can print the functionname
|
||||
// (=> tells us what kind of lump) before shutting down the game
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = l->filelen / inSize + extra;
|
||||
int size = count * outSize;
|
||||
|
||||
// round to cacheline, like Hunk_Alloc() does
|
||||
size = (size + 31) & ~31;
|
||||
return size;
|
||||
}
|
||||
|
|
|
@ -290,71 +290,6 @@ Mod_ForName (char *name, model_t *parent_model, qboolean crash)
|
|||
return mod;
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadLighting(model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
if (!l->filelen)
|
||||
{
|
||||
loadmodel->lightdata = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
loadmodel->lightdata = Hunk_Alloc(l->filelen);
|
||||
memcpy(loadmodel->lightdata, mod_base + l->fileofs, l->filelen);
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadVisibility(model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!l->filelen)
|
||||
{
|
||||
loadmodel->vis = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
loadmodel->vis = Hunk_Alloc(l->filelen);
|
||||
memcpy(loadmodel->vis, mod_base + l->fileofs, l->filelen);
|
||||
|
||||
loadmodel->vis->numclusters = LittleLong(loadmodel->vis->numclusters);
|
||||
|
||||
for (i = 0; i < loadmodel->vis->numclusters; i++)
|
||||
{
|
||||
loadmodel->vis->bitofs[i][0] = LittleLong(loadmodel->vis->bitofs[i][0]);
|
||||
loadmodel->vis->bitofs[i][1] = LittleLong(loadmodel->vis->bitofs[i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadVertexes(model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
dvertex_t *in;
|
||||
mvertex_t *out;
|
||||
int i, 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->vertexes = out;
|
||||
loadmodel->numvertexes = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
out->position[0] = LittleFloat(in->point[0]);
|
||||
out->position[1] = LittleFloat(in->point[1]);
|
||||
out->position[2] = LittleFloat(in->point[2]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadSubmodels (model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
|
@ -414,103 +349,6 @@ Mod_LoadSubmodels (model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadEdges(model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
dedge_t *in;
|
||||
medge_t *out;
|
||||
int i, 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 + 1) * sizeof(*out));
|
||||
|
||||
loadmodel->edges = out;
|
||||
loadmodel->numedges = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
out->v[0] = (unsigned short)LittleShort(in->v[0]);
|
||||
out->v[1] = (unsigned short)LittleShort(in->v[1]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadTexinfo(model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
texinfo_t *in;
|
||||
mtexinfo_t *out, *step;
|
||||
int i, j, count;
|
||||
int next;
|
||||
|
||||
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->texinfo = out;
|
||||
loadmodel->numtexinfo = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
image_t *image;
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
out->vecs[0][j] = LittleFloat(in->vecs[0][j]);
|
||||
out->vecs[1][j] = LittleFloat(in->vecs[1][j]);
|
||||
}
|
||||
|
||||
out->flags = LittleLong(in->flags);
|
||||
next = LittleLong(in->nexttexinfo);
|
||||
|
||||
if (next > 0)
|
||||
{
|
||||
out->next = loadmodel->texinfo + next;
|
||||
}
|
||||
else
|
||||
{
|
||||
out->next = NULL;
|
||||
}
|
||||
|
||||
image = GetTexImage(in->texture, (findimage_t)R_FindImage);
|
||||
|
||||
if (!image)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: Couldn't load %s\n",
|
||||
__func__, in->texture);
|
||||
image = r_notexture;
|
||||
}
|
||||
|
||||
out->image = image;
|
||||
}
|
||||
|
||||
/* count animation frames */
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
out = &loadmodel->texinfo[i];
|
||||
out->numframes = 1;
|
||||
|
||||
for (step = out->next; step && step != out; step = step->next)
|
||||
{
|
||||
out->numframes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fills in s->texturemins[] and s->extents[]
|
||||
*/
|
||||
|
@ -685,6 +523,11 @@ Mod_LoadFaces(model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
out->flags |= SURF_PLANEBACK;
|
||||
}
|
||||
|
||||
if (planenum < 0 || planenum >= loadmodel->numplanes)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: Incorrect %d planenum.",
|
||||
__func__, planenum);
|
||||
}
|
||||
out->plane = loadmodel->planes + planenum;
|
||||
|
||||
ti = LittleShort(in->texinfo);
|
||||
|
@ -838,102 +681,6 @@ Mod_LoadMarksurfaces(model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadSurfedges(model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
int i, count;
|
||||
int *in, *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);
|
||||
|
||||
if ((count < 1) || (count >= MAX_MAP_SURFEDGES))
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: bad surfedges count in %s: %i",
|
||||
__func__, loadmodel->name, count);
|
||||
}
|
||||
|
||||
out = Hunk_Alloc(count * sizeof(*out));
|
||||
|
||||
loadmodel->surfedges = out;
|
||||
loadmodel->numsurfedges = count;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
out[i] = LittleLong(in[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadPlanes(model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
int i, j;
|
||||
cplane_t *out;
|
||||
dplane_t *in;
|
||||
int count;
|
||||
int bits;
|
||||
|
||||
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 * 2 * sizeof(*out));
|
||||
|
||||
loadmodel->planes = out;
|
||||
loadmodel->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;
|
||||
}
|
||||
}
|
||||
|
||||
// calculate the size that Hunk_Alloc(), called by Mod_Load*() from Mod_LoadBrushModel(),
|
||||
// will use (=> includes its padding), so we'll know how big the hunk needs to be
|
||||
static int calcLumpHunkSize(const lump_t *l, int inSize, int outSize)
|
||||
{
|
||||
if (l->filelen % inSize)
|
||||
{
|
||||
// Mod_Load*() will error out on this because of "funny size"
|
||||
// don't error out here because in Mod_Load*() it can print the functionname
|
||||
// (=> tells us what kind of lump) before shutting down the game
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = l->filelen / inSize;
|
||||
int size = count * outSize;
|
||||
|
||||
// round to cacheline, like Hunk_Alloc() does
|
||||
size = (size + 31) & ~31;
|
||||
return size;
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen)
|
||||
{
|
||||
|
@ -966,37 +713,44 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen)
|
|||
|
||||
// calculate the needed hunksize from the lumps
|
||||
int hunkSize = 0;
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_VERTEXES], sizeof(dvertex_t), sizeof(mvertex_t));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_EDGES], sizeof(dedge_t), sizeof(medge_t));
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VERTEXES], sizeof(dvertex_t), sizeof(mvertex_t), 0);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES], sizeof(dedge_t), sizeof(medge_t), 0);
|
||||
hunkSize += sizeof(medge_t) + 31; // for count+1 in Mod_LoadEdges()
|
||||
int surfEdgeCount = (header->lumps[LUMP_SURFEDGES].filelen+sizeof(int)-1)/sizeof(int);
|
||||
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_PLANES], sizeof(dplane_t), sizeof(cplane_t)*2);
|
||||
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_PLANES], sizeof(dplane_t), sizeof(cplane_t)*2, 0);
|
||||
hunkSize += calcTexinfoAndFacesSize(mod_base, &header->lumps[LUMP_FACES], &header->lumps[LUMP_TEXINFO]);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFFACES], sizeof(short), sizeof(msurface_t *)); // yes, out is indeeed a pointer!
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_VISIBILITY], 1, 1);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFS], sizeof(dleaf_t), sizeof(mleaf_t));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_NODES], sizeof(dnode_t), sizeof(mnode_t));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(model_t));
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFFACES], sizeof(short), sizeof(msurface_t *), 0); // yes, out is indeeed a pointer!
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VISIBILITY], 1, 1, 0);
|
||||
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), 0);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(model_t), 0);
|
||||
|
||||
mod->extradata = Hunk_Begin(hunkSize);
|
||||
mod->type = mod_brush;
|
||||
|
||||
/* load into heap */
|
||||
Mod_LoadVertexes(mod, mod_base, &header->lumps[LUMP_VERTEXES]);
|
||||
Mod_LoadEdges(mod, mod_base, &header->lumps[LUMP_EDGES]);
|
||||
Mod_LoadSurfedges(mod, mod_base, &header->lumps[LUMP_SURFEDGES]);
|
||||
Mod_LoadLighting(mod, mod_base, &header->lumps[LUMP_LIGHTING]);
|
||||
Mod_LoadPlanes(mod, mod_base, &header->lumps[LUMP_PLANES]);
|
||||
Mod_LoadTexinfo(mod, mod_base, &header->lumps[LUMP_TEXINFO]);
|
||||
Mod_LoadVertexes(mod->name, &mod->vertexes, &mod->numvertexes, mod_base,
|
||||
&header->lumps[LUMP_VERTEXES], 0);
|
||||
Mod_LoadEdges(mod->name, &mod->edges, &mod->numedges,
|
||||
mod_base, &header->lumps[LUMP_EDGES], 1);
|
||||
Mod_LoadSurfedges(mod->name, &mod->surfedges, &mod->numsurfedges,
|
||||
mod_base, &header->lumps[LUMP_SURFEDGES], 0);
|
||||
Mod_LoadLighting(&mod->lightdata, mod_base, &header->lumps[LUMP_LIGHTING]);
|
||||
Mod_LoadPlanes (mod->name, &mod->planes, &mod->numplanes,
|
||||
mod_base, &header->lumps[LUMP_PLANES], 0);
|
||||
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
|
||||
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)R_FindImage,
|
||||
r_notexture, 0);
|
||||
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES]);
|
||||
Mod_LoadMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
||||
Mod_LoadVisibility(mod, 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_LoadNodes(mod->name, mod->planes, mod->leafs, &mod->nodes,
|
||||
&mod->numnodes, mod_base, &header->lumps[LUMP_NODES]);
|
||||
Mod_LoadNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
|
||||
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
|
||||
&header->lumps[LUMP_NODES]);
|
||||
Mod_LoadSubmodels (mod, mod_base, &header->lumps[LUMP_MODELS]);
|
||||
mod->numframes = 2; /* regular and alternate animation */
|
||||
}
|
||||
|
|
|
@ -158,71 +158,6 @@ GL3_Mod_Init(void)
|
|||
memset(mod_novis, 0xff, sizeof(mod_novis));
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadLighting(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
if (!l->filelen)
|
||||
{
|
||||
loadmodel->lightdata = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
loadmodel->lightdata = Hunk_Alloc(l->filelen);
|
||||
memcpy(loadmodel->lightdata, mod_base + l->fileofs, l->filelen);
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadVisibility(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!l->filelen)
|
||||
{
|
||||
loadmodel->vis = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
loadmodel->vis = Hunk_Alloc(l->filelen);
|
||||
memcpy(loadmodel->vis, mod_base + l->fileofs, l->filelen);
|
||||
|
||||
loadmodel->vis->numclusters = LittleLong(loadmodel->vis->numclusters);
|
||||
|
||||
for (i = 0; i < loadmodel->vis->numclusters; i++)
|
||||
{
|
||||
loadmodel->vis->bitofs[i][0] = LittleLong(loadmodel->vis->bitofs[i][0]);
|
||||
loadmodel->vis->bitofs[i][1] = LittleLong(loadmodel->vis->bitofs[i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadVertexes(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
dvertex_t *in;
|
||||
mvertex_t *out;
|
||||
int i, 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->vertexes = out;
|
||||
loadmodel->numvertexes = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
out->position[0] = LittleFloat(in->point[0]);
|
||||
out->position[1] = LittleFloat(in->point[1]);
|
||||
out->position[2] = LittleFloat(in->point[2]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadSubmodels(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
|
@ -282,102 +217,6 @@ Mod_LoadSubmodels(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadEdges(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
dedge_t *in;
|
||||
medge_t *out;
|
||||
int i, 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 + 1) * sizeof(*out));
|
||||
|
||||
loadmodel->edges = out;
|
||||
loadmodel->numedges = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
out->v[0] = (unsigned short)LittleShort(in->v[0]);
|
||||
out->v[1] = (unsigned short)LittleShort(in->v[1]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadTexinfo(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
texinfo_t *in;
|
||||
mtexinfo_t *out, *step;
|
||||
int i, j, count;
|
||||
int next;
|
||||
|
||||
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->texinfo = out;
|
||||
loadmodel->numtexinfo = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
gl3image_t *image;
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
out->vecs[0][j] = LittleFloat(in->vecs[0][j]);
|
||||
out->vecs[1][j] = LittleFloat(in->vecs[1][j]);
|
||||
}
|
||||
|
||||
out->flags = LittleLong(in->flags);
|
||||
next = LittleLong(in->nexttexinfo);
|
||||
|
||||
if (next > 0)
|
||||
{
|
||||
out->next = loadmodel->texinfo + next;
|
||||
}
|
||||
else
|
||||
{
|
||||
out->next = NULL;
|
||||
}
|
||||
|
||||
image = GetTexImage(in->texture, (findimage_t)GL3_FindImage);
|
||||
if (!image)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: Couldn't load %s\n",
|
||||
__func__, in->texture);
|
||||
image = gl3_notexture;
|
||||
}
|
||||
|
||||
out->image = image;
|
||||
}
|
||||
|
||||
/* count animation frames */
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
out = &loadmodel->texinfo[i];
|
||||
out->numframes = 1;
|
||||
|
||||
for (step = out->next; step && step != out; step = step->next)
|
||||
{
|
||||
out->numframes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fills in s->texturemins[] and s->extents[]
|
||||
*/
|
||||
|
@ -555,6 +394,11 @@ Mod_LoadFaces(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
out->flags |= SURF_PLANEBACK;
|
||||
}
|
||||
|
||||
if (planenum < 0 || planenum >= loadmodel->numplanes)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: Incorrect %d planenum.",
|
||||
__func__, planenum);
|
||||
}
|
||||
out->plane = loadmodel->planes + planenum;
|
||||
|
||||
ti = LittleShort(in->texinfo);
|
||||
|
@ -707,102 +551,6 @@ Mod_LoadMarksurfaces(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadSurfedges(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
int i, count;
|
||||
int *in, *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);
|
||||
|
||||
if ((count < 1) || (count >= MAX_MAP_SURFEDGES))
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: bad surfedges count in %s: %i",
|
||||
__func__, loadmodel->name, count);
|
||||
}
|
||||
|
||||
out = Hunk_Alloc(count * sizeof(*out));
|
||||
|
||||
loadmodel->surfedges = out;
|
||||
loadmodel->numsurfedges = count;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
out[i] = LittleLong(in[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadPlanes(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
int i, j;
|
||||
cplane_t *out;
|
||||
dplane_t *in;
|
||||
int count;
|
||||
int bits;
|
||||
|
||||
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 * 2 * sizeof(*out));
|
||||
|
||||
loadmodel->planes = out;
|
||||
loadmodel->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;
|
||||
}
|
||||
}
|
||||
|
||||
// calculate the size that Hunk_Alloc(), called by Mod_Load*() from Mod_LoadBrushModel(),
|
||||
// will use (=> includes its padding), so we'll know how big the hunk needs to be
|
||||
static int calcLumpHunkSize(const lump_t *l, int inSize, int outSize)
|
||||
{
|
||||
if (l->filelen % inSize)
|
||||
{
|
||||
// Mod_Load*() will error out on this because of "funny size"
|
||||
// don't error out here because in Mod_Load*() it can print the functionname
|
||||
// (=> tells us what kind of lump) before shutting down the game
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = l->filelen / inSize;
|
||||
int size = count * outSize;
|
||||
|
||||
// round to cacheline, like Hunk_Alloc() does
|
||||
size = (size + 31) & ~31;
|
||||
return size;
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadBrushModel(gl3model_t *mod, void *buffer, int modfilelen)
|
||||
{
|
||||
|
@ -835,37 +583,44 @@ Mod_LoadBrushModel(gl3model_t *mod, void *buffer, int modfilelen)
|
|||
|
||||
// calculate the needed hunksize from the lumps
|
||||
int hunkSize = 0;
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_VERTEXES], sizeof(dvertex_t), sizeof(mvertex_t));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_EDGES], sizeof(dedge_t), sizeof(medge_t));
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VERTEXES], sizeof(dvertex_t), sizeof(mvertex_t), 0);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES], sizeof(dedge_t), sizeof(medge_t), 0);
|
||||
hunkSize += sizeof(medge_t) + 31; // for count+1 in Mod_LoadEdges()
|
||||
int surfEdgeCount = (header->lumps[LUMP_SURFEDGES].filelen+sizeof(int)-1)/sizeof(int);
|
||||
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_PLANES], sizeof(dplane_t), sizeof(cplane_t)*2);
|
||||
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_PLANES], sizeof(dplane_t), sizeof(cplane_t)*2, 0);
|
||||
hunkSize += calcTexinfoAndFacesSize(mod_base, &header->lumps[LUMP_FACES], &header->lumps[LUMP_TEXINFO]);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFFACES], sizeof(short), sizeof(msurface_t *)); // yes, out is indeeed a pointer!
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_VISIBILITY], 1, 1);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFS], sizeof(dleaf_t), sizeof(mleaf_t));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_NODES], sizeof(dnode_t), sizeof(mnode_t));
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(gl3model_t));
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFFACES], sizeof(short), sizeof(msurface_t *), 0); // yes, out is indeeed a pointer!
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VISIBILITY], 1, 1, 0);
|
||||
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), 0);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(gl3model_t), 0);
|
||||
|
||||
mod->extradata = Hunk_Begin(hunkSize);
|
||||
mod->type = mod_brush;
|
||||
|
||||
/* load into heap */
|
||||
Mod_LoadVertexes(mod, mod_base, &header->lumps[LUMP_VERTEXES]);
|
||||
Mod_LoadEdges(mod, mod_base, &header->lumps[LUMP_EDGES]);
|
||||
Mod_LoadSurfedges(mod, mod_base, &header->lumps[LUMP_SURFEDGES]);
|
||||
Mod_LoadLighting(mod, mod_base, &header->lumps[LUMP_LIGHTING]);
|
||||
Mod_LoadPlanes(mod, mod_base, &header->lumps[LUMP_PLANES]);
|
||||
Mod_LoadTexinfo(mod, mod_base, &header->lumps[LUMP_TEXINFO]);
|
||||
Mod_LoadVertexes(mod->name, &mod->vertexes, &mod->numvertexes, mod_base,
|
||||
&header->lumps[LUMP_VERTEXES], 0);
|
||||
Mod_LoadEdges(mod->name, &mod->edges, &mod->numedges,
|
||||
mod_base, &header->lumps[LUMP_EDGES], 1);
|
||||
Mod_LoadSurfedges(mod->name, &mod->surfedges, &mod->numsurfedges,
|
||||
mod_base, &header->lumps[LUMP_SURFEDGES], 0);
|
||||
Mod_LoadLighting(&mod->lightdata, mod_base, &header->lumps[LUMP_LIGHTING]);
|
||||
Mod_LoadPlanes (mod->name, &mod->planes, &mod->numplanes,
|
||||
mod_base, &header->lumps[LUMP_PLANES], 0);
|
||||
Mod_LoadTexinfo (mod->name, &mod->texinfo, &mod->numtexinfo,
|
||||
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)GL3_FindImage,
|
||||
gl3_notexture, 0);
|
||||
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES]);
|
||||
Mod_LoadMarksurfaces(mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
||||
Mod_LoadVisibility(mod, 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_LoadNodes(mod->name, mod->planes, mod->leafs, &mod->nodes,
|
||||
&mod->numnodes, mod_base, &header->lumps[LUMP_NODES]);
|
||||
Mod_LoadNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
|
||||
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
|
||||
&header->lumps[LUMP_NODES]);
|
||||
Mod_LoadSubmodels (mod, mod_base, &header->lumps[LUMP_MODELS]);
|
||||
mod->numframes = 2; /* regular and alternate animation */
|
||||
}
|
||||
|
|
|
@ -190,6 +190,22 @@ 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_LoadImage(const char *name, const char* namewe, const char *ext,
|
||||
imagetype_t type, qboolean r_retexturing, loadimage_t load_image);
|
||||
extern void Mod_LoadNodes(const char *name, cplane_t *planes, struct mleaf_s *leafs,
|
||||
mnode_t **nodes, int *numnodes, const byte *mod_base, const lump_t *l);
|
||||
extern void Mod_LoadNodes(const char *name, cplane_t *planes, int numplanes,
|
||||
mleaf_t *leafs, int numleafs, mnode_t **nodes, int *numnodes,
|
||||
const byte *mod_base, const lump_t *l);
|
||||
extern void Mod_LoadVertexes(const char *name, mvertex_t **vertexes, int *numvertexes,
|
||||
const byte *mod_base, const lump_t *l, int extra);
|
||||
extern void Mod_LoadVisibility(dvis_t **vis, const byte *mod_base, const lump_t *l);
|
||||
extern void Mod_LoadLighting(byte **lightdata, const byte *mod_base, const lump_t *l);
|
||||
extern void Mod_LoadTexinfo(const char *name, mtexinfo_t **texinfo, int *numtexinfo,
|
||||
const byte *mod_base, const lump_t *l, findimage_t find_image,
|
||||
struct image_s *notexture, int extra);
|
||||
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_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,
|
||||
const byte *mod_base, const lump_t *l, int extra);
|
||||
extern int Mod_CalcLumpHunkSize(const lump_t *l, int inSize, int outSize, int extra);
|
||||
|
||||
#endif /* SRC_CLIENT_REFRESH_REF_SHARED_H_ */
|
||||
|
|
|
@ -510,9 +510,9 @@ R_RecursiveWorldNode (entity_t *currententity, const model_t *currentmodel, mnod
|
|||
|
||||
pindex = pfrustum_indexes[i];
|
||||
|
||||
rejectpt[0] = (float)node->minmaxs[pindex[0]];
|
||||
rejectpt[1] = (float)node->minmaxs[pindex[1]];
|
||||
rejectpt[2] = (float)node->minmaxs[pindex[2]];
|
||||
rejectpt[0] = node->minmaxs[pindex[0]];
|
||||
rejectpt[1] = node->minmaxs[pindex[1]];
|
||||
rejectpt[2] = node->minmaxs[pindex[2]];
|
||||
|
||||
d = DotProduct (rejectpt, view_clipplanes[i].normal);
|
||||
d -= view_clipplanes[i].dist;
|
||||
|
|
|
@ -331,7 +331,7 @@ R_LoadPic (char *name, byte *pic, int width, int realwidth, int height, int real
|
|||
/* Code used with HIColor calls */
|
||||
if (bits == 32)
|
||||
{
|
||||
image_t *image;
|
||||
image_t *image = NULL;
|
||||
byte *pic8;
|
||||
|
||||
pic8 = malloc(data_size);
|
||||
|
|
|
@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
static void Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen);
|
||||
|
||||
static byte mod_novis[MAX_MAP_LEAFS/8];
|
||||
static YQ2_ALIGNAS_TYPE(int) byte mod_novis[MAX_MAP_LEAFS/8];
|
||||
|
||||
#define MAX_MOD_KNOWN 512
|
||||
static model_t mod_known[MAX_MOD_KNOWN];
|
||||
|
@ -263,124 +263,6 @@ Mod_ClusterPVS (int cluster, const model_t *model)
|
|||
===============================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadLighting
|
||||
|
||||
Converts the 24 bit lighting down to 8 bit
|
||||
by taking the brightest component
|
||||
=================
|
||||
*/
|
||||
static void
|
||||
Mod_LoadLighting (model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
int size;
|
||||
|
||||
if (!l->filelen)
|
||||
{
|
||||
loadmodel->lightdata = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
size = l->filelen;
|
||||
loadmodel->lightdata = Hunk_Alloc(size);
|
||||
memcpy(loadmodel->lightdata, mod_base + l->fileofs, size);
|
||||
}
|
||||
|
||||
|
||||
static int r_leaftovis[MAX_MAP_LEAFS];
|
||||
static int r_vistoleaf[MAX_MAP_LEAFS];
|
||||
static int r_numvisleafs;
|
||||
|
||||
static void
|
||||
R_NumberLeafs (model_t *loadmodel, mnode_t *node)
|
||||
{
|
||||
if (node->contents != CONTENTS_NODE)
|
||||
{
|
||||
mleaf_t *leaf;
|
||||
int leafnum;
|
||||
|
||||
leaf = (mleaf_t *)node;
|
||||
leafnum = leaf - loadmodel->leafs;
|
||||
if (leaf->contents & CONTENTS_SOLID)
|
||||
return;
|
||||
r_leaftovis[leafnum] = r_numvisleafs;
|
||||
r_vistoleaf[r_numvisleafs] = leafnum;
|
||||
r_numvisleafs++;
|
||||
return;
|
||||
}
|
||||
|
||||
R_NumberLeafs (loadmodel, node->children[0]);
|
||||
R_NumberLeafs (loadmodel, node->children[1]);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadVisibility
|
||||
=================
|
||||
*/
|
||||
static void
|
||||
Mod_LoadVisibility (model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!l->filelen)
|
||||
{
|
||||
loadmodel->vis = NULL;
|
||||
return;
|
||||
}
|
||||
loadmodel->vis = Hunk_Alloc(l->filelen);
|
||||
memcpy (loadmodel->vis, mod_base + l->fileofs, l->filelen);
|
||||
|
||||
loadmodel->vis->numclusters = LittleLong (loadmodel->vis->numclusters);
|
||||
for (i=0 ; i<loadmodel->vis->numclusters ; i++)
|
||||
{
|
||||
loadmodel->vis->bitofs[i][0] = LittleLong (loadmodel->vis->bitofs[i][0]);
|
||||
loadmodel->vis->bitofs[i][1] = LittleLong (loadmodel->vis->bitofs[i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadVertexes
|
||||
=================
|
||||
*/
|
||||
static void
|
||||
Mod_LoadVertexes (model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
dvertex_t *in;
|
||||
mvertex_t *out;
|
||||
int i, 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+8)*sizeof(*out)); // extra for skybox
|
||||
/*
|
||||
* Fix for the problem where the games dumped core
|
||||
* when changing levels.
|
||||
*/
|
||||
memset( out, 0, (count + 6) * sizeof( *out ) );
|
||||
|
||||
loadmodel->vertexes = out;
|
||||
loadmodel->numvertexes = count;
|
||||
|
||||
for ( i=0 ; i<count ; i++, in++, out++)
|
||||
{
|
||||
out->position[0] = LittleFloat (in->point[0]);
|
||||
out->position[1] = LittleFloat (in->point[1]);
|
||||
out->position[2] = LittleFloat (in->point[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadSubmodels
|
||||
|
@ -443,109 +325,6 @@ Mod_LoadSubmodels (model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadEdges
|
||||
=================
|
||||
*/
|
||||
static void
|
||||
Mod_LoadEdges (model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
dedge_t *in;
|
||||
medge_t *out;
|
||||
int i, 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 + 13) * sizeof(*out)); // extra for skybox
|
||||
|
||||
loadmodel->edges = out;
|
||||
loadmodel->numedges = count;
|
||||
|
||||
for ( i=0 ; i<count ; i++, in++, out++)
|
||||
{
|
||||
out->v[0] = (unsigned short)LittleShort(in->v[0]);
|
||||
out->v[1] = (unsigned short)LittleShort(in->v[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadTexinfo
|
||||
=================
|
||||
*/
|
||||
static void
|
||||
Mod_LoadTexinfo (model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
texinfo_t *in;
|
||||
mtexinfo_t *out, *step;
|
||||
int i, 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+6)*sizeof(*out)); // extra for skybox
|
||||
|
||||
loadmodel->texinfo = out;
|
||||
loadmodel->numtexinfo = count;
|
||||
|
||||
for ( i=0 ; i<count ; i++, in++, out++)
|
||||
{
|
||||
image_t *image;
|
||||
int j, next;
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
out->vecs[0][j] = LittleFloat(in->vecs[0][j]);
|
||||
out->vecs[1][j] = LittleFloat(in->vecs[1][j]);
|
||||
}
|
||||
|
||||
out->flags = LittleLong (in->flags);
|
||||
|
||||
next = LittleLong (in->nexttexinfo);
|
||||
if (next > 0)
|
||||
out->next = loadmodel->texinfo + next;
|
||||
/*
|
||||
* Fix for the problem where the game
|
||||
* domed core when loading a new level.
|
||||
*/
|
||||
else {
|
||||
out->next = NULL;
|
||||
}
|
||||
|
||||
image = GetTexImage(in->texture, (findimage_t)R_FindImage);
|
||||
if (!image)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: Couldn't load %s\n",
|
||||
__func__, in->texture);
|
||||
image = r_notexture_mip;
|
||||
}
|
||||
|
||||
out->image = image;
|
||||
}
|
||||
|
||||
// count animation frames
|
||||
for (i=0 ; i<count ; i++)
|
||||
{
|
||||
out = &loadmodel->texinfo[i];
|
||||
out->numframes = 1;
|
||||
for (step = out->next ; step && step != out ; step=step->next)
|
||||
out->numframes++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CalcSurfaceExtents
|
||||
|
@ -572,11 +351,15 @@ CalcSurfaceExtents (model_t *loadmodel, msurface_t *s)
|
|||
mvertex_t *v;
|
||||
|
||||
e = loadmodel->surfedges[s->firstedge+i];
|
||||
if (e >= 0)
|
||||
v = &loadmodel->vertexes[loadmodel->edges[e].v[0]];
|
||||
else
|
||||
v = &loadmodel->vertexes[loadmodel->edges[-e].v[1]];
|
||||
|
||||
if (e >= 0)
|
||||
{
|
||||
v = &loadmodel->vertexes[loadmodel->edges[e].v[0]];
|
||||
}
|
||||
else
|
||||
{
|
||||
v = &loadmodel->vertexes[loadmodel->edges[-e].v[1]];
|
||||
}
|
||||
for (j=0 ; j<2 ; j++)
|
||||
{
|
||||
val = v->position[0] * tex->vecs[j][0] +
|
||||
|
@ -635,7 +418,7 @@ Mod_LoadFaces (model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
|
||||
for ( surfnum=0 ; surfnum<count ; surfnum++, in++, out++)
|
||||
{
|
||||
int planenum, side;
|
||||
int planenum, side, ti;
|
||||
|
||||
out->firstedge = LittleLong(in->firstedge);
|
||||
out->numedges = LittleShort(in->numedges);
|
||||
|
@ -651,9 +434,19 @@ Mod_LoadFaces (model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
if (side)
|
||||
out->flags |= SURF_PLANEBACK;
|
||||
|
||||
if (planenum < 0 || planenum >= loadmodel->numplanes)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: Incorrect %d planenum.",
|
||||
__func__, planenum);
|
||||
}
|
||||
out->plane = loadmodel->planes + planenum;
|
||||
|
||||
out->texinfo = loadmodel->texinfo + LittleShort (in->texinfo);
|
||||
ti = LittleShort(in->texinfo);
|
||||
if (ti < 0 || ti >= loadmodel->numtexinfo)
|
||||
{
|
||||
ri.Sys_Error(ERR_DROP, "%s: bad texinfo number", __func__);
|
||||
}
|
||||
out->texinfo = loadmodel->texinfo + ti;
|
||||
|
||||
CalcSurfaceExtents (loadmodel, out);
|
||||
|
||||
|
@ -664,6 +457,7 @@ Mod_LoadFaces (model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
}
|
||||
|
||||
i = LittleLong(in->lightofs);
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
out->samples = NULL;
|
||||
|
@ -806,102 +600,6 @@ Mod_LoadMarksurfaces (model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadSurfedges
|
||||
=================
|
||||
*/
|
||||
static void
|
||||
Mod_LoadSurfedges (model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
int i, count;
|
||||
int *in, *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+24)*sizeof(*out)); // extra for skybox
|
||||
|
||||
loadmodel->surfedges = out;
|
||||
loadmodel->numsurfedges = count;
|
||||
|
||||
for ( i=0 ; i<count ; i++)
|
||||
out[i] = LittleLong (in[i]);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadPlanes
|
||||
=================
|
||||
*/
|
||||
static void
|
||||
Mod_LoadPlanes (model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
{
|
||||
int i;
|
||||
cplane_t *out;
|
||||
dplane_t *in;
|
||||
int 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+6)*sizeof(*out)); // extra for skybox
|
||||
|
||||
loadmodel->planes = out;
|
||||
loadmodel->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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// calculate the size that Hunk_Alloc(), called by Mod_Load*() from Mod_LoadBrushModel(),
|
||||
// will use (=> includes its padding), so we'll know how big the hunk needs to be
|
||||
// extra is used for skybox, which adds 6 surfaces
|
||||
static int calcLumpHunkSize(const lump_t *l, int inSize, int outSize, int extra)
|
||||
{
|
||||
if (l->filelen % inSize)
|
||||
{
|
||||
// Mod_Load*() will error out on this because of "funny size"
|
||||
// don't error out here because in Mod_Load*() it can print the functionname
|
||||
// (=> tells us what kind of lump) before shutting down the game
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = l->filelen / inSize + extra;
|
||||
int size = count * outSize;
|
||||
|
||||
// round to cacheline, like Hunk_Alloc() does
|
||||
size = (size + 31) & ~31;
|
||||
return size;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadBrushModel
|
||||
|
@ -934,11 +632,11 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen)
|
|||
|
||||
// calculate the needed hunksize from the lumps
|
||||
int hunkSize = 0;
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_VERTEXES], sizeof(dvertex_t), sizeof(mvertex_t), 8);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_EDGES], sizeof(dedge_t), sizeof(medge_t), 13);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VERTEXES], sizeof(dvertex_t), sizeof(mvertex_t), 8);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES], sizeof(dedge_t), sizeof(medge_t), 13);
|
||||
float surfEdgeCount = (float)header->lumps[LUMP_SURFEDGES].filelen / sizeof(int);
|
||||
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 24);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int), 24);
|
||||
|
||||
// lighting is a special case, because we keep only 1 byte out of 3
|
||||
// (=> no colored lighting in soft renderer by default)
|
||||
|
@ -949,14 +647,14 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen)
|
|||
hunkSize += size;
|
||||
}
|
||||
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_PLANES], sizeof(dplane_t), sizeof(cplane_t), 6);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_TEXINFO], sizeof(texinfo_t), sizeof(mtexinfo_t), 6);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_FACES], sizeof(dface_t), sizeof(msurface_t), 6);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFFACES], sizeof(short), sizeof(msurface_t *), 0); // yes, out is indeeed a pointer!
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_VISIBILITY], 1, 1, 0);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFS], sizeof(dleaf_t), sizeof(mleaf_t), 0);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_NODES], sizeof(dnode_t), sizeof(mnode_t), 0);
|
||||
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(model_t), 0);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES], sizeof(dplane_t), sizeof(cplane_t)*2, 6);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_TEXINFO], sizeof(texinfo_t), sizeof(mtexinfo_t), 6);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_FACES], sizeof(dface_t), sizeof(msurface_t), 6);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFFACES], sizeof(short), sizeof(msurface_t *), 0); // yes, out is indeeed a pointer!
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VISIBILITY], 1, 1, 0);
|
||||
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), 0);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS], sizeof(dmodel_t), sizeof(model_t), 0);
|
||||
|
||||
hunkSize += 1048576; // 1MB extra just in case
|
||||
|
||||
|
@ -965,23 +663,27 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen)
|
|||
mod->type = mod_brush;
|
||||
|
||||
// load into heap
|
||||
Mod_LoadVertexes (mod, mod_base, &header->lumps[LUMP_VERTEXES]);
|
||||
Mod_LoadEdges (mod, mod_base, &header->lumps[LUMP_EDGES]);
|
||||
Mod_LoadSurfedges (mod, mod_base, &header->lumps[LUMP_SURFEDGES]);
|
||||
Mod_LoadLighting (mod, mod_base, &header->lumps[LUMP_LIGHTING]);
|
||||
Mod_LoadPlanes (mod, mod_base, &header->lumps[LUMP_PLANES]);
|
||||
Mod_LoadTexinfo (mod, mod_base, &header->lumps[LUMP_TEXINFO]);
|
||||
Mod_LoadVertexes (mod->name, &mod->vertexes, &mod->numvertexes, mod_base,
|
||||
&header->lumps[LUMP_VERTEXES], 8);
|
||||
Mod_LoadEdges (mod->name, &mod->edges, &mod->numedges,
|
||||
mod_base, &header->lumps[LUMP_EDGES], 13);
|
||||
Mod_LoadSurfedges (mod->name, &mod->surfedges, &mod->numsurfedges,
|
||||
mod_base, &header->lumps[LUMP_SURFEDGES], 24);
|
||||
Mod_LoadLighting (&mod->lightdata, mod_base, &header->lumps[LUMP_LIGHTING]);
|
||||
Mod_LoadPlanes (mod->name, &mod->planes, &mod->numplanes,
|
||||
mod_base, &header->lumps[LUMP_PLANES], 6);
|
||||
Mod_LoadTexinfo (mod->name, &mod->texinfo, &mod->numtexinfo,
|
||||
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)R_FindImage,
|
||||
r_notexture_mip, 6);
|
||||
Mod_LoadFaces (mod, mod_base, &header->lumps[LUMP_FACES]);
|
||||
Mod_LoadMarksurfaces (mod, mod_base, &header->lumps[LUMP_LEAFFACES]);
|
||||
Mod_LoadVisibility (mod, 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_LoadNodes (mod->name, mod->planes, mod->leafs, &mod->nodes,
|
||||
&mod->numnodes, mod_base, &header->lumps[LUMP_NODES]);
|
||||
Mod_LoadNodes (mod->name, mod->planes, mod->numplanes, mod->leafs,
|
||||
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
|
||||
&header->lumps[LUMP_NODES]);
|
||||
Mod_LoadSubmodels (mod, mod_base, &header->lumps[LUMP_MODELS]);
|
||||
|
||||
r_numvisleafs = 0;
|
||||
R_NumberLeafs (mod, mod->nodes);
|
||||
|
||||
R_InitSkyBox (mod);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue