mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-17 01:21:12 +00:00
gl1,vk: Share SetCacheState and fix q64/outpost
This commit is contained in:
parent
9874f1a6c0
commit
85c18a8090
19 changed files with 322 additions and 138 deletions
|
@ -276,3 +276,16 @@ R_LightPoint(const bspxlightgrid_t *grid, const entity_t *currententity,
|
|||
|
||||
VectorScale(color, modulate, color);
|
||||
}
|
||||
|
||||
void
|
||||
R_SetCacheState(msurface_t *surf, refdef_t *refdef)
|
||||
{
|
||||
int maps;
|
||||
|
||||
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
|
||||
maps++)
|
||||
{
|
||||
surf->cached_light[maps] =
|
||||
refdef->lightstyles[surf->styles[maps]].white;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2101,7 +2101,7 @@ Mod_LoadBSPXDecoupledLM(const dlminfo_t* lminfos, int surfnum, msurface_t *out)
|
|||
}
|
||||
|
||||
static void
|
||||
Mod_LoadMarksurfaces(const char *name, msurface_t ***marksurfaces, int *nummarksurfaces,
|
||||
Mod_LoadMarksurfaces(const char *name, msurface_t ***marksurfaces, unsigned int *nummarksurfaces,
|
||||
msurface_t *surfaces, int numsurfaces, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
int i, count;
|
||||
|
@ -2139,7 +2139,7 @@ Mod_LoadMarksurfaces(const char *name, msurface_t ***marksurfaces, int *nummarks
|
|||
}
|
||||
|
||||
static void
|
||||
Mod_LoadQMarksurfaces(const char *name, msurface_t ***marksurfaces, int *nummarksurfaces,
|
||||
Mod_LoadQMarksurfaces(const char *name, msurface_t ***marksurfaces, unsigned int *nummarksurfaces,
|
||||
msurface_t *surfaces, int numsurfaces, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
int i, count;
|
||||
|
@ -2176,7 +2176,7 @@ Mod_LoadQMarksurfaces(const char *name, msurface_t ***marksurfaces, int *nummark
|
|||
}
|
||||
|
||||
void
|
||||
Mod_LoadQBSPMarksurfaces(const char *name, msurface_t ***marksurfaces, int *nummarksurfaces,
|
||||
Mod_LoadQBSPMarksurfaces(const char *name, msurface_t ***marksurfaces, unsigned int *nummarksurfaces,
|
||||
msurface_t *surfaces, int numsurfaces, const byte *mod_base, const lump_t *l, int ident)
|
||||
{
|
||||
if (ident == IDBSPHEADER)
|
||||
|
@ -2193,7 +2193,7 @@ Mod_LoadQBSPMarksurfaces(const char *name, msurface_t ***marksurfaces, int *numm
|
|||
|
||||
static void
|
||||
Mod_LoadLeafs(const char *name, mleaf_t **leafs, int *numleafs,
|
||||
msurface_t **marksurfaces, int nummarksurfaces,
|
||||
msurface_t **marksurfaces, unsigned int nummarksurfaces,
|
||||
const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dleaf_t *in;
|
||||
|
@ -2216,7 +2216,7 @@ Mod_LoadLeafs(const char *name, mleaf_t **leafs, int *numleafs,
|
|||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
unsigned firstleafface;
|
||||
unsigned int firstleafface;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
|
@ -2243,7 +2243,7 @@ Mod_LoadLeafs(const char *name, mleaf_t **leafs, int *numleafs,
|
|||
|
||||
static void
|
||||
Mod_LoadQLeafs(const char *name, mleaf_t **leafs, int *numleafs,
|
||||
msurface_t **marksurfaces, int nummarksurfaces,
|
||||
msurface_t **marksurfaces, unsigned int nummarksurfaces,
|
||||
const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dqleaf_t *in;
|
||||
|
@ -2266,7 +2266,7 @@ Mod_LoadQLeafs(const char *name, mleaf_t **leafs, int *numleafs,
|
|||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
unsigned firstleafface;
|
||||
unsigned int firstleafface;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
|
@ -2293,7 +2293,7 @@ Mod_LoadQLeafs(const char *name, mleaf_t **leafs, int *numleafs,
|
|||
|
||||
void
|
||||
Mod_LoadQBSPLeafs(const char *name, mleaf_t **leafs, int *numleafs,
|
||||
msurface_t **marksurfaces, int nummarksurfaces,
|
||||
msurface_t **marksurfaces, unsigned int nummarksurfaces,
|
||||
const byte *mod_base, const lump_t *l, int ident)
|
||||
{
|
||||
if (ident == IDBSPHEADER)
|
||||
|
|
|
@ -275,19 +275,6 @@ R_AddDynamicLights(msurface_t *surf)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
R_SetCacheState(msurface_t *surf)
|
||||
{
|
||||
int maps;
|
||||
|
||||
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
|
||||
maps++)
|
||||
{
|
||||
surf->cached_light[maps] =
|
||||
r_newrefdef.lightstyles[surf->styles[maps]].white;
|
||||
}
|
||||
}
|
||||
|
||||
float *s_blocklights = NULL, *s_blocklights_max = NULL;
|
||||
|
||||
/*
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
extern gllightmapstate_t gl_lms;
|
||||
|
||||
void R_SetCacheState(msurface_t *surf);
|
||||
void R_BuildLightMap(msurface_t *surf, byte *dest, int stride);
|
||||
|
||||
void
|
||||
|
@ -255,7 +254,7 @@ LM_CreateSurfaceLightmap(msurface_t *surf)
|
|||
base = gl_lms.lightmap_buffer;
|
||||
base += (surf->light_t * BLOCK_WIDTH + surf->light_s) * LIGHTMAP_BYTES;
|
||||
|
||||
R_SetCacheState(surf);
|
||||
R_SetCacheState(surf, &r_newrefdef);
|
||||
R_BuildLightMap(surf, base, BLOCK_WIDTH * LIGHTMAP_BYTES);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ void LM_InitBlock(void);
|
|||
void LM_UploadBlock(qboolean dynamic);
|
||||
qboolean LM_AllocBlock(int w, int h, int *x, int *y);
|
||||
|
||||
void R_SetCacheState(msurface_t *surf);
|
||||
void R_BuildLightMap(msurface_t *surf, byte *dest, int stride);
|
||||
|
||||
static void
|
||||
|
@ -510,7 +509,7 @@ R_RenderBrushPoly(entity_t *currententity, msurface_t *fa)
|
|||
tmax = (fa->extents[1] >> fa->lmshift) + 1;
|
||||
|
||||
R_BuildLightMap(fa, (void *)temp, smax * 4);
|
||||
R_SetCacheState(fa);
|
||||
R_SetCacheState(fa, &r_newrefdef);
|
||||
|
||||
R_Bind(gl_state.lightmap_textures + fa->lightmaptexturenum);
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ typedef struct model_s
|
|||
int numsurfedges;
|
||||
int *surfedges;
|
||||
|
||||
int nummarksurfaces;
|
||||
unsigned int nummarksurfaces;
|
||||
msurface_t **marksurfaces;
|
||||
|
||||
int numvisibility;
|
||||
|
|
|
@ -768,7 +768,7 @@ Mod_ForName (const char *name, gl3model_t *parent_model, qboolean crash)
|
|||
strcpy(mod->name, name);
|
||||
|
||||
/* load the file */
|
||||
modfilelen = Mod_LoadFile (mod->name, &buf);
|
||||
modfilelen = Mod_LoadFile(mod->name, &buf);
|
||||
|
||||
if (!buf)
|
||||
{
|
||||
|
|
|
@ -91,7 +91,7 @@ typedef struct model_s
|
|||
int numsurfedges;
|
||||
int *surfedges;
|
||||
|
||||
int nummarksurfaces;
|
||||
unsigned int nummarksurfaces;
|
||||
msurface_t **marksurfaces;
|
||||
|
||||
int numvisibility;
|
||||
|
|
|
@ -181,7 +181,8 @@ Mod_LoadSubmodels(gl4model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
}
|
||||
}
|
||||
|
||||
static int calcTexinfoAndFacesSize(byte *mod_base, const lump_t *fl, const lump_t *tl)
|
||||
static int
|
||||
calcTexinfoAndFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl)
|
||||
{
|
||||
dface_t* face_in = (void *)(mod_base + fl->fileofs);
|
||||
texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
|
||||
|
@ -256,14 +257,89 @@ static int calcTexinfoAndFacesSize(byte *mod_base, const lump_t *fl, const lump_
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadFaces(gl4model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
static int
|
||||
calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl)
|
||||
{
|
||||
dqface_t* face_in = (void *)(mod_base + fl->fileofs);
|
||||
texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
|
||||
|
||||
if (fl->filelen % sizeof(*face_in) || tl->filelen % sizeof(*texinfo_in))
|
||||
{
|
||||
// will error out when actually loading it
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
|
||||
int face_count = fl->filelen / sizeof(*face_in);
|
||||
int texinfo_count = tl->filelen / sizeof(*texinfo_in);
|
||||
|
||||
{
|
||||
// out = Hunk_Alloc(count * sizeof(*out));
|
||||
int baseSize = face_count * sizeof(msurface_t);
|
||||
baseSize = (baseSize + 31) & ~31;
|
||||
ret += baseSize;
|
||||
|
||||
int ti_size = texinfo_count * sizeof(mtexinfo_t);
|
||||
ti_size = (ti_size + 31) & ~31;
|
||||
ret += ti_size;
|
||||
}
|
||||
|
||||
int numWarpFaces = 0;
|
||||
|
||||
for (int surfnum = 0; surfnum < face_count; surfnum++, face_in++)
|
||||
{
|
||||
int numverts = LittleLong(face_in->numedges);
|
||||
int ti = LittleLong(face_in->texinfo);
|
||||
if ((ti < 0) || (ti >= texinfo_count))
|
||||
{
|
||||
return 0; // will error out
|
||||
}
|
||||
int texFlags = LittleLong(texinfo_in[ti].flags);
|
||||
|
||||
/* set the drawing flags */
|
||||
if (texFlags & SURF_WARP)
|
||||
{
|
||||
if (numverts > 60)
|
||||
return 0; // will error out in R_SubdividePolygon()
|
||||
|
||||
// R_SubdivideSurface(out, loadmodel); /* cut up polygon for warps */
|
||||
// for each (pot. recursive) call to R_SubdividePolygon():
|
||||
// sizeof(mpoly_t) + ((numverts - 4) + 2) * sizeof(mvtx_t)
|
||||
|
||||
// this is tricky, how much is allocated depends on the size of the surface
|
||||
// which we don't know (we'd need the vertices etc to know, but we can't load
|
||||
// those without allocating...)
|
||||
// so we just count warped faces and use a generous estimate below
|
||||
|
||||
++numWarpFaces;
|
||||
}
|
||||
else
|
||||
{
|
||||
// GL3_LM_BuildPolygonFromSurface(out);
|
||||
// => poly = Hunk_Alloc(sizeof(mpoly_t) + (numverts - 4) * sizeof(mvtx_t));
|
||||
int polySize = sizeof(mpoly_t) + (numverts - 4) * sizeof(mvtx_t);
|
||||
polySize = (polySize + 31) & ~31;
|
||||
ret += polySize;
|
||||
}
|
||||
}
|
||||
|
||||
// yeah, this is a bit hacky, but it looks like for each warped face
|
||||
// 256-55000 bytes are allocated (usually on the lower end),
|
||||
// so just assume 48k per face to be safe
|
||||
ret += numWarpFaces * 49152;
|
||||
ret += 5000000; // and 5MB extra just in case
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
||||
const bspx_header_t *bspx_header)
|
||||
{
|
||||
dface_t *in;
|
||||
msurface_t *out;
|
||||
int i, count, surfnum;
|
||||
int planenum, side;
|
||||
int ti;
|
||||
msurface_t *out;
|
||||
dface_t *in;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
|
@ -283,8 +359,16 @@ Mod_LoadFaces(gl4model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
|
||||
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
|
||||
{
|
||||
int side, ti, planenum;
|
||||
|
||||
out->firstedge = LittleLong(in->firstedge);
|
||||
out->numedges = LittleShort(in->numedges);
|
||||
|
||||
if (out->numedges < 3)
|
||||
{
|
||||
Com_Error(ERR_DROP, "%s: Surface with %d edges",
|
||||
__func__, out->numedges);
|
||||
}
|
||||
out->flags = 0;
|
||||
out->polys = NULL;
|
||||
|
||||
|
@ -359,11 +443,12 @@ Mod_LoadFaces(gl4model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
}
|
||||
|
||||
static void
|
||||
Mod_LoadLeafs(gl4model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
Mod_LoadQFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
||||
const bspx_header_t *bspx_header)
|
||||
{
|
||||
dleaf_t *in;
|
||||
mleaf_t *out;
|
||||
int i, j, count, p;
|
||||
int i, count, surfnum;
|
||||
msurface_t *out;
|
||||
dqface_t *in;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
|
@ -374,42 +459,100 @@ Mod_LoadLeafs(gl4model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
}
|
||||
|
||||
count = l->filelen / sizeof(*in);
|
||||
out = Hunk_Alloc(count * sizeof(*out));
|
||||
out = Hunk_Alloc((count + EXTRA_LUMP_FACES) * sizeof(*out));
|
||||
|
||||
loadmodel->leafs = out;
|
||||
loadmodel->numleafs = count;
|
||||
loadmodel->surfaces = out;
|
||||
loadmodel->numsurfaces = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
GL4_LM_BeginBuildingLightmaps(loadmodel);
|
||||
|
||||
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
|
||||
{
|
||||
unsigned firstleafface;
|
||||
int side, ti, planenum;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
out->firstedge = LittleLong(in->firstedge);
|
||||
out->numedges = LittleLong(in->numedges);
|
||||
|
||||
if (out->numedges < 3)
|
||||
{
|
||||
out->minmaxs[j] = LittleShort(in->mins[j]);
|
||||
out->minmaxs[3 + j] = LittleShort(in->maxs[j]);
|
||||
Com_Error(ERR_DROP, "%s: Surface with %d edges",
|
||||
__func__, out->numedges);
|
||||
}
|
||||
out->flags = 0;
|
||||
out->polys = NULL;
|
||||
|
||||
planenum = LittleLong(in->planenum);
|
||||
side = LittleLong(in->side);
|
||||
|
||||
if (side)
|
||||
{
|
||||
out->flags |= SURF_PLANEBACK;
|
||||
}
|
||||
|
||||
p = LittleLong(in->contents);
|
||||
out->contents = p;
|
||||
|
||||
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)
|
||||
if (planenum < 0 || planenum >= loadmodel->numplanes)
|
||||
{
|
||||
Com_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
|
||||
__func__, loadmodel->name);
|
||||
Com_Error(ERR_DROP, "%s: Incorrect %d planenum.",
|
||||
__func__, planenum);
|
||||
}
|
||||
out->plane = loadmodel->planes + planenum;
|
||||
|
||||
ti = LittleLong(in->texinfo);
|
||||
|
||||
if ((ti < 0) || (ti >= loadmodel->numtexinfo))
|
||||
{
|
||||
Com_Error(ERR_DROP, "%s: bad texinfo number",
|
||||
__func__);
|
||||
}
|
||||
|
||||
out->texinfo = loadmodel->texinfo + ti;
|
||||
out->lmshift = DEFAULT_LMSHIFT;
|
||||
|
||||
Mod_CalcSurfaceExtents(loadmodel->surfedges, loadmodel->vertexes,
|
||||
loadmodel->edges, out);
|
||||
|
||||
Mod_LoadSetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, in->lightofs);
|
||||
|
||||
/* set the drawing flags */
|
||||
if (out->texinfo->flags & SURF_WARP)
|
||||
{
|
||||
out->flags |= SURF_DRAWTURB;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
out->extents[i] = 16384;
|
||||
out->texturemins[i] = -8192;
|
||||
}
|
||||
|
||||
R_SubdivideSurface(loadmodel->surfedges, loadmodel->vertexes,
|
||||
loadmodel->edges, out); /* cut up polygon for warps */
|
||||
}
|
||||
|
||||
if (r_fixsurfsky->value)
|
||||
{
|
||||
if (out->texinfo->flags & SURF_SKY)
|
||||
{
|
||||
out->flags |= SURF_DRAWSKY;
|
||||
}
|
||||
}
|
||||
|
||||
/* create lightmaps and polygons */
|
||||
if (!(out->texinfo->flags & (SURF_SKY | SURF_TRANS33 | SURF_TRANS66 | SURF_WARP)))
|
||||
{
|
||||
GL4_LM_CreateSurfaceLightmap(out);
|
||||
}
|
||||
|
||||
if (!(out->texinfo->flags & SURF_WARP))
|
||||
{
|
||||
GL4_LM_BuildPolygonFromSurface(loadmodel, out);
|
||||
}
|
||||
}
|
||||
|
||||
GL4_LM_EndBuildingLightmaps();
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
|
||||
Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
|
||||
{
|
||||
const bspx_header_t *bspx_header;
|
||||
int i, lightgridsize = 0;
|
||||
|
@ -418,14 +561,22 @@ Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
|
|||
|
||||
if (mod != mod_known)
|
||||
{
|
||||
Com_Error(ERR_DROP, "Loaded a brush model after the world");
|
||||
Com_Error(ERR_DROP, "%s: Loaded a brush model after the world", __func__);
|
||||
}
|
||||
|
||||
header = (dheader_t *)buffer;
|
||||
|
||||
i = LittleLong(header->ident);
|
||||
|
||||
if (i != IDBSPHEADER && i != QBSPHEADER)
|
||||
{
|
||||
Com_Error(ERR_DROP, "%s: %s has wrong ident (%i should be %i)",
|
||||
__func__, mod->name, i, IDBSPHEADER);
|
||||
}
|
||||
|
||||
i = LittleLong(header->version);
|
||||
|
||||
if (i != BSPVERSION)
|
||||
if (i != BSPVERSION && i != BSPDKMVERSION)
|
||||
{
|
||||
Com_Error(ERR_DROP, "%s: %s has wrong version number (%i should be %i)",
|
||||
__func__, mod->name, i, BSPVERSION);
|
||||
|
@ -446,24 +597,52 @@ Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
|
|||
int hunkSize = 0;
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VERTEXES],
|
||||
sizeof(dvertex_t), sizeof(mvertex_t), EXTRA_LUMP_VERTEXES);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
|
||||
sizeof(dedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
|
||||
if (header->ident == IDBSPHEADER)
|
||||
{
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
|
||||
sizeof(dedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
|
||||
}
|
||||
else
|
||||
{
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_EDGES],
|
||||
sizeof(dqedge_t), sizeof(medge_t), EXTRA_LUMP_EDGES);
|
||||
}
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_SURFEDGES],
|
||||
sizeof(int), sizeof(int), EXTRA_LUMP_SURFEDGES);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LIGHTING],
|
||||
1, 1, 0);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_PLANES],
|
||||
sizeof(dplane_t), sizeof(cplane_t), EXTRA_LUMP_PLANES);
|
||||
hunkSize += calcTexinfoAndFacesSize(mod_base,
|
||||
&header->lumps[LUMP_FACES], &header->lumps[LUMP_TEXINFO]);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFFACES],
|
||||
sizeof(short), sizeof(msurface_t *), 0); // yes, out is indeed a pointer!
|
||||
if (header->ident == IDBSPHEADER)
|
||||
{
|
||||
hunkSize += calcTexinfoAndFacesSize(mod_base,
|
||||
&header->lumps[LUMP_FACES], &header->lumps[LUMP_TEXINFO]);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFFACES],
|
||||
sizeof(short), sizeof(msurface_t *), 0); // yes, out is indeed a pointer!
|
||||
}
|
||||
else
|
||||
{
|
||||
hunkSize += calcTexinfoAndQFacesSize(mod_base,
|
||||
&header->lumps[LUMP_FACES], &header->lumps[LUMP_TEXINFO]);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFFACES],
|
||||
sizeof(int), sizeof(msurface_t *), 0); // yes, out is indeed a pointer!
|
||||
}
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_VISIBILITY],
|
||||
1, 1, 0);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
|
||||
sizeof(dleaf_t), sizeof(mleaf_t), 0);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
|
||||
sizeof(dnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
|
||||
if (header->ident == IDBSPHEADER)
|
||||
{
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
|
||||
sizeof(dleaf_t), sizeof(mleaf_t), 0);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
|
||||
sizeof(dnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
|
||||
}
|
||||
else
|
||||
{
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
|
||||
sizeof(dqleaf_t), sizeof(mleaf_t), 0);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
|
||||
sizeof(dqnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
|
||||
}
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_MODELS],
|
||||
sizeof(dmodel_t), sizeof(gl4model_t), 0);
|
||||
|
||||
|
@ -494,46 +673,34 @@ Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
|
|||
mod_base, &header->lumps[LUMP_SURFEDGES]);
|
||||
Mod_LoadLighting(&mod->lightdata, &mod->numlightdata, mod_base,
|
||||
&header->lumps[LUMP_LIGHTING]);
|
||||
Mod_LoadPlanes (mod->name, &mod->planes, &mod->numplanes,
|
||||
Mod_LoadPlanes(mod->name, &mod->planes, &mod->numplanes,
|
||||
mod_base, &header->lumps[LUMP_PLANES]);
|
||||
Mod_LoadTexinfo (mod->name, &mod->texinfo, &mod->numtexinfo,
|
||||
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
|
||||
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)GL4_FindImage,
|
||||
gl4_notexture);
|
||||
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES]);
|
||||
if (header->ident == IDBSPHEADER)
|
||||
{
|
||||
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mod_LoadQFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
|
||||
}
|
||||
Mod_LoadQBSPMarksurfaces(mod->name, &mod->marksurfaces, &mod->nummarksurfaces,
|
||||
mod->surfaces, mod->numsurfaces, mod_base, &header->lumps[LUMP_LEAFFACES],
|
||||
header->ident);
|
||||
Mod_LoadVisibility(mod->name, &mod->vis, &mod->numvisibility, mod_base,
|
||||
&header->lumps[LUMP_VISIBILITY]);
|
||||
Mod_LoadLeafs(mod, mod_base, &header->lumps[LUMP_LEAFS]);
|
||||
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
|
||||
mod->marksurfaces, mod->nummarksurfaces, mod_base,
|
||||
&header->lumps[LUMP_LEAFS], header->ident);
|
||||
Mod_LoadQBSPNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
|
||||
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
|
||||
&header->lumps[LUMP_NODES], header->ident);
|
||||
Mod_LoadSubmodels (mod, mod_base, &header->lumps[LUMP_MODELS]);
|
||||
Mod_LoadSubmodels(mod, mod_base, &header->lumps[LUMP_MODELS]);
|
||||
mod->numframes = 2; /* regular and alternate animation */
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_Free(gl4model_t *mod)
|
||||
{
|
||||
Hunk_Free(mod->extradata);
|
||||
memset(mod, 0, sizeof(*mod));
|
||||
}
|
||||
|
||||
void
|
||||
GL4_Mod_FreeAll(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < mod_numknown; i++)
|
||||
{
|
||||
if (mod_known[i].extradatasize)
|
||||
{
|
||||
Mod_Free(&mod_known[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads in a model for the given name
|
||||
*/
|
||||
|
@ -590,7 +757,7 @@ Mod_ForName (const char *name, gl4model_t *parent_model, qboolean crash)
|
|||
{
|
||||
if (mod_numknown == MAX_MOD_KNOWN)
|
||||
{
|
||||
Com_Error(ERR_DROP, "mod_numknown == MAX_MOD_KNOWN");
|
||||
Com_Error(ERR_DROP, "%s: mod_numknown == MAX_MOD_KNOWN", __func__);
|
||||
}
|
||||
|
||||
mod_numknown++;
|
||||
|
@ -599,7 +766,7 @@ Mod_ForName (const char *name, gl4model_t *parent_model, qboolean crash)
|
|||
strcpy(mod->name, name);
|
||||
|
||||
/* load the file */
|
||||
modfilelen = ri.FS_LoadFile(mod->name, (void **)&buf);
|
||||
modfilelen = Mod_LoadFile(mod->name, &buf);
|
||||
|
||||
if (!buf)
|
||||
{
|
||||
|
@ -669,6 +836,27 @@ Mod_ForName (const char *name, gl4model_t *parent_model, qboolean crash)
|
|||
return mod;
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_Free(gl4model_t *mod)
|
||||
{
|
||||
Hunk_Free(mod->extradata);
|
||||
memset(mod, 0, sizeof(*mod));
|
||||
}
|
||||
|
||||
void
|
||||
GL4_Mod_FreeAll(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < mod_numknown; i++)
|
||||
{
|
||||
if (mod_known[i].extradatasize)
|
||||
{
|
||||
Mod_Free(&mod_known[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Specifies the model that will be used as the world
|
||||
*/
|
||||
|
|
|
@ -91,7 +91,7 @@ typedef struct model_s
|
|||
int numsurfedges;
|
||||
int *surfedges;
|
||||
|
||||
int nummarksurfaces;
|
||||
unsigned int nummarksurfaces;
|
||||
msurface_t **marksurfaces;
|
||||
|
||||
int numvisibility;
|
||||
|
|
|
@ -188,7 +188,7 @@ typedef struct mleaf_s
|
|||
int area;
|
||||
|
||||
struct msurface_s **firstmarksurface;
|
||||
int nummarksurfaces;
|
||||
unsigned int nummarksurfaces;
|
||||
int key; /* BSP sequence number for leaf's contents */
|
||||
} mleaf_t;
|
||||
|
||||
|
@ -331,13 +331,13 @@ 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_LoadQBSPMarksurfaces(const char *name, msurface_t ***marksurfaces,
|
||||
int *nummarksurfaces, msurface_t *surfaces, int numsurfaces,
|
||||
unsigned 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,
|
||||
mleaf_t *leafs, int numleafs, mnode_t **nodes, int *numnodes,
|
||||
const byte *mod_base, const lump_t *l, int ident);
|
||||
extern void Mod_LoadQBSPLeafs(const char *name, mleaf_t **leafs, int *numleafs,
|
||||
msurface_t **marksurfaces, int nummarksurfaces,
|
||||
msurface_t **marksurfaces, unsigned int nummarksurfaces,
|
||||
const byte *mod_base, const lump_t *l, int ident);
|
||||
extern void Mod_LoadQBSPEdges(const char *name, medge_t **edges, int *numedges,
|
||||
const byte *mod_base, const lump_t *l, int ident);
|
||||
|
@ -379,6 +379,7 @@ extern void R_SubdivideSurface(int *surfedges, mvertex_t *vertexes, medge_t *edg
|
|||
extern bspxlightgrid_t *Mod_LoadBSPXLightGrid(const bspx_header_t *bspx_header, const byte *mod_base);
|
||||
extern void R_LightPoint(const bspxlightgrid_t *grid, const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
|
||||
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot);
|
||||
extern void R_SetCacheState(msurface_t *surf, refdef_t *r_newrefdef);
|
||||
|
||||
/* Warp Sky logic */
|
||||
extern void R_ClipSkyPolygon(int nump, vec3_t vecs, int stage,
|
||||
|
|
|
@ -104,8 +104,8 @@ typedef struct model_s
|
|||
int numsurfedges;
|
||||
int *surfedges;
|
||||
|
||||
int nummarksurfaces;
|
||||
msurface_t **marksurfaces;
|
||||
unsigned int nummarksurfaces;
|
||||
msurface_t **marksurfaces;
|
||||
|
||||
int numvisibility;
|
||||
dvis_t *vis;
|
||||
|
|
|
@ -192,7 +192,6 @@ void R_DrawBrushModel(entity_t *currententity, const model_t *currentmodel);
|
|||
void R_DrawBeam(entity_t *currententity);
|
||||
void R_DrawWorld(void);
|
||||
void R_RenderDlights(void);
|
||||
void R_SetCacheState(msurface_t *surf );
|
||||
void R_BuildLightMap(msurface_t *surf, byte *dest, int stride);
|
||||
void R_DrawAlphaSurfaces(void);
|
||||
void RE_InitParticleTexture(void);
|
||||
|
|
|
@ -100,7 +100,7 @@ typedef struct model_s
|
|||
int numsurfedges;
|
||||
int *surfedges;
|
||||
|
||||
int nummarksurfaces;
|
||||
unsigned int nummarksurfaces;
|
||||
msurface_t **marksurfaces;
|
||||
|
||||
int numvisibility;
|
||||
|
|
|
@ -265,19 +265,6 @@ R_AddDynamicLights(msurface_t *surf)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
R_SetCacheState(msurface_t *surf)
|
||||
{
|
||||
int maps;
|
||||
|
||||
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
|
||||
maps++)
|
||||
{
|
||||
surf->cached_light[maps] =
|
||||
r_newrefdef.lightstyles[surf->styles[maps]].white;
|
||||
}
|
||||
}
|
||||
|
||||
float *s_blocklights = NULL, *s_blocklights_max = NULL;
|
||||
|
||||
/*
|
||||
|
|
|
@ -261,7 +261,7 @@ Vk_CreateSurfaceLightmap(msurface_t *surf)
|
|||
base = vk_lms.lightmap_buffer;
|
||||
base += (surf->light_t * BLOCK_WIDTH + surf->light_s) * LIGHTMAP_BYTES;
|
||||
|
||||
R_SetCacheState(surf);
|
||||
R_SetCacheState(surf, &r_newrefdef);
|
||||
R_BuildLightMap(surf, base, BLOCK_WIDTH * LIGHTMAP_BYTES);
|
||||
}
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ R_RenderBrushPoly(msurface_t *fa, float *modelMatrix, float alpha, entity_t *cur
|
|||
tmax = (fa->extents[1] >> fa->lmshift) + 1;
|
||||
|
||||
R_BuildLightMap(fa, (void *)temp, smax * 4);
|
||||
R_SetCacheState(fa);
|
||||
R_SetCacheState(fa, &r_newrefdef);
|
||||
|
||||
QVk_UpdateTextureData(&vk_state.lightmap_textures[fa->lightmaptexturenum], (unsigned char*)temp, fa->light_s, fa->light_t, smax, tmax);
|
||||
|
||||
|
@ -452,7 +452,7 @@ Vk_RenderLightmappedPoly(msurface_t *surf, float *modelMatrix, float alpha, enti
|
|||
|
||||
if ((surf->styles[map] >= 32 || surf->styles[map] == 0) && (surf->dlightframe != r_framecount))
|
||||
{
|
||||
R_SetCacheState(surf);
|
||||
R_SetCacheState(surf, &r_newrefdef);
|
||||
|
||||
lmtex = surf->lightmaptexturenum;
|
||||
QVk_UpdateTextureData(&vk_state.lightmap_textures[surf->lightmaptexturenum], (unsigned char *)temp, surf->light_s, surf->light_t, smax, tmax);
|
||||
|
|
|
@ -54,8 +54,8 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
int contents;
|
||||
int numsides;
|
||||
int firstbrushside;
|
||||
unsigned int numsides;
|
||||
unsigned int firstbrushside;
|
||||
int checkcount; /* to avoid repeated testings */
|
||||
} cbrush_t;
|
||||
|
||||
|
@ -644,7 +644,7 @@ CM_ClipBoxToBrush(vec3_t mins, vec3_t maxs, vec3_t p1,
|
|||
leavefrac = 1;
|
||||
clipplane = NULL;
|
||||
|
||||
if (!brush->numsides)
|
||||
if (!brush->numsides || !cmod.map_brushsides)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -659,6 +659,14 @@ CM_ClipBoxToBrush(vec3_t mins, vec3_t maxs, vec3_t p1,
|
|||
|
||||
for (i = 0; i < brush->numsides; i++)
|
||||
{
|
||||
if (((brush->firstbrushside + i) < 0) ||
|
||||
((brush->firstbrushside + i) >= (cmod.numbrushsides + EXTRA_LUMP_BRUSHSIDES)))
|
||||
{
|
||||
Com_DPrintf("%s: Incorrect brushside %d\n",
|
||||
__func__, brush->firstbrushside + i);
|
||||
break;
|
||||
}
|
||||
|
||||
side = &cmod.map_brushsides[brush->firstbrushside + i];
|
||||
plane = side->plane;
|
||||
|
||||
|
@ -786,13 +794,21 @@ CM_TestBoxInBrush(vec3_t mins, vec3_t maxs, vec3_t p1,
|
|||
float d1;
|
||||
cbrushside_t *side;
|
||||
|
||||
if (!brush->numsides)
|
||||
if (!brush->numsides || !cmod.map_brushsides)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < brush->numsides; i++)
|
||||
{
|
||||
if (((brush->firstbrushside + i) < 0) ||
|
||||
((brush->firstbrushside + i) >= (cmod.numbrushsides + EXTRA_LUMP_BRUSHSIDES)))
|
||||
{
|
||||
Com_DPrintf("%s: Incorrect brushside %d\n",
|
||||
__func__, brush->firstbrushside + i);
|
||||
break;
|
||||
}
|
||||
|
||||
side = &cmod.map_brushsides[brush->firstbrushside + i];
|
||||
plane = side->plane;
|
||||
|
||||
|
@ -1408,8 +1424,8 @@ CMod_LoadBrushes(const char* name, cbrush_t **map_brushes, int *numbrushes,
|
|||
|
||||
for (i = 0; i < count; i++, out++, in++)
|
||||
{
|
||||
out->firstbrushside = LittleLong(in->firstside);
|
||||
out->numsides = LittleLong(in->numsides);
|
||||
out->firstbrushside = LittleLong(in->firstside) & 0xFFFFFFFF;
|
||||
out->numsides = LittleLong(in->numsides) & 0xFFFFFFFF;
|
||||
out->contents = LittleLong(in->contents);
|
||||
}
|
||||
}
|
||||
|
@ -1833,14 +1849,9 @@ CM_ModFree(model_t *cmod)
|
|||
if (cmod->extradata && cmod->extradatasize)
|
||||
{
|
||||
Hunk_Free(cmod->extradata);
|
||||
cmod->extradata = NULL;
|
||||
cmod->extradatasize = 0;
|
||||
}
|
||||
|
||||
memset(cmod, 0, sizeof(model_t));
|
||||
|
||||
cmod->numareas = 1;
|
||||
cmod->numclusters = 1;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "shared.h"
|
||||
#include "crc.h"
|
||||
|
||||
#define YQ2VERSION "ReRelease 8.21.1"
|
||||
#define YQ2VERSION "8.21RR1"
|
||||
#define BASEDIRNAME "baseq2"
|
||||
|
||||
#ifndef YQ2OSTYPE
|
||||
|
|
Loading…
Reference in a new issue