From be8976fa35bf9da5a1be8f3e4fd13dec3f3a3109 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Wed, 22 Oct 2014 20:28:48 -0600 Subject: [PATCH] restore entity sorting --- quakespasm/Quake/gl_rmain.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/quakespasm/Quake/gl_rmain.c b/quakespasm/Quake/gl_rmain.c index 4b9ae938..6ff680d0 100644 --- a/quakespasm/Quake/gl_rmain.c +++ b/quakespasm/Quake/gl_rmain.c @@ -452,6 +452,11 @@ void R_SetupView (void) // //============================================================================== +static int R_EntitySortFunc(const void *a, const void *b) +{ + return (*(entity_t **)a)->model - (*(entity_t **)b)->model; +} + /* ============= R_DrawEntitiesOnList @@ -459,16 +464,21 @@ R_DrawEntitiesOnList */ void R_DrawEntitiesOnList (qboolean alphapass) //johnfitz -- added parameter { + entity_t *entities_sorted[MAX_VISEDICTS]; int i; if (!r_drawentities.value) return; + //ericw -- draw the entities sorted by model, to eliminate redundant texture binding + memcpy (entities_sorted, cl_visedicts, cl_numvisedicts * sizeof(entity_t *)); + qsort (entities_sorted, cl_numvisedicts, sizeof(entity_t *), R_EntitySortFunc); + //ericw -- + //johnfitz -- sprites are not a special case for (i=0 ; ialpha) < 1 && !alphapass) ||