mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-05-10 14:20:38 +00:00
Whitespace, some optimizations
This commit is contained in:
parent
893a8ba827
commit
52cc1fa218
1 changed files with 25 additions and 55 deletions
|
@ -102,21 +102,21 @@ extern qboolean lighthalf;
|
||||||
|
|
||||||
// LordHavoc: place for gl_rsurf setup code
|
// LordHavoc: place for gl_rsurf setup code
|
||||||
void
|
void
|
||||||
glrsurf_init ()
|
glrsurf_init (void)
|
||||||
{
|
{
|
||||||
memset (&lightmaps, 0, sizeof (lightmaps));
|
memset (&lightmaps, 0, sizeof (lightmaps));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
recursivelightupdate (mnode_t *node)
|
R_RecursiveLightUpdate (mnode_t *node)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
msurface_t *surf;
|
msurface_t *surf;
|
||||||
|
|
||||||
if (node->children[0]->contents >= 0)
|
if (node->children[0]->contents >= 0)
|
||||||
recursivelightupdate (node->children[0]);
|
R_RecursiveLightUpdate (node->children[0]);
|
||||||
if (node->children[1]->contents >= 0)
|
if (node->children[1]->contents >= 0)
|
||||||
recursivelightupdate (node->children[1]);
|
R_RecursiveLightUpdate (node->children[1]);
|
||||||
if ((c = node->numsurfaces))
|
if ((c = node->numsurfaces))
|
||||||
for (surf = cl.worldmodel->surfaces + node->firstsurface; c;
|
for (surf = cl.worldmodel->surfaces + node->firstsurface; c;
|
||||||
c--, surf++) surf->cached_dlight = true;
|
c--, surf++) surf->cached_dlight = true;
|
||||||
|
@ -124,11 +124,11 @@ recursivelightupdate (mnode_t *node)
|
||||||
|
|
||||||
// LordHavoc: function to force all lightmaps to be updated
|
// LordHavoc: function to force all lightmaps to be updated
|
||||||
void
|
void
|
||||||
R_ForceLightUpdate ()
|
R_ForceLightUpdate (void)
|
||||||
{
|
{
|
||||||
if (cl.worldmodel && cl.worldmodel->nodes
|
if (cl.worldmodel && cl.worldmodel->nodes
|
||||||
&& cl.worldmodel->nodes->contents >= 0)
|
&& cl.worldmodel->nodes->contents >= 0)
|
||||||
recursivelightupdate (cl.worldmodel->nodes);
|
R_RecursiveLightUpdate (cl.worldmodel->nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -182,56 +182,38 @@ R_AddDynamicLights (msurface_t *surf)
|
||||||
impact[i] =
|
impact[i] =
|
||||||
cl_dlights[lnum].origin[i] - surf->plane->normal[i] * dist;
|
cl_dlights[lnum].origin[i] - surf->plane->normal[i] * dist;
|
||||||
|
|
||||||
f =
|
i = f = DotProduct (impact, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3] - surf->texturemins[0];
|
||||||
DotProduct (impact,
|
|
||||||
surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3] -
|
|
||||||
surf->texturemins[0];
|
|
||||||
i = f;
|
|
||||||
|
|
||||||
// reduce calculations
|
// reduce calculations
|
||||||
t = dist * dist;
|
t = dist * dist;
|
||||||
for (s = 0; s < smax; s++, i -= 16)
|
for (s = 0; s < smax; s++, i -= 16)
|
||||||
sdtable[s] = i * i + t;
|
sdtable[s] = i * i + t;
|
||||||
|
|
||||||
f =
|
i = f = DotProduct (impact, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3] - surf->texturemins[1];
|
||||||
DotProduct (impact,
|
|
||||||
surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3] -
|
// for comparisons to minimum acceptable light
|
||||||
surf->texturemins[1];
|
maxdist = (int) ((cl_dlights[lnum].radius * cl_dlights[lnum].radius) * 0.75);
|
||||||
i = f;
|
|
||||||
|
|
||||||
maxdist = (int) ((cl_dlights[lnum].radius * cl_dlights[lnum].radius) * 0.75); // for
|
|
||||||
// comparisons
|
|
||||||
// to
|
|
||||||
// minimum
|
|
||||||
// acceptable
|
|
||||||
// light
|
|
||||||
// clamp radius to avoid exceeding 8192 entry division table
|
// clamp radius to avoid exceeding 8192 entry division table
|
||||||
if (maxdist > 1048576)
|
if (maxdist > 1048576)
|
||||||
maxdist = 1048576;
|
maxdist = 1048576;
|
||||||
maxdist3 = maxdist - (int) (dist * dist);
|
maxdist3 = maxdist - (int) (dist * dist);
|
||||||
|
|
||||||
// convert to 8.8 blocklights format
|
// convert to 8.8 blocklights format
|
||||||
f = cl_dlights[lnum].color[0] * maxdist;
|
red = f = cl_dlights[lnum].color[0] * maxdist;
|
||||||
red = f;
|
green = f = cl_dlights[lnum].color[1] * maxdist;
|
||||||
f = cl_dlights[lnum].color[1] * maxdist;
|
blue = f = cl_dlights[lnum].color[2] * maxdist;
|
||||||
green = f;
|
|
||||||
f = cl_dlights[lnum].color[2] * maxdist;
|
|
||||||
blue = f;
|
|
||||||
bl = blocklights;
|
bl = blocklights;
|
||||||
for (t = 0; t < tmax; t++, i -= 16) {
|
for (t = 0; t < tmax; t++, i -= 16) {
|
||||||
td = i * i;
|
td = i * i;
|
||||||
if (td < maxdist3) // make sure some part of it is
|
if (td < maxdist3) { // make sure some part of it is visible on this line
|
||||||
// visible on this line
|
|
||||||
{
|
|
||||||
maxdist2 = maxdist - td;
|
maxdist2 = maxdist - td;
|
||||||
for (s = 0; s < smax; s++) {
|
for (s = 0; s < smax; s++) {
|
||||||
if (sdtable[s] < maxdist2) {
|
if (sdtable[s] < maxdist2) {
|
||||||
j = dlightdivtable[(sdtable[s] + td) >> 7];
|
j = dlightdivtable[(sdtable[s] + td) >> 7];
|
||||||
k = (red * j) >> 7;
|
bl[0] += (k = (red * j) >> 7);
|
||||||
bl[0] += k;
|
bl[1] += (k = (green * j) >> 7);
|
||||||
k = (green * j) >> 7;
|
bl[2] += (k = (blue * j) >> 7);
|
||||||
bl[1] += k;
|
|
||||||
k = (blue * j) >> 7;
|
|
||||||
bl[2] += k;
|
|
||||||
}
|
}
|
||||||
bl += 3;
|
bl += 3;
|
||||||
}
|
}
|
||||||
|
@ -882,8 +864,8 @@ R_RecursiveWorldNode (mnode_t *node)
|
||||||
mleaf_t *pleaf;
|
mleaf_t *pleaf;
|
||||||
double dot;
|
double dot;
|
||||||
|
|
||||||
if (node->contents == CONTENTS_SOLID)
|
if (node->contents == CONTENTS_SOLID) // solid
|
||||||
return; // solid
|
return;
|
||||||
|
|
||||||
if (node->visframe != r_visframecount)
|
if (node->visframe != r_visframecount)
|
||||||
return;
|
return;
|
||||||
|
@ -1144,13 +1126,8 @@ BuildSurfaceDisplayList (msurface_t *fa)
|
||||||
lnumverts = fa->numedges;
|
lnumverts = fa->numedges;
|
||||||
vertpage = 0;
|
vertpage = 0;
|
||||||
|
|
||||||
//
|
|
||||||
// draw texture
|
// draw texture
|
||||||
//
|
poly = Hunk_Alloc (sizeof (glpoly_t) + (lnumverts - 4) * VERTEXSIZE * sizeof (float));
|
||||||
poly =
|
|
||||||
|
|
||||||
Hunk_Alloc (sizeof (glpoly_t) +
|
|
||||||
(lnumverts - 4) * VERTEXSIZE * sizeof (float));
|
|
||||||
poly->next = fa->polys;
|
poly->next = fa->polys;
|
||||||
poly->flags = fa->flags;
|
poly->flags = fa->flags;
|
||||||
fa->polys = poly;
|
fa->polys = poly;
|
||||||
|
@ -1176,9 +1153,7 @@ BuildSurfaceDisplayList (msurface_t *fa)
|
||||||
poly->verts[i][3] = s;
|
poly->verts[i][3] = s;
|
||||||
poly->verts[i][4] = t;
|
poly->verts[i][4] = t;
|
||||||
|
|
||||||
//
|
|
||||||
// lightmap texture coordinates
|
// lightmap texture coordinates
|
||||||
//
|
|
||||||
s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
|
s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
|
||||||
s -= fa->texturemins[0];
|
s -= fa->texturemins[0];
|
||||||
s += fa->light_s * 16;
|
s += fa->light_s * 16;
|
||||||
|
@ -1195,9 +1170,7 @@ BuildSurfaceDisplayList (msurface_t *fa)
|
||||||
poly->verts[i][6] = t;
|
poly->verts[i][6] = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// remove co-linear points - Ed
|
// remove co-linear points - Ed
|
||||||
//
|
|
||||||
if (!gl_keeptjunctions->int_val && !(fa->flags & SURF_UNDERWATER)) {
|
if (!gl_keeptjunctions->int_val && !(fa->flags & SURF_UNDERWATER)) {
|
||||||
for (i = 0; i < lnumverts; ++i) {
|
for (i = 0; i < lnumverts; ++i) {
|
||||||
vec3_t v1, v2;
|
vec3_t v1, v2;
|
||||||
|
@ -1253,11 +1226,8 @@ GL_CreateSurfaceLightmap (msurface_t *surf)
|
||||||
smax = (surf->extents[0] >> 4) + 1;
|
smax = (surf->extents[0] >> 4) + 1;
|
||||||
tmax = (surf->extents[1] >> 4) + 1;
|
tmax = (surf->extents[1] >> 4) + 1;
|
||||||
|
|
||||||
surf->lightmaptexturenum =
|
surf->lightmaptexturenum = AllocBlock (smax, tmax, &surf->light_s, &surf->light_t);
|
||||||
AllocBlock (smax, tmax, &surf->light_s, &surf->light_t);
|
base = lightmaps[surf->lightmaptexturenum] + (surf->light_t * BLOCK_WIDTH + surf->light_s) * lightmap_bytes;
|
||||||
base =
|
|
||||||
lightmaps[surf->lightmaptexturenum] + (surf->light_t * BLOCK_WIDTH +
|
|
||||||
surf->light_s) * lightmap_bytes;
|
|
||||||
R_BuildLightMap (surf, base, BLOCK_WIDTH * lightmap_bytes);
|
R_BuildLightMap (surf, base, BLOCK_WIDTH * lightmap_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue