From 4a3a5c3877364b06a04b0a08ca31b8f36fa86467 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Wed, 30 Sep 2020 15:38:58 -0500 Subject: [PATCH] Replaced PSPF_PIVOTOFFSETREL with WOF_RELATIVE. The idea behind this is to outright remove the relative position adding from the engine side and let it happen with A_OverlayOffset instead. Still more work to do. --- src/playsim/p_pspr.cpp | 5 ++--- src/playsim/p_pspr.h | 2 -- src/rendering/hwrenderer/scene/hw_weapon.cpp | 12 ++++++------ wadsrc/static/zscript/actors/player/player.zs | 1 - wadsrc/static/zscript/constants.zs | 1 + 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/playsim/p_pspr.cpp b/src/playsim/p_pspr.cpp index d858c0598..b5ecf78f0 100644 --- a/src/playsim/p_pspr.cpp +++ b/src/playsim/p_pspr.cpp @@ -155,7 +155,6 @@ DEFINE_FIELD_BIT(DPSprite, Flags, bMirror, PSPF_MIRROR) DEFINE_FIELD_BIT(DPSprite, Flags, bPlayerTranslated, PSPF_PLAYERTRANSLATED) DEFINE_FIELD_BIT(DPSprite, Flags, bPivotPercent, PSPF_PIVOTPERCENT) DEFINE_FIELD_BIT(DPSprite, Flags, bPivotScreen, PSPF_PIVOTSCREEN) -DEFINE_FIELD_BIT(DPSprite, Flags, bPivotOffsetRel, PSPF_PIVOTOFFSETREL) //------------------------------------------------------------------------ // @@ -184,8 +183,7 @@ DPSprite::DPSprite(player_t *owner, AActor *caller, int id) oldpx(.0), oldpy(.0), oldrotation(.0), PivotPercent(true), - PivotScreen(false), - PivotOffsetRel(false) + PivotScreen(false) { alpha = 1; Renderstyle = STYLE_Normal; @@ -671,6 +669,7 @@ enum WOFFlags WOF_KEEPY = 1 << 1, WOF_ADD = 1 << 2, WOF_INTERPOLATE = 1 << 3, + WOF_RELATIVE = 1 << 4, }; DEFINE_ACTION_FUNCTION(AActor, A_OverlayScale) diff --git a/src/playsim/p_pspr.h b/src/playsim/p_pspr.h index 27afacb5c..e5d7ad10b 100644 --- a/src/playsim/p_pspr.h +++ b/src/playsim/p_pspr.h @@ -73,7 +73,6 @@ enum PSPFlags PSPF_PLAYERTRANSLATED = 1 << 10, PSPF_PIVOTPERCENT = 1 << 11, PSPF_PIVOTSCREEN = 1 << 12, - PSPF_PIVOTOFFSETREL = 1 << 13, }; class DPSprite : public DObject @@ -102,7 +101,6 @@ public: bool PivotScreen; // If true, the pivot is based on the entire screen width/height instead of the image's dimensions/position. bool PivotPercent; // If true, the pivot goes between [0.0, 1.0]. Otherwise, it's a pixel position offset from the image size. - bool PivotOffsetRel; // If true, x & y are relative to rotation. Otherwise, x is left/right and y is up/down. double px, py; // pivot points double oldpx, oldpy; double rotation; // How much rotation to apply. diff --git a/src/rendering/hwrenderer/scene/hw_weapon.cpp b/src/rendering/hwrenderer/scene/hw_weapon.cpp index 452b33f86..dd13c6ad8 100644 --- a/src/rendering/hwrenderer/scene/hw_weapon.cpp +++ b/src/rendering/hwrenderer/scene/hw_weapon.cpp @@ -490,8 +490,8 @@ bool HUDSprite::GetWeaponRect(HWDrawInfo *di, DPSprite *psp, float sx, float sy, if (psp->rotation != 0.0 || psp->scalex != 1.0 || psp->scaley != 1.0) { float radang = psp->rotation * (pi::pi() / 180.); - float cosang = -cos(radang); - float sinang = -sin(radang); + float cosang = cos(radang); + float sinang = sin(radang); float xcenter, ycenter; @@ -535,16 +535,16 @@ bool HUDSprite::GetWeaponRect(HWDrawInfo *di, DPSprite *psp, float sx, float sy, float ssy = (float)psp->scaley; float xx1 = xcenter + ssx * (x1 * cosang + y1 * sinang); - float yy1 = ycenter + ssy * (x1 * sinang - y1 * cosang); + float yy1 = ycenter - ssy * (x1 * sinang - y1 * cosang); float xx2 = xcenter + ssx * (x1 * cosang + y2 * sinang); - float yy2 = ycenter + ssy * (x1 * sinang - y2 * cosang); + float yy2 = ycenter - ssy * (x1 * sinang - y2 * cosang); float xx3 = xcenter + ssx * (x2 * cosang + y1 * sinang); - float yy3 = ycenter + ssy * (x2 * sinang - y1 * cosang); + float yy3 = ycenter - ssy * (x2 * sinang - y1 * cosang); float xx4 = xcenter + ssx * (x2 * cosang + y2 * sinang); - float yy4 = ycenter + ssy * (x2 * sinang - y2 * cosang); + float yy4 = ycenter - ssy * (x2 * sinang - y2 * cosang); verts.first[0].Set(xx1, yy1, 0, u1, v1); verts.first[1].Set(xx2, yy2, 0, u1, v2); diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index d0f5ccf25..f076e680a 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -2580,7 +2580,6 @@ class PSprite : Object native play native bool bPlayerTranslated; native bool bPivotPercent; native bool bPivotScreen; - native bool bPivotOffsetRel; native void SetState(State newstate, bool pending = false); diff --git a/wadsrc/static/zscript/constants.zs b/wadsrc/static/zscript/constants.zs index f7f9e2508..215d53b17 100644 --- a/wadsrc/static/zscript/constants.zs +++ b/wadsrc/static/zscript/constants.zs @@ -694,6 +694,7 @@ enum EWeaponOffsetFlags WOF_KEEPY = 1 << 1, WOF_ADD = 1 << 2, WOF_INTERPOLATE = 1 << 3, + WOF_RELATIVE = 1 << 4, }; // Flags for psprite layers