diff --git a/src/playsim/p_pspr.cpp b/src/playsim/p_pspr.cpp index 97e58bd680..4a810374a3 100644 --- a/src/playsim/p_pspr.cpp +++ b/src/playsim/p_pspr.cpp @@ -132,6 +132,7 @@ DEFINE_FIELD(DPSprite, x) DEFINE_FIELD(DPSprite, y) DEFINE_FIELD(DPSprite, oldx) DEFINE_FIELD(DPSprite, oldy) +DEFINE_FIELD(DPSprite, baseScale) DEFINE_FIELD(DPSprite, pivot) DEFINE_FIELD(DPSprite, scale) DEFINE_FIELD(DPSprite, rotation) @@ -180,6 +181,7 @@ DPSprite::DPSprite(player_t *owner, AActor *caller, int id) ID(id), processPending(true) { + baseScale = {1.0, 1.2}; rotation = 0.; scale = {1.0, 1.0}; pivot = {0.0, 0.0}; @@ -1251,7 +1253,8 @@ void DPSprite::Serialize(FSerializer &arc) ("rotation", rotation) ("halign", HAlign) ("valign", VAlign) - ("renderstyle_", Renderstyle); // The underscore is intentional to avoid problems with old savegames which had this as an ERenderStyle (which is not future proof.) + ("renderstyle_", Renderstyle) // The underscore is intentional to avoid problems with old savegames which had this as an ERenderStyle (which is not future proof.) + ("baseScale", baseScale); } //------------------------------------------------------------------------ diff --git a/src/playsim/p_pspr.h b/src/playsim/p_pspr.h index df5b45f540..31d3ec0bbe 100644 --- a/src/playsim/p_pspr.h +++ b/src/playsim/p_pspr.h @@ -114,9 +114,10 @@ public: float GetYAdjust(bool fullscreen); int HAlign, VAlign; // Horizontal and vertical alignment + DVector2 baseScale; // Base scale (set by weapon); defaults to (1.0, 1.2) since that's Doom's native aspect ratio DAngle rotation; // How much rotation to apply. DVector2 pivot; // pivot points - DVector2 scale; // Scale + DVector2 scale; // Dynamic scale (set by A_Overlay functions) double x, y, alpha; double oldx, oldy; bool InterpolateTic; // One tic interpolation (WOF_INTERPOLATE) diff --git a/src/rendering/hwrenderer/scene/hw_weapon.cpp b/src/rendering/hwrenderer/scene/hw_weapon.cpp index f90ff4fd9a..a49f497c3e 100644 --- a/src/rendering/hwrenderer/scene/hw_weapon.cpp +++ b/src/rendering/hwrenderer/scene/hw_weapon.cpp @@ -428,7 +428,7 @@ bool HUDSprite::GetWeaponRect(HWDrawInfo *di, DPSprite *psp, float sx, float sy, FloatRect r = spi.GetSpriteRect(); // calculate edges of the shape - scalex = (320.0f / (240.0f * r_viewwindow.WidescreenRatio)) * vw / 320; + scalex = psp->baseScale.X * (320.0f / (240.0f * r_viewwindow.WidescreenRatio)) * (vw / 320); float x1, y1, x2, y2, u1, v1, u2, v2; @@ -447,7 +447,10 @@ bool HUDSprite::GetWeaponRect(HWDrawInfo *di, DPSprite *psp, float sx, float sy, // killough 12/98: fix psprite positioning problem ftexturemid = 100.f - sy - r.top - psp->GetYAdjust(screenblocks >= 11); - scale = (SCREENHEIGHT*vw) / (SCREENWIDTH * 200.0f); + // [XA] note: Doom's native 1.2x aspect ratio was originally + // handled here by multiplying SCREENWIDTH by 200 instead of + // 240, but now the baseScale var defines this from now on. + scale = psp->baseScale.Y * (SCREENHEIGHT*vw) / (SCREENWIDTH * 240.0f); y1 = viewwindowy + vh / 2 - (ftexturemid * scale); y2 = y1 + (r.height * scale) + 1; diff --git a/src/rendering/swrenderer/things/r_playersprite.cpp b/src/rendering/swrenderer/things/r_playersprite.cpp index 45d3d5fa26..e892cf7da0 100644 --- a/src/rendering/swrenderer/things/r_playersprite.cpp +++ b/src/rendering/swrenderer/things/r_playersprite.cpp @@ -265,7 +265,8 @@ namespace swrenderer auto viewport = Thread->Viewport.get(); double pspritexscale = viewport->viewwindow.centerxwide / 160.0; - double pspriteyscale = pspritexscale * viewport->BaseYaspectMul * ((double)SCREENHEIGHT / SCREENWIDTH) * r_viewwindow.WidescreenRatio; + double pspriteyscale = pspritexscale * pspr->baseScale.Y * ((double)SCREENHEIGHT / SCREENWIDTH) * r_viewwindow.WidescreenRatio; + pspritexscale *= pspr->baseScale.X; // [XA] don't accidentally apply this to the Y calculation above; math be weird double pspritexiscale = 1 / pspritexscale; int tleft = tex->GetDisplayLeftOffset(0); diff --git a/wadsrc/static/zscript/actors/inventory/weapons.zs b/wadsrc/static/zscript/actors/inventory/weapons.zs index 9c3519b487..f3723b3d9c 100644 --- a/wadsrc/static/zscript/actors/inventory/weapons.zs +++ b/wadsrc/static/zscript/actors/inventory/weapons.zs @@ -25,6 +25,7 @@ class Weapon : StateProvider int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha) (visual only so no need to be a double) float BobSpeed; // [XA] Bobbing speed. Defines how quickly a weapon bobs. float BobRangeX, BobRangeY; // [XA] Bobbing range. Defines how far a weapon bobs in either direction. + float WeaponScaleX, WeaponScaleY; // [XA] Weapon scale. Defines the scale for the held weapon sprites (PSprite). Defaults to (1.0, 1.2) since that's what Doom does. Ammo Ammo1, Ammo2; // In-inventory instance variables Weapon SisterWeapon; double FOVScale; @@ -57,6 +58,8 @@ class Weapon : StateProvider property BobSpeed: BobSpeed; property BobRangeX: BobRangeX; property BobRangeY: BobRangeY; + property WeaponScaleX: WeaponScaleX; + property WeaponScaleY: WeaponScaleY; property SlotNumber: SlotNumber; property SlotPriority: SlotPriority; property LookScale: LookScale; @@ -95,6 +98,8 @@ class Weapon : StateProvider Weapon.BobSpeed 1.0; Weapon.BobRangeX 1.0; Weapon.BobRangeY 1.0; + Weapon.WeaponScaleX 1.0; + Weapon.WeaponScaleY 1.2; Weapon.SlotNumber -1; Weapon.SlotPriority 32767; +WEAPONSPAWN @@ -218,6 +223,8 @@ class Weapon : StateProvider { if (!psp) return; psp.rotation = 0; + psp.baseScale.x = invoker.WeaponScaleX; + psp.baseScale.y = invoker.WeaponScaleY; psp.scale.x = 1; psp.scale.y = 1; psp.pivot.x = 0; diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index be17e160bd..1a381c3a86 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -2600,6 +2600,7 @@ class PSprite : Object native play native double y; native double oldx; native double oldy; + native Vector2 baseScale; native Vector2 pivot; native Vector2 scale; native double rotation;