ref: 5ffec98ac5535fce363a48640ff3f1c1e7f42f5a
parent: 48d333cfbbf7349058787093c08d9c52b8df1aeb
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Oct 31 08:12:13 EDT 2023
.alpha: part 4 - draw water-like surfaces in non-VISed maps when r_*alpha is set to 1
--- a/d_edge.c
+++ b/d_edge.c
@@ -185,7 +185,7 @@
if (!s->spans)
continue;
- if((surfdrawflags(s) | entdrawflags(s->entity)) ^ r_drawflags)
+ if((surfdrawflags(s->flags) | entdrawflags(s->entity)) ^ r_drawflags)
continue;
alpha = 255;
if(enthasalpha(s->entity) && s->entity->alpha != 255)
--- a/d_scan.c
+++ b/d_scan.c
@@ -79,7 +79,7 @@
{
sturb = ((r_turb_s + r_turb_turb[(r_turb_t>>16)&(CYCLE-1)])>>16)&63;
tturb = ((r_turb_t + r_turb_turb[(r_turb_s>>16)&(CYCLE-1)])>>16)&63;
- if (*r_turb_z <= (izi >> 16))
+ if (*r_turb_z <= (izi >> 16) || (r_drawflags & DRAW_BLEND) == 0)
*r_turb_pdest = blendalpha(*(r_turb_pbase + (tturb<<6) + sturb), *r_turb_pdest, alpha);
r_turb_s += r_turb_sstep;
r_turb_t += r_turb_tstep;
--- a/model.c
+++ b/model.c
@@ -1174,7 +1174,7 @@
mod->nummodelsurfaces = bm->numfaces;
mod->blend = false;
for(j = bm->firstface; j < bm->firstface+bm->numfaces; j++){
- if(surfdrawflags(&loadmodel->surfaces[j]) & DRAW_BLEND){
+ if(loadmodel->surfaces[j].flags & SURF_TRANS){
mod->blend = true;
break;
}
--- a/r_alias.c
+++ b/r_alias.c
@@ -397,11 +397,11 @@
int temp;
float lightcos, *plightnormal;
- av->fv[0] = DotProduct(pverts->v, aliastransform[0]) +
+ av->fv[0] = DotProduct_(pverts->v, aliastransform[0]) +
aliastransform[0][3];
- av->fv[1] = DotProduct(pverts->v, aliastransform[1]) +
+ av->fv[1] = DotProduct_(pverts->v, aliastransform[1]) +
aliastransform[1][3];
- av->fv[2] = DotProduct(pverts->v, aliastransform[2]) +
+ av->fv[2] = DotProduct_(pverts->v, aliastransform[2]) +
aliastransform[2][3];
fv->v[2] = pstverts->s;
@@ -444,7 +444,7 @@
for (i=0 ; i<r_anumverts ; i++, fv++, pverts++, pstverts++)
{
// transform and project
- zi = 1.0 / (DotProduct(pverts->v, aliastransform[2]) +
+ zi = 1.0 / (DotProduct_(pverts->v, aliastransform[2]) +
aliastransform[2][3]);
// x, y, and z are scaled down by 1/2**31 in the transform, so 1/z is
@@ -452,9 +452,9 @@
// projection
fv->v[5] = zi;
- fv->v[0] = ((DotProduct(pverts->v, aliastransform[0]) +
+ fv->v[0] = ((DotProduct_(pverts->v, aliastransform[0]) +
aliastransform[0][3]) * zi) + aliasxcenter;
- fv->v[1] = ((DotProduct(pverts->v, aliastransform[1]) +
+ fv->v[1] = ((DotProduct_(pverts->v, aliastransform[1]) +
aliastransform[1][3]) * zi) + aliasycenter;
fv->v[2] = pstverts->s;
--- a/r_draw.c
+++ b/r_draw.c
@@ -50,6 +50,18 @@
qboolean r_lastvertvalid;
+int
+surfdrawflags(int flags)
+{
+ if(flags & SURF_TRANS){
+ if((flags & SURF_TELE) != 0 || alphafor(flags) >= 1.0f)
+ if((flags & SURF_FENCE) == 0)
+ return 0;
+ return DRAW_BLEND;
+ }
+ return 0;
+}
+
/*
================
R_EmitEdge
@@ -370,7 +382,7 @@
medge_t *pedges, tedge;
clipplane_t *pclip;
- if(surfdrawflags(fa) ^ r_drawflags)
+ if(surfdrawflags(fa->flags) ^ r_drawflags)
return;
// skip out if no more surfs
--- a/r_local.h
+++ b/r_local.h
@@ -6,7 +6,7 @@
DRAW_BLEND = 1<<0,
};
-#define surfdrawflags(s) (((s)->flags & SURF_TRANS) ? DRAW_BLEND : 0)
+int surfdrawflags(int flags);
#define enthasalpha(e) ((e) && !defalpha((e)->alpha))
#define entdrawflags(e) (((e) && (!defalpha((e)->alpha) || ((e)->model && (e)->model != cl.worldmodel && (e)->model->blend))) ? DRAW_BLEND : 0)