mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-30 00:10:53 +00:00
Share SetSurfaceLighting between renders
This commit is contained in:
parent
38cbdaf00a
commit
3b7170c4bd
12 changed files with 64 additions and 134 deletions
|
@ -1658,19 +1658,40 @@ Mod_LoadLighting
|
|||
=================
|
||||
*/
|
||||
void
|
||||
Mod_LoadLighting(byte **lightdata, const byte *mod_base, const lump_t *l)
|
||||
Mod_LoadLighting(byte **lightdata, int *size, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
int size;
|
||||
|
||||
if (!l->filelen)
|
||||
{
|
||||
*lightdata = NULL;
|
||||
*size = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
size = l->filelen;
|
||||
*lightdata = Hunk_Alloc(size);
|
||||
memcpy(*lightdata, mod_base + l->fileofs, size);
|
||||
*size = l->filelen;
|
||||
*lightdata = Hunk_Alloc(*size);
|
||||
memcpy(*lightdata, mod_base + l->fileofs, *size);
|
||||
}
|
||||
|
||||
void
|
||||
SetSurfaceLighting(byte *lightdata, int size, msurface_t *out, byte *styles, int lightofs)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* lighting info */
|
||||
for (i = 0; i < MAXLIGHTMAPS; i++)
|
||||
{
|
||||
out->styles[i] = styles[i];
|
||||
}
|
||||
|
||||
i = LittleLong(lightofs);
|
||||
if (i == -1 || lightdata == NULL || i >= size)
|
||||
{
|
||||
out->samples = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
out->samples = lightdata + i;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -439,28 +439,6 @@ Mod_LoadBSPXDecoupledLM(const dlminfo_t* lminfos, int surfnum, msurface_t *out)
|
|||
return LittleLong(lminfo->lightofs);
|
||||
}
|
||||
|
||||
static void
|
||||
SetSurfaceLighting(model_t *loadmodel, msurface_t *out, byte *styles, int lightofs)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* lighting info */
|
||||
for (i = 0; i < MAXLIGHTMAPS; i++)
|
||||
{
|
||||
out->styles[i] = styles[i];
|
||||
}
|
||||
|
||||
i = LittleLong(lightofs);
|
||||
if (i == -1 || loadmodel->lightdata == NULL)
|
||||
{
|
||||
out->samples = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
out->samples = loadmodel->lightdata + i;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
||||
const bspx_header_t *bspx_header)
|
||||
|
@ -545,7 +523,8 @@ Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
lightofs = in->lightofs;
|
||||
}
|
||||
|
||||
SetSurfaceLighting(loadmodel, out, in->styles, lightofs);
|
||||
SetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, lightofs);
|
||||
|
||||
/* set the drawing flags */
|
||||
if (out->texinfo->flags & SURF_WARP)
|
||||
|
@ -668,7 +647,8 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
lightofs = in->lightofs;
|
||||
}
|
||||
|
||||
SetSurfaceLighting(loadmodel, out, in->styles, lightofs);
|
||||
SetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, lightofs);
|
||||
|
||||
/* set the drawing flags */
|
||||
if (out->texinfo->flags & SURF_WARP)
|
||||
|
@ -995,7 +975,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
|||
}
|
||||
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_LoadLighting(&mod->lightdata, &mod->numlightdata, 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,
|
||||
|
|
|
@ -86,6 +86,7 @@ typedef struct model_s
|
|||
dvis_t *vis;
|
||||
|
||||
byte *lightdata;
|
||||
int numlightdata;
|
||||
|
||||
/* for alias models and skins */
|
||||
image_t *skins[MAX_MD2SKINS];
|
||||
|
|
|
@ -398,28 +398,6 @@ calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *t
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
SetSurfaceLighting(gl3model_t *loadmodel, msurface_t *out, byte *styles, int lightofs)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* lighting info */
|
||||
for (i = 0; i < MAX_LIGHTMAPS_PER_SURFACE; i++)
|
||||
{
|
||||
out->styles[i] = styles[i];
|
||||
}
|
||||
|
||||
i = LittleLong(lightofs);
|
||||
if (i == -1 || loadmodel->lightdata == NULL)
|
||||
{
|
||||
out->samples = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
out->samples = loadmodel->lightdata + i;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
||||
const bspx_header_t *bspx_header)
|
||||
|
@ -487,7 +465,8 @@ Mod_LoadFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
|
||||
Mod_CalcSurfaceExtents(loadmodel, out);
|
||||
|
||||
SetSurfaceLighting(loadmodel, out, in->styles, in->lightofs);
|
||||
SetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, in->lightofs);
|
||||
|
||||
/* set the drawing flags */
|
||||
if (out->texinfo->flags & SURF_WARP)
|
||||
|
@ -593,7 +572,8 @@ Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
|
||||
Mod_CalcSurfaceExtents(loadmodel, out);
|
||||
|
||||
SetSurfaceLighting(loadmodel, out, in->styles, in->lightofs);
|
||||
SetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, in->lightofs);
|
||||
|
||||
/* set the drawing flags */
|
||||
if (out->texinfo->flags & SURF_WARP)
|
||||
|
@ -920,7 +900,8 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
|
|||
}
|
||||
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_LoadLighting(&mod->lightdata, &mod->numlightdata, 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,
|
||||
|
|
|
@ -97,6 +97,7 @@ typedef struct model_s
|
|||
dvis_t *vis;
|
||||
|
||||
byte *lightdata;
|
||||
int numlightdata;
|
||||
|
||||
/* for alias models and skins */
|
||||
gl3image_t *skins[MAX_MD2SKINS];
|
||||
|
|
|
@ -377,22 +377,8 @@ Mod_LoadFaces(gl4model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
|
||||
Mod_CalcSurfaceExtents(loadmodel, out);
|
||||
|
||||
/* lighting info */
|
||||
for (i = 0; i < MAX_LIGHTMAPS_PER_SURFACE; i++)
|
||||
{
|
||||
out->styles[i] = in->styles[i];
|
||||
}
|
||||
|
||||
i = LittleLong(in->lightofs);
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
out->samples = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
out->samples = loadmodel->lightdata + i;
|
||||
}
|
||||
SetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, in->lightofs);
|
||||
|
||||
/* set the drawing flags */
|
||||
if (out->texinfo->flags & SURF_WARP)
|
||||
|
@ -595,7 +581,8 @@ Mod_LoadBrushModel(gl4model_t *mod, void *buffer, int modfilelen)
|
|||
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_LoadLighting(&mod->lightdata, &mod->numlightdata, 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,
|
||||
|
|
|
@ -97,6 +97,7 @@ typedef struct model_s
|
|||
dvis_t *vis;
|
||||
|
||||
byte *lightdata;
|
||||
int numlightdata;
|
||||
|
||||
/* for alias models and skins */
|
||||
gl4image_t *skins[MAX_MD2SKINS];
|
||||
|
|
|
@ -337,7 +337,8 @@ extern void Mod_LoadQNodes(const char *name, cplane_t *planes, int numplanes,
|
|||
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_LoadLighting(byte **lightdata, int *size, const byte *mod_base, const lump_t *l);
|
||||
extern void SetSurfaceLighting(byte *lightdata, int size, msurface_t *out, byte *styles, int lightofs);
|
||||
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);
|
||||
|
|
|
@ -110,6 +110,7 @@ typedef struct model_s
|
|||
dvis_t *vis;
|
||||
|
||||
byte *lightdata;
|
||||
int numlightdata;
|
||||
|
||||
// for alias models and sprites
|
||||
image_t *skins[MAX_MD2SKINS];
|
||||
|
|
|
@ -313,24 +313,10 @@ Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
out->texinfo = loadmodel->texinfo + ti;
|
||||
out->lmshift = DEFAULT_LMSHIFT;
|
||||
|
||||
Mod_CalcSurfaceExtents (loadmodel, out);
|
||||
Mod_CalcSurfaceExtents(loadmodel, out);
|
||||
|
||||
// lighting is saved as its with 24 bit color
|
||||
for (i=0 ; i<MAXLIGHTMAPS ; i++)
|
||||
{
|
||||
out->styles[i] = in->styles[i];
|
||||
}
|
||||
|
||||
i = LittleLong(in->lightofs);
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
out->samples = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
out->samples = loadmodel->lightdata + i;
|
||||
}
|
||||
SetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, in->lightofs);
|
||||
|
||||
/* set the drawing flags flag */
|
||||
if (!out->texinfo->image)
|
||||
|
@ -437,22 +423,8 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
|
||||
Mod_CalcSurfaceExtents (loadmodel, out);
|
||||
|
||||
// lighting is saved as its with 24 bit color
|
||||
for (i=0 ; i<MAXLIGHTMAPS ; i++)
|
||||
{
|
||||
out->styles[i] = in->styles[i];
|
||||
}
|
||||
|
||||
i = LittleLong(in->lightofs);
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
out->samples = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
out->samples = loadmodel->lightdata + i;
|
||||
}
|
||||
SetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, in->lightofs);
|
||||
|
||||
if (!out->texinfo->image)
|
||||
continue;
|
||||
|
@ -786,7 +758,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
|||
}
|
||||
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_LoadLighting(&mod->lightdata, &mod->numlightdata, 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,
|
||||
|
|
|
@ -106,6 +106,7 @@ typedef struct model_s
|
|||
dvis_t *vis;
|
||||
|
||||
byte *lightdata;
|
||||
int numlightdata;
|
||||
|
||||
/* for alias models and skins */
|
||||
image_t *skins[MAX_MD2SKINS];
|
||||
|
|
|
@ -409,28 +409,6 @@ Mod_LoadBSPXDecoupledLM(const dlminfo_t* lminfos, int surfnum, msurface_t *out)
|
|||
return LittleLong(lminfo->lightofs);
|
||||
}
|
||||
|
||||
static void
|
||||
SetSurfaceLighting(model_t *loadmodel, msurface_t *out, byte *styles, int lightofs)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* lighting info */
|
||||
for (i = 0; i < MAXLIGHTMAPS; i++)
|
||||
{
|
||||
out->styles[i] = styles[i];
|
||||
}
|
||||
|
||||
i = LittleLong(lightofs);
|
||||
if (i == -1 || loadmodel->lightdata == NULL)
|
||||
{
|
||||
out->samples = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
out->samples = loadmodel->lightdata + i;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
||||
const bspx_header_t *bspx_header)
|
||||
|
@ -515,7 +493,8 @@ Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
lightofs = in->lightofs;
|
||||
}
|
||||
|
||||
SetSurfaceLighting(loadmodel, out, in->styles, lightofs);
|
||||
SetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, lightofs);
|
||||
|
||||
/* set the drawing flags */
|
||||
if (out->texinfo->flags & SURF_WARP)
|
||||
|
@ -638,7 +617,8 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
lightofs = in->lightofs;
|
||||
}
|
||||
|
||||
SetSurfaceLighting(loadmodel, out, in->styles, lightofs);
|
||||
SetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, lightofs);
|
||||
|
||||
/* set the drawing flags */
|
||||
if (out->texinfo->flags & SURF_WARP)
|
||||
|
@ -965,7 +945,8 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
|||
}
|
||||
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_LoadLighting(&mod->lightdata, &mod->numlightdata, 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,
|
||||
|
|
Loading…
Reference in a new issue