mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
parent
bd86f646da
commit
fc543be4f5
10 changed files with 130 additions and 55 deletions
|
@ -1771,11 +1771,11 @@ Mod_CalcSurfaceExtents(int *surfedges, mvertex_t *vertexes, medge_t *edges,
|
|||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
bmins[i] = floor(mins[i] / 16);
|
||||
bmaxs[i] = ceil(maxs[i] / 16);
|
||||
bmins[i] = floor(mins[i] / (1 << s->lmshift));
|
||||
bmaxs[i] = ceil(maxs[i] / (1 << s->lmshift));
|
||||
|
||||
s->texturemins[i] = bmins[i] * 16;
|
||||
s->extents[i] = (bmaxs[i] - bmins[i]) * 16;
|
||||
s->texturemins[i] = bmins[i] * (1 << s->lmshift);
|
||||
s->extents[i] = (bmaxs[i] - bmins[i]) * (1 << s->lmshift);
|
||||
if (s->extents[i] < 16)
|
||||
{
|
||||
/* take at least one cache block */
|
||||
|
|
|
@ -34,11 +34,6 @@ static int mod_max = 0;
|
|||
|
||||
int registration_sequence;
|
||||
|
||||
void LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa);
|
||||
void LM_CreateSurfaceLightmap(msurface_t *surf);
|
||||
void LM_EndBuildingLightmaps(void);
|
||||
void LM_BeginBuildingLightmaps(model_t *m);
|
||||
|
||||
//===============================================================================
|
||||
|
||||
static qboolean
|
||||
|
@ -130,7 +125,7 @@ static void
|
|||
Mod_LoadSubmodels(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dmodel_t *in;
|
||||
model_t *out;
|
||||
model_t *out;
|
||||
int i, j, count;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
|
|
@ -344,6 +344,11 @@ typedef struct
|
|||
byte lightmap_buffer[LIGHTMAP_BYTES * BLOCK_WIDTH * BLOCK_HEIGHT];
|
||||
} gllightmapstate_t;
|
||||
|
||||
void LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa);
|
||||
void LM_CreateSurfaceLightmap(msurface_t *surf);
|
||||
void LM_EndBuildingLightmaps(void);
|
||||
void LM_BeginBuildingLightmaps(model_t *m);
|
||||
|
||||
extern glconfig_t gl_config;
|
||||
extern glstate_t gl_state;
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ GL3_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride)
|
|||
|
||||
stride -= (smax << 2);
|
||||
|
||||
if (size > 34*34*3)
|
||||
if (size > BLOCK_WIDTH * BLOCK_HEIGHT * 3)
|
||||
{
|
||||
Com_Error(ERR_DROP, "Bad s_blocklights size");
|
||||
}
|
||||
|
|
|
@ -73,13 +73,14 @@ LM_UploadBlock(void)
|
|||
qboolean
|
||||
LM_AllocBlock(int w, int h, int *x, int *y)
|
||||
{
|
||||
int i, j;
|
||||
int best, best2;
|
||||
int i, best;
|
||||
|
||||
best = BLOCK_HEIGHT;
|
||||
|
||||
for (i = 0; i < BLOCK_WIDTH - w; i++)
|
||||
{
|
||||
int j, best2;
|
||||
|
||||
best2 = 0;
|
||||
|
||||
for (j = 0; j < w; j++)
|
||||
|
@ -119,10 +120,9 @@ LM_AllocBlock(int w, int h, int *x, int *y)
|
|||
void
|
||||
LM_BuildPolygonFromSurface(gl3model_t *currentmodel, msurface_t *fa)
|
||||
{
|
||||
int i, lindex, lnumverts;
|
||||
int i, lnumverts;
|
||||
medge_t *pedges, *r_pedge;
|
||||
float *vec;
|
||||
float s, t;
|
||||
mpoly_t *poly;
|
||||
vec3_t total;
|
||||
vec3_t normal;
|
||||
|
@ -152,7 +152,11 @@ LM_BuildPolygonFromSurface(gl3model_t *currentmodel, msurface_t *fa)
|
|||
|
||||
for (i = 0; i < lnumverts; i++)
|
||||
{
|
||||
mvtx_t* vert = &poly->verts[i];
|
||||
mvtx_t* vert;
|
||||
float s, t;
|
||||
int lindex;
|
||||
|
||||
vert = &poly->verts[i];
|
||||
|
||||
lindex = currentmodel->surfedges[fa->firstedge + i];
|
||||
|
||||
|
@ -179,13 +183,13 @@ LM_BuildPolygonFromSurface(gl3model_t *currentmodel, msurface_t *fa)
|
|||
vert->texCoord[1] = t;
|
||||
|
||||
/* lightmap texture coordinates */
|
||||
s = DotProduct(vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
|
||||
s = DotProduct(vec, fa->lmvecs[0]) + fa->lmvecs[0][3];
|
||||
s -= fa->texturemins[0];
|
||||
s += fa->light_s * (1 << fa->lmshift);
|
||||
s += (1 << fa->lmshift) * 0.5;
|
||||
s /= BLOCK_WIDTH * (1 << fa->lmshift);
|
||||
|
||||
t = DotProduct(vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3];
|
||||
t = DotProduct(vec, fa->lmvecs[1]) + fa->lmvecs[1][3];
|
||||
t -= fa->texturemins[1];
|
||||
t += fa->light_t * (1 << fa->lmshift);
|
||||
t += (1 << fa->lmshift) * 0.5;
|
||||
|
@ -233,7 +237,6 @@ LM_CreateSurfaceLightmap(msurface_t *surf)
|
|||
void
|
||||
LM_BeginBuildingLightmaps(gl3model_t *m)
|
||||
{
|
||||
|
||||
static lightstyle_t lightstyles[MAX_LIGHTSTYLES];
|
||||
int i;
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ GL3_Mod_Init(void)
|
|||
}
|
||||
|
||||
static void
|
||||
Mod_LoadSubmodels(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||
Mod_LoadSubmodels(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
dmodel_t *in;
|
||||
gl3model_t *out;
|
||||
|
@ -337,7 +337,8 @@ static void
|
|||
Mod_LoadFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
||||
const bspx_header_t *bspx_header)
|
||||
{
|
||||
int i, count, surfnum;
|
||||
int i, count, surfnum, lminfosize, lightofs;
|
||||
const dlminfo_t *lminfos;
|
||||
msurface_t *out;
|
||||
dface_t *in;
|
||||
|
||||
|
@ -355,6 +356,13 @@ Mod_LoadFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
loadmodel->surfaces = out;
|
||||
loadmodel->numsurfaces = count;
|
||||
|
||||
lminfos = Mod_LoadBSPXFindLump(bspx_header, "DECOUPLED_LM", &lminfosize, mod_base);
|
||||
if (lminfos != NULL && lminfosize / sizeof(dlminfo_t) != loadmodel->numsurfaces) {
|
||||
R_Printf(PRINT_ALL, "%s: [%s] decoupled_lm size %ld does not match surface count %d\n",
|
||||
__func__, loadmodel->name, lminfosize / sizeof(dlminfo_t), loadmodel->numsurfaces);
|
||||
lminfos = NULL;
|
||||
}
|
||||
|
||||
LM_BeginBuildingLightmaps(loadmodel);
|
||||
|
||||
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
|
||||
|
@ -396,13 +404,22 @@ Mod_LoadFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
}
|
||||
|
||||
out->texinfo = loadmodel->texinfo + ti;
|
||||
out->lmshift = DEFAULT_LMSHIFT;
|
||||
|
||||
Mod_CalcSurfaceExtents(loadmodel->surfedges, loadmodel->vertexes,
|
||||
loadmodel->edges, out);
|
||||
lightofs = Mod_LoadBSPXDecoupledLM(lminfos, surfnum, out);
|
||||
if (lightofs < 0) {
|
||||
memcpy(out->lmvecs, out->texinfo->vecs, sizeof(out->lmvecs));
|
||||
out->lmshift = DEFAULT_LMSHIFT;
|
||||
out->lmvlen[0] = 1.0f;
|
||||
out->lmvlen[1] = 1.0f;
|
||||
|
||||
Mod_CalcSurfaceExtents(loadmodel->surfedges, loadmodel->vertexes,
|
||||
loadmodel->edges, out);
|
||||
|
||||
lightofs = in->lightofs;
|
||||
}
|
||||
|
||||
Mod_LoadSetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, in->lightofs);
|
||||
out, in->styles, lightofs);
|
||||
|
||||
/* set the drawing flags */
|
||||
if (out->texinfo->flags & SURF_WARP)
|
||||
|
@ -446,7 +463,8 @@ static void
|
|||
Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
||||
const bspx_header_t *bspx_header)
|
||||
{
|
||||
int i, count, surfnum;
|
||||
int i, count, surfnum, lminfosize, lightofs;
|
||||
const dlminfo_t *lminfos;
|
||||
msurface_t *out;
|
||||
dqface_t *in;
|
||||
|
||||
|
@ -464,6 +482,13 @@ Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
loadmodel->surfaces = out;
|
||||
loadmodel->numsurfaces = count;
|
||||
|
||||
lminfos = Mod_LoadBSPXFindLump(bspx_header, "DECOUPLED_LM", &lminfosize, mod_base);
|
||||
if (lminfos != NULL && lminfosize / sizeof(dlminfo_t) != loadmodel->numsurfaces) {
|
||||
R_Printf(PRINT_ALL, "%s: [%s] decoupled_lm size %ld does not match surface count %d\n",
|
||||
__func__, loadmodel->name, lminfosize / sizeof(dlminfo_t), loadmodel->numsurfaces);
|
||||
lminfos = NULL;
|
||||
}
|
||||
|
||||
LM_BeginBuildingLightmaps(loadmodel);
|
||||
|
||||
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
|
||||
|
@ -505,13 +530,22 @@ Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
}
|
||||
|
||||
out->texinfo = loadmodel->texinfo + ti;
|
||||
out->lmshift = DEFAULT_LMSHIFT;
|
||||
|
||||
Mod_CalcSurfaceExtents(loadmodel->surfedges, loadmodel->vertexes,
|
||||
loadmodel->edges, out);
|
||||
lightofs = Mod_LoadBSPXDecoupledLM(lminfos, surfnum, out);
|
||||
if (lightofs < 0) {
|
||||
memcpy(out->lmvecs, out->texinfo->vecs, sizeof(out->lmvecs));
|
||||
out->lmshift = DEFAULT_LMSHIFT;
|
||||
out->lmvlen[0] = 1.0f;
|
||||
out->lmvlen[1] = 1.0f;
|
||||
|
||||
Mod_CalcSurfaceExtents(loadmodel->surfedges, loadmodel->vertexes,
|
||||
loadmodel->edges, out);
|
||||
|
||||
lightofs = in->lightofs;
|
||||
}
|
||||
|
||||
Mod_LoadSetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, in->lightofs);
|
||||
out, in->styles, lightofs);
|
||||
|
||||
/* set the drawing flags */
|
||||
if (out->texinfo->flags & SURF_WARP)
|
||||
|
|
|
@ -35,8 +35,8 @@ vec3_t lightspot;
|
|||
void
|
||||
GL4_PushDlights(void)
|
||||
{
|
||||
int i;
|
||||
dlight_t *l;
|
||||
int i;
|
||||
|
||||
/* because the count hasn't advanced yet for this frame */
|
||||
r_dlightframecount = gl4_framecount + 1;
|
||||
|
@ -89,7 +89,7 @@ GL4_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride)
|
|||
|
||||
stride -= (smax << 2);
|
||||
|
||||
if (size > 34*34*3)
|
||||
if (size > BLOCK_WIDTH * BLOCK_HEIGHT * 3)
|
||||
{
|
||||
Com_Error(ERR_DROP, "Bad s_blocklights size");
|
||||
}
|
||||
|
|
|
@ -73,13 +73,14 @@ LM_UploadBlock(void)
|
|||
qboolean
|
||||
LM_AllocBlock(int w, int h, int *x, int *y)
|
||||
{
|
||||
int i, j;
|
||||
int best, best2;
|
||||
int i, best;
|
||||
|
||||
best = BLOCK_HEIGHT;
|
||||
|
||||
for (i = 0; i < BLOCK_WIDTH - w; i++)
|
||||
{
|
||||
int j, best2;
|
||||
|
||||
best2 = 0;
|
||||
|
||||
for (j = 0; j < w; j++)
|
||||
|
@ -119,10 +120,9 @@ LM_AllocBlock(int w, int h, int *x, int *y)
|
|||
void
|
||||
LM_BuildPolygonFromSurface(gl4model_t *currentmodel, msurface_t *fa)
|
||||
{
|
||||
int i, lindex, lnumverts;
|
||||
int i, lnumverts;
|
||||
medge_t *pedges, *r_pedge;
|
||||
float *vec;
|
||||
float s, t;
|
||||
mpoly_t *poly;
|
||||
vec3_t total;
|
||||
vec3_t normal;
|
||||
|
@ -152,7 +152,11 @@ LM_BuildPolygonFromSurface(gl4model_t *currentmodel, msurface_t *fa)
|
|||
|
||||
for (i = 0; i < lnumverts; i++)
|
||||
{
|
||||
mvtx_t* vert = &poly->verts[i];
|
||||
mvtx_t* vert;
|
||||
float s, t;
|
||||
int lindex;
|
||||
|
||||
vert = &poly->verts[i];
|
||||
|
||||
lindex = currentmodel->surfedges[fa->firstedge + i];
|
||||
|
||||
|
@ -179,13 +183,13 @@ LM_BuildPolygonFromSurface(gl4model_t *currentmodel, msurface_t *fa)
|
|||
vert->texCoord[1] = t;
|
||||
|
||||
/* lightmap texture coordinates */
|
||||
s = DotProduct(vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
|
||||
s = DotProduct(vec, fa->lmvecs[0]) + fa->lmvecs[0][3];
|
||||
s -= fa->texturemins[0];
|
||||
s += fa->light_s * (1 << fa->lmshift);
|
||||
s += (1 << fa->lmshift) * 0.5;
|
||||
s /= BLOCK_WIDTH * (1 << fa->lmshift);
|
||||
|
||||
t = DotProduct(vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3];
|
||||
t = DotProduct(vec, fa->lmvecs[1]) + fa->lmvecs[1][3];
|
||||
t -= fa->texturemins[1];
|
||||
t += fa->light_t * (1 << fa->lmshift);
|
||||
t += (1 << fa->lmshift) * 0.5;
|
||||
|
@ -233,7 +237,6 @@ LM_CreateSurfaceLightmap(msurface_t *surf)
|
|||
void
|
||||
LM_BeginBuildingLightmaps(gl4model_t *m)
|
||||
{
|
||||
|
||||
static lightstyle_t lightstyles[MAX_LIGHTSTYLES];
|
||||
int i;
|
||||
|
||||
|
|
|
@ -102,8 +102,8 @@ GL4_Mod_Modellist_f(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
R_Printf(PRINT_ALL, "%8i : %s %s\n",
|
||||
mod->extradatasize, mod->name, in_use);
|
||||
R_Printf(PRINT_ALL, "%8i : %s %s r: %f #%d\n",
|
||||
mod->extradatasize, mod->name, in_use, mod->radius, mod->numsubmodels);
|
||||
total += mod->extradatasize;
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,8 @@ static void
|
|||
Mod_LoadFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
||||
const bspx_header_t *bspx_header)
|
||||
{
|
||||
int i, count, surfnum;
|
||||
int i, count, surfnum, lminfosize, lightofs;
|
||||
const dlminfo_t *lminfos;
|
||||
msurface_t *out;
|
||||
dface_t *in;
|
||||
|
||||
|
@ -353,6 +354,13 @@ Mod_LoadFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
loadmodel->surfaces = out;
|
||||
loadmodel->numsurfaces = count;
|
||||
|
||||
lminfos = Mod_LoadBSPXFindLump(bspx_header, "DECOUPLED_LM", &lminfosize, mod_base);
|
||||
if (lminfos != NULL && lminfosize / sizeof(dlminfo_t) != loadmodel->numsurfaces) {
|
||||
R_Printf(PRINT_ALL, "%s: [%s] decoupled_lm size %ld does not match surface count %d\n",
|
||||
__func__, loadmodel->name, lminfosize / sizeof(dlminfo_t), loadmodel->numsurfaces);
|
||||
lminfos = NULL;
|
||||
}
|
||||
|
||||
LM_BeginBuildingLightmaps(loadmodel);
|
||||
|
||||
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
|
||||
|
@ -394,13 +402,22 @@ Mod_LoadFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
}
|
||||
|
||||
out->texinfo = loadmodel->texinfo + ti;
|
||||
out->lmshift = DEFAULT_LMSHIFT;
|
||||
|
||||
Mod_CalcSurfaceExtents(loadmodel->surfedges, loadmodel->vertexes,
|
||||
loadmodel->edges, out);
|
||||
lightofs = Mod_LoadBSPXDecoupledLM(lminfos, surfnum, out);
|
||||
if (lightofs < 0) {
|
||||
memcpy(out->lmvecs, out->texinfo->vecs, sizeof(out->lmvecs));
|
||||
out->lmshift = DEFAULT_LMSHIFT;
|
||||
out->lmvlen[0] = 1.0f;
|
||||
out->lmvlen[1] = 1.0f;
|
||||
|
||||
Mod_CalcSurfaceExtents(loadmodel->surfedges, loadmodel->vertexes,
|
||||
loadmodel->edges, out);
|
||||
|
||||
lightofs = in->lightofs;
|
||||
}
|
||||
|
||||
Mod_LoadSetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, in->lightofs);
|
||||
out, in->styles, lightofs);
|
||||
|
||||
/* set the drawing flags */
|
||||
if (out->texinfo->flags & SURF_WARP)
|
||||
|
@ -444,7 +461,8 @@ static void
|
|||
Mod_LoadQFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
||||
const bspx_header_t *bspx_header)
|
||||
{
|
||||
int i, count, surfnum;
|
||||
int i, count, surfnum, lminfosize, lightofs;
|
||||
const dlminfo_t *lminfos;
|
||||
msurface_t *out;
|
||||
dqface_t *in;
|
||||
|
||||
|
@ -462,6 +480,13 @@ Mod_LoadQFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
loadmodel->surfaces = out;
|
||||
loadmodel->numsurfaces = count;
|
||||
|
||||
lminfos = Mod_LoadBSPXFindLump(bspx_header, "DECOUPLED_LM", &lminfosize, mod_base);
|
||||
if (lminfos != NULL && lminfosize / sizeof(dlminfo_t) != loadmodel->numsurfaces) {
|
||||
R_Printf(PRINT_ALL, "%s: [%s] decoupled_lm size %ld does not match surface count %d\n",
|
||||
__func__, loadmodel->name, lminfosize / sizeof(dlminfo_t), loadmodel->numsurfaces);
|
||||
lminfos = NULL;
|
||||
}
|
||||
|
||||
LM_BeginBuildingLightmaps(loadmodel);
|
||||
|
||||
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
|
||||
|
@ -503,13 +528,22 @@ Mod_LoadQFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
}
|
||||
|
||||
out->texinfo = loadmodel->texinfo + ti;
|
||||
out->lmshift = DEFAULT_LMSHIFT;
|
||||
|
||||
Mod_CalcSurfaceExtents(loadmodel->surfedges, loadmodel->vertexes,
|
||||
loadmodel->edges, out);
|
||||
lightofs = Mod_LoadBSPXDecoupledLM(lminfos, surfnum, out);
|
||||
if (lightofs < 0) {
|
||||
memcpy(out->lmvecs, out->texinfo->vecs, sizeof(out->lmvecs));
|
||||
out->lmshift = DEFAULT_LMSHIFT;
|
||||
out->lmvlen[0] = 1.0f;
|
||||
out->lmvlen[1] = 1.0f;
|
||||
|
||||
Mod_CalcSurfaceExtents(loadmodel->surfedges, loadmodel->vertexes,
|
||||
loadmodel->edges, out);
|
||||
|
||||
lightofs = in->lightofs;
|
||||
}
|
||||
|
||||
Mod_LoadSetSurfaceLighting(loadmodel->lightdata, loadmodel->numlightdata,
|
||||
out, in->styles, in->lightofs);
|
||||
out, in->styles, lightofs);
|
||||
|
||||
/* set the drawing flags */
|
||||
if (out->texinfo->flags & SURF_WARP)
|
||||
|
@ -703,7 +737,7 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
|
|||
* Loads in a model for the given name
|
||||
*/
|
||||
static gl4model_t *
|
||||
Mod_ForName (const char *name, gl4model_t *parent_model, qboolean crash)
|
||||
Mod_ForName(const char *name, gl4model_t *parent_model, qboolean crash)
|
||||
{
|
||||
gl4model_t *mod;
|
||||
void *buf;
|
||||
|
@ -904,7 +938,8 @@ GL4_RegisterModel(const char *name)
|
|||
|
||||
for (i = 0; i < mod->numtexinfo; i++)
|
||||
{
|
||||
mod->texinfo[i].image->registration_sequence = registration_sequence;
|
||||
mod->texinfo[i].image->registration_sequence =
|
||||
registration_sequence;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -134,7 +134,7 @@ qboolean GL4_IsVsyncActive(void)
|
|||
}
|
||||
|
||||
/*
|
||||
* Enables or disabes the vsync.
|
||||
* Enables or disables the vsync.
|
||||
*/
|
||||
void GL4_SetVsync(void)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue