From a111c5928638a606c6f1776823194ebc6208dac1 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Thu, 25 May 2017 19:46:36 -0500 Subject: [PATCH 1/4] Added PSPF_MIRROR. - Flips the sprite's drawing and position over entirely. Automatically implies PSPF_FLIP. --- src/gl/scene/gl_weapon.cpp | 12 ++++++++++-- src/p_pspr.cpp | 1 + src/p_pspr.h | 1 + wadsrc/static/zscript/constants.txt | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 23610fb01..61c5c2a4e 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -98,7 +98,7 @@ void GLSceneDrawer::DrawPSprite (player_t * player,DPSprite *psp, float sx, floa // calculate edges of the shape scalex = (320.0f / (240.0f * r_viewwindow.WidescreenRatio)) * vw / 320; - tx = sx - (160 - r.left); + tx = (psp->Flags & PSPF_MIRROR) ? ((160 - r.width) - (sx + r.left)) : (sx - (160 - r.left)); x1 = tx * scalex + vw/2; if (x1 > vw) return; // off the right side x1 += viewwindowx; @@ -107,6 +107,13 @@ void GLSceneDrawer::DrawPSprite (player_t * player,DPSprite *psp, float sx, floa x2 = tx * scalex + vw / 2; if (x2 < 0) return; // off the left side x2 += viewwindowx; + /* + if (psp->Flags & PSPF_MIRROR) + { + float dist = 320.f - sx; + x1 += dist * scalex; + x2 += dist * scalex; + }*/ // killough 12/98: fix psprite positioning problem @@ -130,7 +137,8 @@ void GLSceneDrawer::DrawPSprite (player_t * player,DPSprite *psp, float sx, floa y1 = viewwindowy + vh / 2 - (ftexturemid * scale); y2 = y1 + (r.height * scale) + 1; - if (!(mirror) != !(psp->Flags & PSPF_FLIP)) + + if (!(mirror) != !(psp->Flags & (PSPF_FLIP|PSPF_MIRROR))) { fU2 = tex->GetSpriteUL(); fV1 = tex->GetSpriteVT(); diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 2404b8b9c..45e92a8d0 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -141,6 +141,7 @@ DEFINE_FIELD_BIT(DPSprite, Flags, bAddBob, PSPF_ADDBOB) DEFINE_FIELD_BIT(DPSprite, Flags, bPowDouble, PSPF_POWDOUBLE) DEFINE_FIELD_BIT(DPSprite, Flags, bCVarFast, PSPF_CVARFAST) DEFINE_FIELD_BIT(DPSprite, Flags, bFlip, PSPF_FLIP) +DEFINE_FIELD_BIT(DPSprite, Flags, bMirror, PSPF_MIRROR) //------------------------------------------------------------------------ // diff --git a/src/p_pspr.h b/src/p_pspr.h index 5964ace20..c98918ded 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -68,6 +68,7 @@ enum PSPFlags PSPF_FLIP = 1 << 6, PSPF_FORCEALPHA = 1 << 7, PSPF_FORCESTYLE = 1 << 8, + PSPF_MIRROR = 1 << 9, }; class DPSprite : public DObject diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index b698f966f..b0bf1b65d 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -726,6 +726,7 @@ enum EPSpriteFlags PSPF_FLIP = 1 << 6, PSPF_FORCEALPHA = 1 << 7, PSPF_FORCESTYLE = 1 << 8, + PSPF_MIRROR = 1 << 9, }; // Default psprite layers From a25a536c9f33447dbc095b368f4436f1d6d4c719 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Thu, 25 May 2017 20:40:54 -0500 Subject: [PATCH 2/4] Removed the auto PSPF_FLIP implimentation. --- src/gl/scene/gl_weapon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 61c5c2a4e..90d0ff31b 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -138,7 +138,7 @@ void GLSceneDrawer::DrawPSprite (player_t * player,DPSprite *psp, float sx, floa y2 = y1 + (r.height * scale) + 1; - if (!(mirror) != !(psp->Flags & (PSPF_FLIP|PSPF_MIRROR))) + if (!(mirror) != !(psp->Flags & (PSPF_FLIP))) { fU2 = tex->GetSpriteUL(); fV1 = tex->GetSpriteVT(); From 636e36b90d9f2b9a5792d9bfdaec23ed53bc647b Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Fri, 26 May 2017 11:34:26 -0500 Subject: [PATCH 3/4] Clean-up. --- src/gl/scene/gl_weapon.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 90d0ff31b..8edc12474 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -107,14 +107,6 @@ void GLSceneDrawer::DrawPSprite (player_t * player,DPSprite *psp, float sx, floa x2 = tx * scalex + vw / 2; if (x2 < 0) return; // off the left side x2 += viewwindowx; - /* - if (psp->Flags & PSPF_MIRROR) - { - float dist = 320.f - sx; - x1 += dist * scalex; - x2 += dist * scalex; - }*/ - // killough 12/98: fix psprite positioning problem ftexturemid = 100.f - sy - r.top; From 35583621cf9573c9d79e4398f65f204f168ae31b Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Fri, 26 May 2017 18:28:09 -0500 Subject: [PATCH 4/4] PSPF_MIRROR now corrects the bobx direction. --- src/gl/scene/gl_weapon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 8edc12474..78c32cc07 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -437,7 +437,7 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) if (psp->Flags & PSPF_ADDBOB) { - sx += bobx; + sx += (psp->Flags & PSPF_MIRROR) ? -bobx : bobx; sy += boby; }