mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[renderer] Be more consistent with msurface_t names
Use "surf" everywhere in gl, glsl and vulkan. Not worried about sw/sw32 at this stage (I don't poke around in there anywhere near as much).
This commit is contained in:
parent
3c93d555e3
commit
87dc35e2fd
7 changed files with 136 additions and 133 deletions
|
@ -545,7 +545,7 @@ gl_overbright_f (cvar_t *var)
|
|||
{
|
||||
int num, i, j;
|
||||
model_t *m;
|
||||
msurface_t *fa;
|
||||
msurface_t *surf;
|
||||
entity_t *ent;
|
||||
mod_brush_t *brush;
|
||||
|
||||
|
@ -602,35 +602,36 @@ gl_overbright_f (cvar_t *var)
|
|||
continue;
|
||||
|
||||
brush = &m->brush;
|
||||
for (j = 0, fa = brush->surfaces; j < brush->numsurfaces; j++, fa++) {
|
||||
if (fa->flags & (SURF_DRAWTURB | SURF_DRAWSKY))
|
||||
for (j = 0, surf = brush->surfaces; j < brush->numsurfaces;
|
||||
j++, surf++) {
|
||||
if (surf->flags & (SURF_DRAWTURB | SURF_DRAWSKY))
|
||||
continue;
|
||||
|
||||
num = fa->lightmaptexturenum;
|
||||
num = surf->lightmaptexturenum;
|
||||
gl_lightmap_modified[num] = true;
|
||||
gl_lightmap_rectchange[num].l = 0;
|
||||
gl_lightmap_rectchange[num].t = 0;
|
||||
gl_lightmap_rectchange[num].w = BLOCK_WIDTH;
|
||||
gl_lightmap_rectchange[num].h = BLOCK_HEIGHT;
|
||||
|
||||
gl_R_BuildLightMap (brush, fa);
|
||||
gl_R_BuildLightMap (brush, surf);
|
||||
}
|
||||
}
|
||||
|
||||
brush = &r_worldentity.renderer.model->brush;
|
||||
|
||||
for (i = 0, fa = brush->surfaces; i < brush->numsurfaces; i++, fa++) {
|
||||
if (fa->flags & (SURF_DRAWTURB | SURF_DRAWSKY))
|
||||
for (i = 0, surf = brush->surfaces; i < brush->numsurfaces; i++, surf++) {
|
||||
if (surf->flags & (SURF_DRAWTURB | SURF_DRAWSKY))
|
||||
continue;
|
||||
|
||||
num = fa->lightmaptexturenum;
|
||||
num = surf->lightmaptexturenum;
|
||||
gl_lightmap_modified[num] = true;
|
||||
gl_lightmap_rectchange[num].l = 0;
|
||||
gl_lightmap_rectchange[num].t = 0;
|
||||
gl_lightmap_rectchange[num].w = BLOCK_WIDTH;
|
||||
gl_lightmap_rectchange[num].h = BLOCK_HEIGHT;
|
||||
|
||||
gl_R_BuildLightMap (brush, fa);
|
||||
gl_R_BuildLightMap (brush, surf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -481,7 +481,7 @@ static void
|
|||
R_Mirror (void)
|
||||
{
|
||||
//float d;
|
||||
// msurface_t *s;
|
||||
// msurface_t *surf;
|
||||
|
||||
// if (!gl_mirror) // FIXME: Broken
|
||||
return;
|
||||
|
@ -528,25 +528,25 @@ R_Mirror (void)
|
|||
color_white[3] = r_mirroralpha->value * 255;
|
||||
qfglColor4ubv (color_white);
|
||||
#if 0//FIXME
|
||||
s = r_worldentity.model->textures[gl_mirrortexturenum]->texturechain;
|
||||
for (; s; s = s->texturechain) {
|
||||
surf = r_worldentity.model->textures[gl_mirrortexturenum]->texturechain;
|
||||
for (; surf; surf = surf->texturechain) {
|
||||
texture_t *tex;
|
||||
|
||||
if (!s->texinfo->texture->anim_total)
|
||||
tex = s->texinfo->texture;
|
||||
if (!surf->texinfo->texture->anim_total)
|
||||
tex = surf->texinfo->texture;
|
||||
else
|
||||
tex = R_TextureAnimation (s);
|
||||
tex = R_TextureAnimation (surf);
|
||||
|
||||
// FIXME: Needs to set the texture, the tmu, and include the header, and then
|
||||
// clean up afterwards.
|
||||
// if (tex->gl_fb_texturenum && gl_mtex_fullbright
|
||||
// && gl_fb_models->int_val) {
|
||||
// s->polys->fb_chain = fullbright_polys[tex->gl_fb_texturenum];
|
||||
// fullbright_polys[tex->gl_fb_texturenum] = s->polys;
|
||||
// surf->polys->fb_chain = fullbright_polys[tex->gl_fb_texturenum];
|
||||
// fullbright_polys[tex->gl_fb_texturenum] = surf->polys;
|
||||
// }
|
||||
|
||||
qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum);
|
||||
// R_RenderBrushPoly (s, tex); // FIXME: Need to move R_Mirror to gl_rsurf.c, and uncommment this line!
|
||||
// R_RenderBrushPoly (surf, tex); // FIXME: Need to move R_Mirror to gl_rsurf.c, and uncommment this line!
|
||||
}
|
||||
r_worldentity.model->textures[gl_mirrortexturenum]->texturechain = NULL;
|
||||
#endif
|
||||
|
|
|
@ -210,7 +210,7 @@ R_RenderFullbrights (void)
|
|||
}
|
||||
|
||||
static inline void
|
||||
R_RenderBrushPoly_3 (msurface_t *fa)
|
||||
R_RenderBrushPoly_3 (msurface_t *surf)
|
||||
{
|
||||
float *v;
|
||||
int i;
|
||||
|
@ -218,9 +218,9 @@ R_RenderBrushPoly_3 (msurface_t *fa)
|
|||
gl_c_brush_polys++;
|
||||
|
||||
qfglBegin (GL_POLYGON);
|
||||
v = fa->polys->verts[0];
|
||||
v = surf->polys->verts[0];
|
||||
|
||||
for (i = 0; i < fa->polys->numverts; i++, v += VERTEXSIZE) {
|
||||
for (i = 0; i < surf->polys->numverts; i++, v += VERTEXSIZE) {
|
||||
qglMultiTexCoord2fv (gl_mtex_enum + 0, &v[3]);
|
||||
qglMultiTexCoord2fv (gl_mtex_enum + 1, &v[5]);
|
||||
qglMultiTexCoord2fv (gl_mtex_enum + 2, &v[3]);
|
||||
|
@ -231,7 +231,7 @@ R_RenderBrushPoly_3 (msurface_t *fa)
|
|||
}
|
||||
|
||||
static inline void
|
||||
R_RenderBrushPoly_2 (msurface_t *fa)
|
||||
R_RenderBrushPoly_2 (msurface_t *surf)
|
||||
{
|
||||
float *v;
|
||||
int i;
|
||||
|
@ -239,9 +239,9 @@ R_RenderBrushPoly_2 (msurface_t *fa)
|
|||
gl_c_brush_polys++;
|
||||
|
||||
qfglBegin (GL_POLYGON);
|
||||
v = fa->polys->verts[0];
|
||||
v = surf->polys->verts[0];
|
||||
|
||||
for (i = 0; i < fa->polys->numverts; i++, v += VERTEXSIZE) {
|
||||
for (i = 0; i < surf->polys->numverts; i++, v += VERTEXSIZE) {
|
||||
qglMultiTexCoord2fv (gl_mtex_enum + 0, &v[3]);
|
||||
qglMultiTexCoord2fv (gl_mtex_enum + 1, &v[5]);
|
||||
qfglVertex3fv (v);
|
||||
|
@ -251,7 +251,7 @@ R_RenderBrushPoly_2 (msurface_t *fa)
|
|||
}
|
||||
|
||||
static inline void
|
||||
R_RenderBrushPoly_1 (msurface_t *fa)
|
||||
R_RenderBrushPoly_1 (msurface_t *surf)
|
||||
{
|
||||
float *v;
|
||||
int i;
|
||||
|
@ -259,9 +259,9 @@ R_RenderBrushPoly_1 (msurface_t *fa)
|
|||
gl_c_brush_polys++;
|
||||
|
||||
qfglBegin (GL_POLYGON);
|
||||
v = fa->polys->verts[0];
|
||||
v = surf->polys->verts[0];
|
||||
|
||||
for (i = 0; i < fa->polys->numverts; i++, v += VERTEXSIZE) {
|
||||
for (i = 0; i < surf->polys->numverts; i++, v += VERTEXSIZE) {
|
||||
qfglTexCoord2fv (&v[3]);
|
||||
qfglVertex3fv (v);
|
||||
}
|
||||
|
@ -270,42 +270,42 @@ R_RenderBrushPoly_1 (msurface_t *fa)
|
|||
}
|
||||
|
||||
static inline void
|
||||
R_AddToLightmapChain (mod_brush_t *brush, msurface_t *fa, instsurf_t *sc)
|
||||
R_AddToLightmapChain (mod_brush_t *brush, msurface_t *surf, instsurf_t *sc)
|
||||
{
|
||||
int maps, smax, tmax;
|
||||
glRect_t *theRect;
|
||||
|
||||
// add the poly to the proper lightmap chain
|
||||
sc->lm_chain = gl_lightmap_polys[fa->lightmaptexturenum];
|
||||
gl_lightmap_polys[fa->lightmaptexturenum] = sc;
|
||||
sc->lm_chain = gl_lightmap_polys[surf->lightmaptexturenum];
|
||||
gl_lightmap_polys[surf->lightmaptexturenum] = sc;
|
||||
|
||||
// check for lightmap modification
|
||||
for (maps = 0; maps < MAXLIGHTMAPS && fa->styles[maps] != 255; maps++)
|
||||
if (d_lightstylevalue[fa->styles[maps]] != fa->cached_light[maps])
|
||||
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++)
|
||||
if (d_lightstylevalue[surf->styles[maps]] != surf->cached_light[maps])
|
||||
goto dynamic;
|
||||
|
||||
if ((fa->dlightframe == r_framecount) || fa->cached_dlight) {
|
||||
if ((surf->dlightframe == r_framecount) || surf->cached_dlight) {
|
||||
dynamic:
|
||||
if (r_dynamic->int_val) {
|
||||
gl_lightmap_modified[fa->lightmaptexturenum] = true;
|
||||
theRect = &gl_lightmap_rectchange[fa->lightmaptexturenum];
|
||||
if (fa->light_t < theRect->t) {
|
||||
gl_lightmap_modified[surf->lightmaptexturenum] = true;
|
||||
theRect = &gl_lightmap_rectchange[surf->lightmaptexturenum];
|
||||
if (surf->light_t < theRect->t) {
|
||||
if (theRect->h)
|
||||
theRect->h += theRect->t - fa->light_t;
|
||||
theRect->t = fa->light_t;
|
||||
theRect->h += theRect->t - surf->light_t;
|
||||
theRect->t = surf->light_t;
|
||||
}
|
||||
if (fa->light_s < theRect->l) {
|
||||
if (surf->light_s < theRect->l) {
|
||||
if (theRect->w)
|
||||
theRect->w += theRect->l - fa->light_s;
|
||||
theRect->l = fa->light_s;
|
||||
theRect->w += theRect->l - surf->light_s;
|
||||
theRect->l = surf->light_s;
|
||||
}
|
||||
smax = (fa->extents[0] >> 4) + 1;
|
||||
tmax = (fa->extents[1] >> 4) + 1;
|
||||
if ((theRect->w + theRect->l) < (fa->light_s + smax))
|
||||
theRect->w = (fa->light_s - theRect->l) + smax;
|
||||
if ((theRect->h + theRect->t) < (fa->light_t + tmax))
|
||||
theRect->h = (fa->light_t - theRect->t) + tmax;
|
||||
gl_R_BuildLightMap (brush, fa);
|
||||
smax = (surf->extents[0] >> 4) + 1;
|
||||
tmax = (surf->extents[1] >> 4) + 1;
|
||||
if ((theRect->w + theRect->l) < (surf->light_s + smax))
|
||||
theRect->w = (surf->light_s - theRect->l) + smax;
|
||||
if ((theRect->h + theRect->t) < (surf->light_t + tmax))
|
||||
theRect->h = (surf->light_t - theRect->t) + tmax;
|
||||
gl_R_BuildLightMap (brush, surf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ gl_R_DrawWaterSurfaces (void)
|
|||
{
|
||||
int i;
|
||||
instsurf_t *s;
|
||||
msurface_t *fa;
|
||||
msurface_t *surf;
|
||||
float wateralpha = max (vr_data.min_wateralpha, r_wateralpha->value);
|
||||
|
||||
if (!waterchain)
|
||||
|
@ -333,17 +333,17 @@ gl_R_DrawWaterSurfaces (void)
|
|||
i = -1;
|
||||
for (s = waterchain; s; s = s->tex_chain) {
|
||||
gltex_t *tex;
|
||||
fa = s->surface;
|
||||
surf = s->surface;
|
||||
if (s->transform)
|
||||
qfglLoadMatrixf (s->transform);
|
||||
else
|
||||
qfglLoadMatrixf (gl_r_world_matrix);
|
||||
tex = fa->texinfo->texture->render;
|
||||
tex = surf->texinfo->texture->render;
|
||||
if (i != tex->gl_texturenum) {
|
||||
i = tex->gl_texturenum;
|
||||
qfglBindTexture (GL_TEXTURE_2D, i);
|
||||
}
|
||||
GL_EmitWaterPolys (fa);
|
||||
GL_EmitWaterPolys (surf);
|
||||
}
|
||||
qfglLoadMatrixf (gl_r_world_matrix);
|
||||
|
||||
|
@ -361,7 +361,7 @@ DrawTextureChains (int disable_blend, int do_bind)
|
|||
{
|
||||
int i;
|
||||
instsurf_t *s;
|
||||
msurface_t *fa;
|
||||
msurface_t *surf;
|
||||
gltex_t *tex;
|
||||
|
||||
if (gl_mtex_active_tmus >= 2) {
|
||||
|
@ -386,7 +386,7 @@ DrawTextureChains (int disable_blend, int do_bind)
|
|||
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
for (s = tex->tex_chain; s; s = s->tex_chain) {
|
||||
fa = s->surface;
|
||||
surf = s->surface;
|
||||
if (s->transform) {
|
||||
qfglPushMatrix ();
|
||||
qfglLoadMatrixf (s->transform);
|
||||
|
@ -394,9 +394,9 @@ DrawTextureChains (int disable_blend, int do_bind)
|
|||
if (s->color && do_bind)
|
||||
qfglColor4fv (s->color);
|
||||
qfglBindTexture (GL_TEXTURE_2D, gl_lightmap_textures +
|
||||
fa->lightmaptexturenum);
|
||||
surf->lightmaptexturenum);
|
||||
|
||||
R_RenderBrushPoly_3 (fa);
|
||||
R_RenderBrushPoly_3 (surf);
|
||||
|
||||
if (s->transform)
|
||||
qfglPopMatrix ();
|
||||
|
@ -411,9 +411,9 @@ DrawTextureChains (int disable_blend, int do_bind)
|
|||
} else {
|
||||
qglActiveTexture (gl_mtex_enum + 1);
|
||||
for (s = tex->tex_chain; s; s = s->tex_chain) {
|
||||
fa = s->surface;
|
||||
surf = s->surface;
|
||||
qfglBindTexture (GL_TEXTURE_2D, gl_lightmap_textures +
|
||||
fa->lightmaptexturenum);
|
||||
surf->lightmaptexturenum);
|
||||
|
||||
if (s->transform) {
|
||||
qfglPushMatrix ();
|
||||
|
@ -421,7 +421,7 @@ DrawTextureChains (int disable_blend, int do_bind)
|
|||
}
|
||||
if (s->color && do_bind)
|
||||
qfglColor4fv (s->color);
|
||||
R_RenderBrushPoly_2 (fa);
|
||||
R_RenderBrushPoly_2 (surf);
|
||||
|
||||
if (s->transform)
|
||||
qfglPopMatrix ();
|
||||
|
@ -522,8 +522,7 @@ gl_R_DrawBrushModel (entity_t *e)
|
|||
int i;
|
||||
unsigned int k;
|
||||
model_t *model;
|
||||
plane_t *pplane;
|
||||
msurface_t *psurf;
|
||||
msurface_t *surf;
|
||||
qboolean rotated;
|
||||
vec3_t mins, maxs;
|
||||
mod_brush_t *brush;
|
||||
|
@ -587,19 +586,19 @@ gl_R_DrawBrushModel (entity_t *e)
|
|||
qfglGetFloatv (GL_MODELVIEW_MATRIX, e->renderer.full_transform);
|
||||
qfglPopMatrix ();
|
||||
|
||||
psurf = &brush->surfaces[brush->firstmodelsurface];
|
||||
surf = &brush->surfaces[brush->firstmodelsurface];
|
||||
|
||||
// draw texture
|
||||
for (i = 0; i < brush->nummodelsurfaces; i++, psurf++) {
|
||||
for (i = 0; i < brush->nummodelsurfaces; i++, surf++) {
|
||||
// find which side of the node we are on
|
||||
pplane = psurf->plane;
|
||||
plane_t *plane = surf->plane;
|
||||
|
||||
dot = DotProduct (modelorg, pplane->normal) - pplane->dist;
|
||||
dot = DotProduct (modelorg, plane->normal) - plane->dist;
|
||||
|
||||
// draw the polygon
|
||||
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
|
||||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
|
||||
chain_surface (brush, psurf, e->renderer.full_transform,
|
||||
if (((surf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
|
||||
(!(surf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
|
||||
chain_surface (brush, surf, e->renderer.full_transform,
|
||||
e->renderer.colormod);
|
||||
}
|
||||
}
|
||||
|
@ -817,7 +816,7 @@ gl_R_DrawWorld (void)
|
|||
model_t *gl_currentmodel;
|
||||
|
||||
void
|
||||
GL_BuildSurfaceDisplayList (msurface_t *fa)
|
||||
GL_BuildSurfaceDisplayList (msurface_t *surf)
|
||||
{
|
||||
float s, t;
|
||||
float *vec;
|
||||
|
@ -827,18 +826,19 @@ GL_BuildSurfaceDisplayList (msurface_t *fa)
|
|||
|
||||
// reconstruct the polygon
|
||||
pedges = gl_currentmodel->brush.edges;
|
||||
lnumverts = fa->numedges;
|
||||
lnumverts = surf->numedges;
|
||||
|
||||
// draw texture
|
||||
poly = Hunk_Alloc (sizeof (glpoly_t) + (lnumverts - 4) *
|
||||
VERTEXSIZE * sizeof (float));
|
||||
poly->next = fa->polys;
|
||||
poly->flags = fa->flags;
|
||||
fa->polys = poly;
|
||||
poly->next = surf->polys;
|
||||
poly->flags = surf->flags;
|
||||
surf->polys = poly;
|
||||
poly->numverts = lnumverts;
|
||||
|
||||
mtexinfo_t *texinfo = surf->texinfo;
|
||||
for (i = 0; i < lnumverts; i++) {
|
||||
lindex = gl_currentmodel->brush.surfedges[fa->firstedge + i];
|
||||
lindex = gl_currentmodel->brush.surfedges[surf->firstedge + i];
|
||||
|
||||
if (lindex > 0) {
|
||||
r_pedge = &pedges[lindex];
|
||||
|
@ -847,35 +847,35 @@ GL_BuildSurfaceDisplayList (msurface_t *fa)
|
|||
r_pedge = &pedges[-lindex];
|
||||
vec = r_pcurrentvertbase[r_pedge->v[1]].position;
|
||||
}
|
||||
s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
|
||||
s /= fa->texinfo->texture->width;
|
||||
s = DotProduct (vec, texinfo->vecs[0]) + texinfo->vecs[0][3];
|
||||
s /= texinfo->texture->width;
|
||||
|
||||
t = DotProduct (vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3];
|
||||
t /= fa->texinfo->texture->height;
|
||||
t = DotProduct (vec, texinfo->vecs[1]) + texinfo->vecs[1][3];
|
||||
t /= texinfo->texture->height;
|
||||
|
||||
VectorCopy (vec, poly->verts[i]);
|
||||
poly->verts[i][3] = s;
|
||||
poly->verts[i][4] = t;
|
||||
|
||||
// lightmap texture coordinates
|
||||
s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
|
||||
s -= fa->texturemins[0];
|
||||
s += fa->light_s * 16;
|
||||
s = DotProduct (vec, texinfo->vecs[0]) + texinfo->vecs[0][3];
|
||||
s -= surf->texturemins[0];
|
||||
s += surf->light_s * 16;
|
||||
s += 8;
|
||||
s /= BLOCK_WIDTH * 16; // fa->texinfo->texture->width;
|
||||
s /= BLOCK_WIDTH * 16;
|
||||
|
||||
t = DotProduct (vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3];
|
||||
t -= fa->texturemins[1];
|
||||
t += fa->light_t * 16;
|
||||
t = DotProduct (vec, texinfo->vecs[1]) + texinfo->vecs[1][3];
|
||||
t -= surf->texturemins[1];
|
||||
t += surf->light_t * 16;
|
||||
t += 8;
|
||||
t /= BLOCK_HEIGHT * 16; // fa->texinfo->texture->height;
|
||||
t /= BLOCK_HEIGHT * 16;
|
||||
|
||||
poly->verts[i][5] = s;
|
||||
poly->verts[i][6] = t;
|
||||
}
|
||||
|
||||
// remove co-linear points - Ed
|
||||
if (!gl_keeptjunctions->int_val && !(fa->flags & SURF_UNDERWATER)) {
|
||||
if (!gl_keeptjunctions->int_val && !(surf->flags & SURF_UNDERWATER)) {
|
||||
for (i = 0; i < lnumverts; ++i) {
|
||||
vec3_t v1, v2;
|
||||
float *prev, *this, *next;
|
||||
|
|
|
@ -644,10 +644,10 @@ EmitSkyPolys (float speedscale, const instsurf_t *sc)
|
|||
int i;
|
||||
glpoly_t *p;
|
||||
vec3_t dir;
|
||||
msurface_t *fa = sc->surface;
|
||||
msurface_t *surf = sc->surface;
|
||||
|
||||
//FIXME transform/color
|
||||
for (p = fa->polys; p; p = p->next) {
|
||||
for (p = surf->polys; p; p = p->next) {
|
||||
qfglBegin (GL_POLYGON);
|
||||
for (i = 0, v = p->verts[0]; i < p->numverts; i++, v += VERTEXSIZE) {
|
||||
VectorSubtract (v, r_origin, dir);
|
||||
|
|
|
@ -54,7 +54,7 @@ static float turbsin[] = {
|
|||
Does a water warp on the pre-fragmented glpoly_t chain
|
||||
*/
|
||||
void
|
||||
GL_EmitWaterPolys (msurface_t *fa)
|
||||
GL_EmitWaterPolys (msurface_t *surf)
|
||||
{
|
||||
float os, ot, s, t, timetemp;
|
||||
float *v;
|
||||
|
@ -63,7 +63,7 @@ GL_EmitWaterPolys (msurface_t *fa)
|
|||
|
||||
timetemp = vr_data.realtime * TURBSCALE;
|
||||
|
||||
for (p = fa->polys; p; p = p->next) {
|
||||
for (p = surf->polys; p; p = p->next) {
|
||||
qfglBegin (GL_POLYGON);
|
||||
for (i = 0, v = p->verts[0]; i < p->numverts; i++, v += VERTEXSIZE) {
|
||||
os = turbsin[(int) (v[3] * TURBFRAC + timetemp) & 255];
|
||||
|
|
|
@ -465,7 +465,7 @@ add_elechain (glsltex_t *tex, int model_index)
|
|||
}
|
||||
|
||||
static void
|
||||
build_surf_displist (model_t **models, msurface_t *fa, int base,
|
||||
build_surf_displist (model_t **models, msurface_t *surf, int base,
|
||||
dstring_t *vert_list)
|
||||
{
|
||||
int numverts;
|
||||
|
@ -483,8 +483,8 @@ build_surf_displist (model_t **models, msurface_t *fa, int base,
|
|||
float s, t;
|
||||
mod_brush_t *brush;
|
||||
|
||||
if (fa->model_index < 0) {
|
||||
brush = &models[-fa->model_index - 1]->brush;
|
||||
if (surf->model_index < 0) {
|
||||
brush = &models[-surf->model_index - 1]->brush;
|
||||
} else {
|
||||
brush = &r_worldentity.renderer.model->brush;
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ build_surf_displist (model_t **models, msurface_t *fa, int base,
|
|||
edges = brush->edges;
|
||||
surfedges = brush->surfedges;
|
||||
|
||||
numverts = fa->numedges;
|
||||
numverts = surf->numedges;
|
||||
numtris = numverts - 2;
|
||||
numindices = numtris * 3;
|
||||
verts = alloca (numverts * sizeof (bspvert_t));
|
||||
|
@ -503,39 +503,40 @@ build_surf_displist (model_t **models, msurface_t *fa, int base,
|
|||
*ind++ = base + i + 1;
|
||||
*ind++ = base + i + 2;
|
||||
}
|
||||
fa->polys = (glpoly_t *) poly;
|
||||
surf->polys = (glpoly_t *) poly;
|
||||
|
||||
mtexinfo_t *texinfo = surf->texinfo;
|
||||
for (i = 0; i < numverts; i++) {
|
||||
index = surfedges[fa->firstedge + i];
|
||||
index = surfedges[surf->firstedge + i];
|
||||
if (index > 0)
|
||||
vec = vertices[edges[index].v[0]].position;
|
||||
else
|
||||
vec = vertices[edges[-index].v[1]].position;
|
||||
|
||||
s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
|
||||
t = DotProduct (vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3];
|
||||
s = DotProduct (vec, texinfo->vecs[0]) + texinfo->vecs[0][3];
|
||||
t = DotProduct (vec, texinfo->vecs[1]) + texinfo->vecs[1][3];
|
||||
VectorCopy (vec, verts[i].vertex);
|
||||
verts[i].vertex[3] = 1;
|
||||
verts[i].tlst[0] = s / fa->texinfo->texture->width;
|
||||
verts[i].tlst[1] = t / fa->texinfo->texture->height;
|
||||
verts[i].tlst[0] = s / texinfo->texture->width;
|
||||
verts[i].tlst[1] = t / texinfo->texture->height;
|
||||
|
||||
//lightmap texture coordinates
|
||||
if (!fa->lightpic) {
|
||||
if (!surf->lightpic) {
|
||||
// sky and water textures don't have lightmaps
|
||||
verts[i].tlst[2] = 0;
|
||||
verts[i].tlst[3] = 0;
|
||||
continue;
|
||||
}
|
||||
s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
|
||||
t = DotProduct (vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3];
|
||||
s -= fa->texturemins[0];
|
||||
t -= fa->texturemins[1];
|
||||
s += fa->lightpic->rect->x * 16 + 8;
|
||||
t += fa->lightpic->rect->y * 16 + 8;
|
||||
s = DotProduct (vec, texinfo->vecs[0]) + texinfo->vecs[0][3];
|
||||
t = DotProduct (vec, texinfo->vecs[1]) + texinfo->vecs[1][3];
|
||||
s -= surf->texturemins[0];
|
||||
t -= surf->texturemins[1];
|
||||
s += surf->lightpic->rect->x * 16 + 8;
|
||||
t += surf->lightpic->rect->y * 16 + 8;
|
||||
s /= 16;
|
||||
t /= 16;
|
||||
verts[i].tlst[2] = s * fa->lightpic->size;
|
||||
verts[i].tlst[3] = t * fa->lightpic->size;
|
||||
verts[i].tlst[2] = s * surf->lightpic->size;
|
||||
verts[i].tlst[3] = t * surf->lightpic->size;
|
||||
}
|
||||
dstring_append (vert_list, (char *) verts, numverts * sizeof (bspvert_t));
|
||||
}
|
||||
|
|
|
@ -320,15 +320,15 @@ add_elechain (vulktex_t *tex, int model_index, bspctx_t *bctx)
|
|||
}
|
||||
|
||||
static void
|
||||
count_verts_inds (model_t **models, msurface_t *fa,
|
||||
count_verts_inds (model_t **models, msurface_t *surf,
|
||||
uint32_t *verts, uint32_t *inds)
|
||||
{
|
||||
*verts = fa->numedges;
|
||||
*inds = fa->numedges + 1;
|
||||
*verts = surf->numedges;
|
||||
*inds = surf->numedges + 1;
|
||||
}
|
||||
|
||||
static bsppoly_t *
|
||||
build_surf_displist (model_t **models, msurface_t *fa, int base,
|
||||
build_surf_displist (model_t **models, msurface_t *surf, int base,
|
||||
bspvert_t **vert_list)
|
||||
{
|
||||
int numverts;
|
||||
|
@ -345,9 +345,9 @@ build_surf_displist (model_t **models, msurface_t *fa, int base,
|
|||
float s, t;
|
||||
mod_brush_t *brush;
|
||||
|
||||
if (fa->model_index < 0) {
|
||||
if (surf->model_index < 0) {
|
||||
// instance model
|
||||
brush = &models[~fa->model_index]->brush;
|
||||
brush = &models[~surf->model_index]->brush;
|
||||
} else {
|
||||
// main or sub model
|
||||
brush = &r_worldentity.renderer.model->brush;
|
||||
|
@ -356,50 +356,51 @@ build_surf_displist (model_t **models, msurface_t *fa, int base,
|
|||
edges = brush->edges;
|
||||
surfedges = brush->surfedges;
|
||||
// create a triangle fan
|
||||
numverts = fa->numedges;
|
||||
numverts = surf->numedges;
|
||||
numindices = numverts + 1;
|
||||
verts = *vert_list;
|
||||
// surf->polys is set to the next slot before the call
|
||||
poly = (bsppoly_t *) fa->polys;
|
||||
poly = (bsppoly_t *) surf->polys;
|
||||
poly->count = numindices;
|
||||
for (i = 0, ind = poly->indices; i < numverts; i++) {
|
||||
*ind++ = base + i;
|
||||
}
|
||||
*ind++ = -1; // end of primitive
|
||||
fa->polys = (glpoly_t *) poly;
|
||||
surf->polys = (glpoly_t *) poly;
|
||||
|
||||
mtexinfo_t *texinfo = surf->texinfo;
|
||||
for (i = 0; i < numverts; i++) {
|
||||
index = surfedges[fa->firstedge + i];
|
||||
index = surfedges[surf->firstedge + i];
|
||||
if (index > 0) {
|
||||
vec = vertices[edges[index].v[0]].position;
|
||||
} else {
|
||||
vec = vertices[edges[-index].v[1]].position;
|
||||
}
|
||||
|
||||
s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
|
||||
t = DotProduct (vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3];
|
||||
s = DotProduct (vec, texinfo->vecs[0]) + texinfo->vecs[0][3];
|
||||
t = DotProduct (vec, texinfo->vecs[1]) + texinfo->vecs[1][3];
|
||||
VectorCopy (vec, verts[i].vertex);
|
||||
verts[i].vertex[3] = 1;
|
||||
verts[i].tlst[0] = s / fa->texinfo->texture->width;
|
||||
verts[i].tlst[1] = t / fa->texinfo->texture->height;
|
||||
verts[i].tlst[0] = s / texinfo->texture->width;
|
||||
verts[i].tlst[1] = t / texinfo->texture->height;
|
||||
|
||||
//lightmap texture coordinates
|
||||
if (!fa->lightpic) {
|
||||
if (!surf->lightpic) {
|
||||
// sky and water textures don't have lightmaps
|
||||
verts[i].tlst[2] = 0;
|
||||
verts[i].tlst[3] = 0;
|
||||
continue;
|
||||
}
|
||||
s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
|
||||
t = DotProduct (vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3];
|
||||
s -= fa->texturemins[0];
|
||||
t -= fa->texturemins[1];
|
||||
s += fa->lightpic->rect->x * 16 + 8;
|
||||
t += fa->lightpic->rect->y * 16 + 8;
|
||||
s = DotProduct (vec, texinfo->vecs[0]) + texinfo->vecs[0][3];
|
||||
t = DotProduct (vec, texinfo->vecs[1]) + texinfo->vecs[1][3];
|
||||
s -= surf->texturemins[0];
|
||||
t -= surf->texturemins[1];
|
||||
s += surf->lightpic->rect->x * 16 + 8;
|
||||
t += surf->lightpic->rect->y * 16 + 8;
|
||||
s /= 16;
|
||||
t /= 16;
|
||||
verts[i].tlst[2] = s * fa->lightpic->size;
|
||||
verts[i].tlst[3] = t * fa->lightpic->size;
|
||||
verts[i].tlst[2] = s * surf->lightpic->size;
|
||||
verts[i].tlst[3] = t * surf->lightpic->size;
|
||||
}
|
||||
*vert_list += numverts;
|
||||
return (bsppoly_t *) &poly->indices[numindices];
|
||||
|
|
Loading…
Reference in a new issue