X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=meshqueue.c;h=2ba5c518004de13ce324ca07dd6b11283f520525;hp=34334e6d1ff9ba3b590f038129d8dbde789d5b41;hb=cd63746d0f88ccbc279bc61cbcf3dfd400437bc0;hpb=d35a3da5c044ae514578d133eced5a9e8ee17bb0 diff --git a/meshqueue.c b/meshqueue.c index 34334e6d..2ba5c518 100644 --- a/meshqueue.c +++ b/meshqueue.c @@ -10,15 +10,13 @@ typedef struct meshqueue_s int surfacenumber; const rtlight_t *rtlight; float dist; + dptransparentsortcategory_t category; } meshqueue_t; int trans_sortarraysize; meshqueue_t **trans_hash = NULL; meshqueue_t ***trans_hashpointer = NULL; -extern cvar_t r_transparent_sortarraysize; -extern cvar_t r_transparent_sortmindist; -extern cvar_t r_transparent_sortmaxdist; float mqt_viewplanedist; float mqt_viewmaxdist; @@ -33,7 +31,7 @@ void R_MeshQueue_BeginScene(void) mqt_viewmaxdist = 0; } -void R_MeshQueue_AddTransparent(const vec3_t center, void (*callback)(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist), const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight) +void R_MeshQueue_AddTransparent(dptransparentsortcategory_t category, const vec3_t center, void (*callback)(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist), const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight) { meshqueue_t *mq; if (mqt_count >= mqt_total || !mqt_array) @@ -53,7 +51,11 @@ void R_MeshQueue_AddTransparent(const vec3_t center, void (*callback)(const enti mq->ent = ent; mq->surfacenumber = surfacenumber; mq->rtlight = rtlight; - mq->dist = DotProduct(center, r_refdef.view.forward) - mqt_viewplanedist; + mq->category = category; + if (r_transparent_useplanardistance.integer) + mq->dist = DotProduct(center, r_refdef.view.forward) - mqt_viewplanedist; + else + mq->dist = VectorDistance(center, r_refdef.view.origin); mq->next = NULL; mqt_viewmaxdist = max(mqt_viewmaxdist, mq->dist); } @@ -99,7 +101,20 @@ void R_MeshQueue_RenderTransparent(void) maxhashindex = trans_sortarraysize - 1; for (i = 0, mqt = mqt_array; i < mqt_count; i++, mqt++) { - hashindex = bound(0, (int)(bound(0, mqt->dist - r_transparent_sortmindist.integer, r_transparent_sortmaxdist.integer) * distscale), maxhashindex); + switch(mqt->category) + { + default: + case TRANSPARENTSORT_HUD: + hashindex = 0; + break; + case TRANSPARENTSORT_DISTANCE: + // this could use a reduced range if we need more categories + hashindex = bound(0, (int)(bound(0, mqt->dist - r_transparent_sortmindist.integer, r_transparent_sortmaxdist.integer) * distscale), maxhashindex); + break; + case TRANSPARENTSORT_SKY: + hashindex = maxhashindex; + break; + } // link to tail of hash chain (to preserve render order) mqt->next = NULL; *trans_hashpointer[hashindex] = mqt;