ref: 191f0d455fbc787c63e31bb58b649dd9d0828bea
parent: 45321b4d94499e2aa8159a498c9732eb371bdc73
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Fri Dec 29 20:02:33 EST 2023
render world "rejects" back to front with clipping disabled to fix fence/transparent surfaces play nicely with each other
--- a/r_bsp.c
+++ b/r_bsp.c
@@ -573,7 +573,7 @@
}
void
-R_RenderWorldRejects(void)
+R_RenderBlendedBrushes(void)
{
model_t *clmodel;
nodereject_t *rej;
@@ -585,9 +585,17 @@
clmodel = currententity->model;
r_pcurrentvertbase = clmodel->vertexes;
- for(rej = node_rejects; rej < node_rejects+num_node_rejects; rej++){
+ if(num_node_rejects < 1)
+ return;
+
+ /* back to front, no clipping */
+ /* FIXME(sigrid): this could still be clipped against solid world */
+ /* FIXME(sigrid): needs to be drawn sorted with non-brush entities */
+ for(rej = node_rejects+num_node_rejects-1; rej >= node_rejects; rej--){
surf = cl.worldmodel->surfaces + rej->node->firstsurface;
+ R_BeginEdgeFrame();
for(i = 0; i < rej->node->numsurfaces; i++, surf++)
R_RenderFace(surf, rej->clipflags);
+ R_ScanEdges();
}
}
--- a/r_draw.c
+++ b/r_draw.c
@@ -418,7 +418,6 @@
&r_pcurrentvertbase[r_pedge->v[1]],
pclip);
r_pedge->cachededgeoffset = cacheoffset;
-
if (r_leftclipped)
makeleftedge = true;
if (r_rightclipped)
--- a/r_local.h
+++ b/r_local.h
@@ -82,7 +82,7 @@
//=============================================================================
void R_RenderWorld (void);
-void R_RenderWorldRejects(void);
+void R_RenderBlendedBrushes(void);
//=============================================================================
--- a/r_main.c
+++ b/r_main.c
@@ -667,27 +667,19 @@
R_AliasDrawModel(&r_viewlighting);
}
-/*
-================
-R_EdgeDrawing
-================
-*/
-void R_EdgeDrawing (void)
+void
+R_RenderSolidBrushes(void)
{
entity_t *e;
int i;
R_BeginEdgeFrame();
- if(r_drawflags & DRAW_BLEND)
- R_RenderWorldRejects();
- else{
- R_RenderWorld();
- for(i = 0; i < cl_numvisedicts; i++){
- e = cl_visedicts[i];
- if(e->model != nil && e->model->type == mod_brush && !R_DrawEntity(e)){
- e->last_reject = ent_reject;
- ent_reject = e;
- }
+ R_RenderWorld();
+ for(i = 0; i < cl_numvisedicts; i++){
+ e = cl_visedicts[i];
+ if(e->model != nil && e->model->type == mod_brush && !R_DrawEntity(e)){
+ e->last_reject = ent_reject;
+ ent_reject = e;
}
}
R_ScanEdges();
@@ -711,7 +703,7 @@
if (!cl_entities[0].model || !cl.worldmodel)
fatal ("R_RenderView: NULL worldmodel");
ent_reject = nil;
- R_EdgeDrawing ();
+ R_RenderSolidBrushes();
for(i = 0; i < cl_numvisedicts; i++){
e = cl_visedicts[i];
@@ -723,9 +715,10 @@
R_DrawViewModel ();
R_DrawParticles ();
+
r_drawflags = DRAW_BLEND;
- R_EdgeDrawing();
- // FIXME(sigrid): these need to be sorted and drawn back to front
+ R_RenderBlendedBrushes();
+ // FIXME(sigrid): these need to be sorted with blended brushes and *all* drawn back to front
if(cl_numvisedicts > 0){
for(i = cl_numvisedicts, e = ent_reject; e != nil && i > 0; e = e->last_reject)
cl_visedicts[--i] = e;