From 1b5d88d290fe90004be43d5cdf4efedd0c4934de Mon Sep 17 00:00:00 2001 From: yellowtd Date: Sat, 21 Feb 2015 03:16:26 -0500 Subject: [PATCH] MD2 fixes transparency fixes, and views (it would be so much better if they didn't stop rendering past the camera y'know, especially if they're big.) --- src/hardware/hw_main.c | 8 +++++--- src/hardware/r_opengl/r_opengl.c | 11 ++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5842a3cd8..e898d274d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4028,7 +4028,8 @@ static void HWR_SortVisSprites(void) gr_vsprsortedhead.next = gr_vsprsortedhead.prev = &gr_vsprsortedhead; for (i = 0; i < gr_visspritecount; i++) { - bestdist = ZCLIP_PLANE-1; + //bestdist = ZCLIP_PLANE-1; + bestdist = -66666.0f; //Yellow: Changing this value fixes the crash for (ds = unsorted.next; ds != &unsorted; ds = ds->next) { if (ds->tz > bestdist) @@ -4561,7 +4562,7 @@ static void HWR_ProjectSprite(mobj_t *thing) tz = (tr_x * gr_viewcos) + (tr_y * gr_viewsin); // thing is behind view plane? - if (tz < ZCLIP_PLANE) + if (tz < ZCLIP_PLANE && md2_models[thing->sprite].notfound == true) //Yellow: Only MD2's dont disappear return; tx = (tr_x * gr_viewsin) - (tr_y * gr_viewcos); @@ -4589,8 +4590,9 @@ static void HWR_ProjectSprite(mobj_t *thing) rot = thing->frame&FF_FRAMEMASK; thing->state->sprite = thing->sprite; thing->state->frame = thing->frame; + sprdef = &sprites[thing->sprite]; //Yellow: sprdef now updates rotations to fix the crash } - + sprframe = &sprdef->spriteframes[rot]; #ifdef PARANOIA diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 76543e259..fd4261bce 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1899,7 +1899,7 @@ EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 d #endif } - DrawPolygon(NULL, NULL, 0, PF_Masked|PF_Modulated|PF_Occlude|PF_Clip); + DrawPolygon(NULL, NULL, 0, PF_Masked|PF_Modulated|PF_Occlude/*|PF_Clip*/); //Yellow: Fixes MD2 Transparency pglPushMatrix(); // should be the same as glLoadIdentity //Hurdler: now it seems to work @@ -1909,6 +1909,15 @@ EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 d pglRotatef(pos->angley, 0.0f, -1.0f, 0.0f); pglRotatef(pos->anglex, -1.0f, 0.0f, 0.0f); //pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency + + //Yellow: Fixes MD2 Transparency + // Remove depth mask when the model is transparent so it doesn't cut thorugh sprites + if (color[3] < 255) + { + pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency + pglDepthMask(GL_FALSE); + } + val = *gl_cmd_buffer++;