shithub: qk1

Download patch

ref: 678bf631976e0e2f9801c0f59d3b6a7d7329e07e
parent: 7763e5f0c8b7e7d67ea3e291a236fb2876ff702c
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Nov 7 18:12:58 EST 2023

blended ents: stop the sorting madness that doesn't work

--- a/r_main.c
+++ b/r_main.c
@@ -708,20 +708,6 @@
 	R_ScanEdges();
 }
 
-static int
-R_SortEntities(const void *a_, const void *b_)
-{
-	entity_t *a, *b;
-	vec3_t v[2];
-
-	a = *(entity_t**)a_;
-	b = *(entity_t**)b_;
-	// FIXME(sigrid): this is the most dumb way, also incorrect
-	VectorSubtract(r_refdef.vieworg, a->origin, v[0]);
-	VectorSubtract(r_refdef.vieworg, b->origin, v[1]);
-	return Length(v[1]) - Length(v[0]);
-}
-
 /*
 ================
 R_RenderView
@@ -764,11 +750,10 @@
 
 	r_drawflags = DRAW_BLEND;
 	R_EdgeDrawing();
-	for(i = 0, e = ent_reject; e != nil; e = e->last_reject, i++)
-		cl_visedicts[i] = e;
-	cl_numvisedicts = i;
-	qsort(cl_visedicts, cl_numvisedicts, sizeof(*cl_visedicts), R_SortEntities);
-	for(i = 0; i < cl_numvisedicts; i++)
+	// FIXME(sigrid): these need to be sorted and drawn back to front
+	for(i = cl_numvisedicts, e = ent_reject; e != nil; e = e->last_reject)
+		cl_visedicts[--i] = e;
+	for(; i < cl_numvisedicts; i++)
 		R_DrawEntity(cl_visedicts[i]);
 	r_drawflags = 0;