From 8d3f3c6025d296c4c77fa7dd748537e08c4561a5 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 28 Sep 2022 13:39:01 +1000 Subject: [PATCH] - Cut over to `DAngle` from `fixedhoriz` and remove the latter. --- source/core/fixedhorizon.h | 182 ----------------------- source/core/gamefuncs.cpp | 2 +- source/core/gamefuncs.h | 9 +- source/core/gameinput.cpp | 33 ++-- source/core/gameinput.h | 38 +++-- source/core/gamestruct.h | 8 +- source/core/mapinfo.h | 2 +- source/core/maptypes.h | 5 +- source/core/rendering/hw_entrypoint.cpp | 8 +- source/core/rendering/render.h | 4 +- source/games/blood/src/blood.h | 6 +- source/games/blood/src/player.cpp | 4 +- source/games/blood/src/prediction.cpp | 4 +- source/games/blood/src/view.cpp | 13 +- source/games/duke/src/actors_d.cpp | 2 +- source/games/duke/src/actors_r.cpp | 2 +- source/games/duke/src/duke3d.h | 2 +- source/games/duke/src/gameexec.cpp | 6 +- source/games/duke/src/player.cpp | 6 +- source/games/duke/src/player_r.cpp | 16 +- source/games/duke/src/prediction.cpp | 2 +- source/games/duke/src/prediction.h | 2 +- source/games/duke/src/premap.cpp | 4 +- source/games/duke/src/render.cpp | 3 +- source/games/exhumed/src/exhumed.h | 6 +- source/games/exhumed/src/player.cpp | 16 +- source/games/exhumed/src/player.h | 2 +- source/games/exhumed/src/view.cpp | 4 +- source/games/sw/src/draw.cpp | 3 +- source/games/sw/src/game.h | 4 +- source/games/sw/src/jsector.cpp | 2 +- source/games/sw/src/player.cpp | 16 +- source/games/sw/src/predict.cpp | 2 +- source/games/sw/src/weapon.cpp | 2 +- wadsrc/static/zscript/games/sw/swgame.zs | 2 +- 35 files changed, 110 insertions(+), 312 deletions(-) delete mode 100644 source/core/fixedhorizon.h diff --git a/source/core/fixedhorizon.h b/source/core/fixedhorizon.h deleted file mode 100644 index 5bba16ee4..000000000 --- a/source/core/fixedhorizon.h +++ /dev/null @@ -1,182 +0,0 @@ -/* -** fixedhorizon.h -** -** type safe representations of high precision horizon values. -** -**--------------------------------------------------------------------------- -** Copyright 2020-2022 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ - -#pragma once - -#include -#include "basics.h" -#include "m_fixed.h" -#include "vectors.h" -#include "xs_Float.h" // needed for reliably overflowing float->int conversions. -#include "serializer.h" -#include "math/cmath.h" - -class FSerializer; - -//--------------------------------------------------------------------------- -// -// Functions for use with fixedhoriz and friendly functions. -// -//--------------------------------------------------------------------------- - -inline double HorizToPitch(double horiz) { return atan2(horiz, 128) * (180. / pi::pi()); } -inline double HorizToPitch(fixed_t q16horiz) { return atan2(q16horiz, IntToFixed(128)) * (180. / pi::pi()); } - - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -class fixedhoriz -{ - fixed_t value; - - constexpr fixedhoriz(fixed_t v) : value(v) {} - - friend fixedhoriz pitchhoriz(double v); - - friend FSerializer &Serialize(FSerializer &arc, const char *key, fixedhoriz &obj, fixedhoriz *defval); - -public: - fixedhoriz() = default; - fixedhoriz(const fixedhoriz &other) = default; - fixedhoriz& operator=(const fixedhoriz&) = default; - - // This class intentionally makes no allowances for implicit type conversions because those would render it ineffective. - constexpr double Tan() const { return FixedToFloat<23>(value); } - double Degrees() const { return HorizToPitch(value); } - - int Sgn() const { return ::Sgn(value); } - - bool operator< (fixedhoriz other) const - { - return value < other.value; - } - - bool operator> (fixedhoriz other) const - { - return value > other.value; - } - - bool operator<= (fixedhoriz other) const - { - return value <= other.value; - } - - bool operator>= (fixedhoriz other) const - { - return value >= other.value; - } - constexpr bool operator== (fixedhoriz other) const - { - return value == other.value; - } - - constexpr bool operator!= (fixedhoriz other) const - { - return value != other.value; - } - - constexpr fixedhoriz &operator+= (fixedhoriz other) - { - value += other.value; - return *this; - } - - constexpr fixedhoriz &operator-= (fixedhoriz other) - { - value -= other.value; - return *this; - } - - constexpr fixedhoriz operator- () const - { - return fixedhoriz(-value); - } - - constexpr fixedhoriz operator+ (fixedhoriz other) const - { - return fixedhoriz(value + other.value); - } - - constexpr fixedhoriz operator- (fixedhoriz other) const - { - return fixedhoriz(value - other.value); - } - - constexpr fixedhoriz &operator<<= (const uint8_t shift) - { - value <<= shift; - return *this; - } - - constexpr fixedhoriz &operator>>= (const uint8_t shift) - { - value >>= shift; - return *this; - } - - constexpr fixedhoriz operator<< (const uint8_t shift) const - { - return fixedhoriz(value << shift); - } - - constexpr fixedhoriz operator>> (const uint8_t shift) const - { - return fixedhoriz(value >> shift); - } - - template - constexpr fixedhoriz &operator*= (const T other) - { - value = value * other; - return *this; - } - - template - constexpr fixedhoriz operator* (const T other) const - { - return value * other; - } -}; - -inline fixedhoriz pitchhoriz(double v) { return fixedhoriz(fixed_t(clamp(IntToFixed(128) * tan(v * (pi::pi() / 180.)), -INT32_MAX, INT32_MAX))); } - -inline FSerializer &Serialize(FSerializer &arc, const char *key, fixedhoriz &obj, fixedhoriz *defval) -{ - return Serialize(arc, key, obj.value, defval ? &defval->value : nullptr); -} diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index 1f2265659..fb436352b 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -37,7 +37,7 @@ IntRect viewport3d; double cameradist, cameraclock; -bool calcChaseCamPos(DVector3& ppos, DCoreActor* act, sectortype** psect, DAngle ang, fixedhoriz horiz, double const interpfrac) +bool calcChaseCamPos(DVector3& ppos, DCoreActor* act, sectortype** psect, DAngle ang, DAngle horiz, double const interpfrac) { if (!*psect) return false; diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 69b791deb..24dda2b6f 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -4,7 +4,6 @@ #include "gamestruct.h" #include "build.h" #include "coreactor.h" -#include "fixedhorizon.h" #include "intrect.h" #include "geometry.h" @@ -268,7 +267,7 @@ extern double cameradist, cameraclock; void loaddefinitionsfile(const char* fn, bool cumulative = false, bool maingrp = false); -bool calcChaseCamPos(DVector3& ppos, DCoreActor* pspr, sectortype** psectnum, DAngle ang, fixedhoriz horiz, double const interpfrac); +bool calcChaseCamPos(DVector3& ppos, DCoreActor* pspr, sectortype** psectnum, DAngle ang, DAngle horiz, double const interpfrac); int getslopeval(sectortype* sect, const DVector3& pos, double bazez); bool cansee(const DVector3& start, sectortype* sect1, const DVector3& end, sectortype* sect2); double intersectSprite(DCoreActor* actor, const DVector3& start, const DVector3& direction, DVector3& result, double maxfactor); @@ -537,17 +536,17 @@ inline double BobVal(double val) return g_sinbam(xs_CRoundToUInt(val * (1 << 21))); } -inline double GetMinPitch() +inline DAngle GetMinPitch() { return gi->playerPitchMin(); } -inline double GetMaxPitch() +inline DAngle GetMaxPitch() { return gi->playerPitchMax(); } -inline double ClampViewPitch(const double pitch) +inline DAngle ClampViewPitch(const DAngle pitch) { return clamp(pitch, GetMinPitch(), GetMaxPitch()); } diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 4f73f580d..cc872ba76 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -176,14 +176,11 @@ void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double cons // Test if we have input to process. if (horz || *actions & (SB_AIM_UP | SB_AIM_DOWN | SB_LOOK_UP | SB_LOOK_DOWN | SB_CENTERVIEW)) { - // Store current horizon as true pitch. - double pitch = horiz.Degrees(); - // Process mouse input. if (horz) { *actions &= ~SB_CENTERVIEW; - pitch += horz; + horiz += DAngle::fromDeg(horz); } // Process keyboard input. @@ -192,27 +189,20 @@ void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double cons if (*actions & (up | down)) { if (lock) *actions &= ~SB_CENTERVIEW; else *actions |= SB_CENTERVIEW; - pitch += scaleAdjust * getTicrateScale(rate) * (!!(*actions & up) - !!(*actions & down)); + horiz += DAngle::fromDeg(scaleAdjust * getTicrateScale(rate) * (!!(*actions & up) - !!(*actions & down))); } }; doKbdInput(SB_AIM_UP, SB_AIM_DOWN, PITCH_AIMSPEED, true); doKbdInput(SB_LOOK_UP, SB_LOOK_DOWN, PITCH_LOOKSPEED, false); - // return to center if conditions met, using a temporary DAngle object. - auto tmpangle = DAngle::fromDeg(pitch); - if ((*actions & SB_CENTERVIEW) && !(*actions & (SB_LOOK_UP|SB_LOOK_DOWN))) { - scaletozero(tmpangle, PITCH_CENTRESPEED * (PITCH_CNTRSINEOFFSET - abs(tmpangle)).Sin(), scaleAdjust); - if (!tmpangle.Sgn()) - { - tmpangle = nullAngle; - *actions &= ~SB_CENTERVIEW; - } + scaletozero(horiz, PITCH_CENTRESPEED * (PITCH_CNTRSINEOFFSET - abs(horiz)).Sin(), scaleAdjust); + if (!horiz.Sgn()) *actions &= ~SB_CENTERVIEW; } // clamp before converting back to horizon - horiz = pitchhoriz(ClampViewPitch(tmpangle.Degrees())); + horiz = ClampViewPitch(horiz); } } else @@ -295,9 +285,6 @@ void PlayerHorizon::calcviewpitch(const DVector2& pos, DAngle const ang, bool co { if (cl_slopetilting && cursectnum != nullptr) { - // Temporarily hold horizoff as pitch. - auto tmpangle = DAngle::fromDeg(horizoff.Degrees()); - if (aimmode && canslopetilt) // If the floor is sloped { // Get a point, 512 (64 for Blood) units ahead of player's position @@ -319,7 +306,7 @@ void PlayerHorizon::calcviewpitch(const DVector2& pos, DAngle const ang, bool co // accordingly if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslopeptr(tempsect, rotpt) - k) <= 4)) { - tmpangle += DAngle::fromDeg(maphoriz(scaleAdjust * ((j - k) * (!isBlood() ? 0.625 : 5.5))).Degrees()); + horizoff += maphoriz(scaleAdjust * ((j - k) * (!isBlood() ? 0.625 : 5.5))); } } } @@ -327,16 +314,16 @@ void PlayerHorizon::calcviewpitch(const DVector2& pos, DAngle const ang, bool co if (climbing) { // tilt when climbing but you can't even really tell it. - if (tmpangle < DAngle::fromDeg(38)) tmpangle += getscaledangle(HORIZOFFSPEEDF, scaleAdjust, DAngle::fromDeg(38) - tmpangle, DAngle::fromDeg(0.4476)); + if (horizoff < DAngle::fromDeg(38)) horizoff += getscaledangle(HORIZOFFSPEEDF, scaleAdjust, deltaangle(horizoff, DAngle::fromDeg(38)), DAngle::fromDeg(0.4476)); } else { // Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope. - scaletozero(tmpangle, HORIZOFFSPEEDF, scaleAdjust, DAngle::fromDeg(tmpangle.Sgn() * 0.4476)); + scaletozero(horizoff, HORIZOFFSPEEDF, scaleAdjust, DAngle::fromDeg(horizoff.Sgn() * 0.4476)); } - // Convert temporary angle back to fixedhoriz. - horizoff = pitchhoriz(ClampViewPitch(tmpangle.Degrees())); + // Clamp off against the maximum allowed pitch. + horizoff = ClampViewPitch(horizoff); } } diff --git a/source/core/gameinput.h b/source/core/gameinput.h index 2c7ad4e0a..2ef17e888 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -1,7 +1,6 @@ #pragma once #include "m_fixed.h" -#include "fixedhorizon.h" #include "gamecvars.h" #include "gamestruct.h" #include "gamefuncs.h" @@ -9,7 +8,7 @@ struct PlayerHorizon { - fixedhoriz horiz, ohoriz, horizoff, ohorizoff; + DAngle horiz, ohoriz, horizoff, ohorizoff; friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w, PlayerHorizon* def); @@ -30,12 +29,12 @@ struct PlayerHorizon } // Commonly used getters. - fixedhoriz osum() { return ohoriz + ohorizoff; } - fixedhoriz sum() { return horiz + horizoff; } - fixedhoriz interpolatedsum(double const interpfrac) { return interpolatedvalue(osum(), sum(), interpfrac); } + DAngle osum() { return ohoriz + ohorizoff; } + DAngle sum() { return horiz + horizoff; } + DAngle interpolatedsum(double const interpfrac) { return interpolatedvalue(osum(), sum(), interpfrac); } // Ticrate playsim adjustment helpers. - void resetadjustment() { adjustment = 0; } + void resetadjustment() { adjustment = nullAngle; } bool targetset() { return target.Sgn(); } // Input locking helpers. @@ -47,11 +46,11 @@ struct PlayerHorizon double horizsumfrac(double const interpfrac) { return (!SyncInput() ? sum() : interpolatedsum(interpfrac)).Tan() * 8.; } // Ticrate playsim adjustment setters and processor. - void addadjustment(fixedhoriz const value) + void addadjustment(DAngle const value) { if (!SyncInput()) { - adjustment += value.Degrees(); + adjustment += value; } else { @@ -59,14 +58,14 @@ struct PlayerHorizon } } - void settarget(fixedhoriz value, bool const backup = false) + void settarget(DAngle value, bool const backup = false) { // Clamp incoming variable because sometimes the caller can exceed bounds. - value = pitchhoriz(ClampViewPitch(value.Degrees())); + value = ClampViewPitch(value); if (!SyncInput() && !backup) { - target = value.Sgn() ? value : pitchhoriz(minAngle.Degrees()); + target = value.Sgn() ? value : minAngle; } else { @@ -79,27 +78,26 @@ struct PlayerHorizon { if (targetset()) { - auto delta = (target - horiz).Degrees(); + auto delta = deltaangle(horiz, target); - if (abs(delta) > 0.45) + if (abs(delta).Degrees() > 0.45) { - horiz += pitchhoriz(scaleAdjust * delta); + horiz += delta * scaleAdjust; } else { horiz = target; - target = pitchhoriz(nullAngle.Degrees()); + target = nullAngle; } } - else if (adjustment) + else if (adjustment.Sgn()) { - horiz += pitchhoriz(scaleAdjust * adjustment); + horiz += adjustment * scaleAdjust; } } private: - fixedhoriz target; - double adjustment; + DAngle target, adjustment; bool inputdisabled; }; @@ -165,7 +163,7 @@ struct PlayerAngle { if (!SyncInput() && !backup) { - target = value.Sgn() ? value : DAngle::fromBam(1); + target = value.Sgn() ? value : minAngle; } else { diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index 78fbd626c..e1dca9f65 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -7,7 +7,7 @@ bool System_WantGuiCapture(); // During playing this tells us whether the game m #include "engineerrors.h" #include "stats.h" #include "packet.h" -#include "fixedhorizon.h" +#include "serializer.h" #include "inputstate.h" #include "maptypes.h" @@ -109,13 +109,13 @@ struct GameInterface virtual void LevelCompleted(MapRecord* map, int skill) {} virtual bool DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, const DAngle cang, const DVector2& xydim, const double czoom, double const interpfrac) { return false; } virtual void SetTileProps(int tile, int surf, int vox, int shade) {} - virtual double playerPitchMin() { return -57.375; } - virtual double playerPitchMax() { return 57.375; } + virtual DAngle playerPitchMin() { return DAngle::fromDeg(-57.375); } + virtual DAngle playerPitchMax() { return DAngle::fromDeg(57.375); } virtual void WarpToCoords(double x, double y, double z, DAngle a) {} virtual void ToggleThirdPerson() { } virtual void SwitchCoopView() { Printf("Unsupported command\n"); } virtual void ToggleShowWeapon() { Printf("Unsupported command\n"); } - virtual DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(0,0,0); } + virtual DVector3 chaseCamPos(DAngle ang, DAngle horiz) { return DVector3(0,0,0); } virtual void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) = 0; virtual void UpdateCameras(double smoothratio) {} virtual void EnterPortal(DCoreActor* viewer, int type) {} diff --git a/source/core/mapinfo.h b/source/core/mapinfo.h index 7fa5bedb5..07476ddd6 100644 --- a/source/core/mapinfo.h +++ b/source/core/mapinfo.h @@ -149,7 +149,7 @@ struct MapRecord // game specific stuff int rr_startsound = 0; int rr_mamaspawn = 15; - fixedhoriz ex_ramses_horiz = pitchhoriz(4.912); + DAngle ex_ramses_horiz = DAngle::fromDeg(4.912); int ex_ramses_cdtrack = -1; // this is not music, it is the actual dialogue! FString ex_ramses_pup; FString ex_ramses_text; diff --git a/source/core/maptypes.h b/source/core/maptypes.h index 241d516f9..9066626cc 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -32,7 +32,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #include "tflags.h" #include "intvec.h" #include "dobject.h" -#include "fixedhorizon.h" void MarkVerticesForSector(int sector); @@ -730,7 +729,7 @@ constexpr DAngle mapangle(int mapang) { return DAngle::fromBuild(mapang); } -inline fixedhoriz maphoriz(double maphoriz) +inline DAngle maphoriz(double maphoriz) { - return pitchhoriz(atan2(maphoriz, 128.) * (180. / pi::pi())); + return DAngle::fromDeg(atan2(maphoriz, 128.) * (180. / pi::pi())); } diff --git a/source/core/rendering/hw_entrypoint.cpp b/source/core/rendering/hw_entrypoint.cpp index c965f1679..faa6a8422 100644 --- a/source/core/rendering/hw_entrypoint.cpp +++ b/source/core/rendering/hw_entrypoint.cpp @@ -192,7 +192,7 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float // //=========================================================================== -FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int sectnum, DAngle angle, fixedhoriz horizon, DAngle rollang, float fov = -1) +FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int sectnum, DAngle angle, DAngle horizon, DAngle rollang, float fov = -1) { FRenderViewpoint r_viewpoint{}; r_viewpoint.CameraActor = cam; @@ -200,7 +200,7 @@ FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int s r_viewpoint.SectCount = sectnum; r_viewpoint.Pos = { position.X, -position.Y, -position.Z }; r_viewpoint.HWAngles.Yaw = FAngle::fromDeg(-90.f + (float)angle.Degrees()); - r_viewpoint.HWAngles.Pitch = FAngle::fromDeg(-ClampViewPitch(horizon.Degrees())); + r_viewpoint.HWAngles.Pitch = FAngle::fromDeg(-ClampViewPitch(horizon).Degrees()); r_viewpoint.HWAngles.Roll = FAngle::fromDeg(-(float)rollang.Degrees()); r_viewpoint.FieldOfView = FAngle::fromDeg(fov > 0? fov : (float)r_fov); r_viewpoint.RotAngle = angle.BAMs(); @@ -305,7 +305,7 @@ static void CheckTimer(FRenderState &state, uint64_t ShaderStartTime) void animatecamsprite(double s); -void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sectortype* sect, DAngle angle, fixedhoriz horizon, DAngle rollang, double interpfrac, float fov) +void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sectortype* sect, DAngle angle, DAngle horizon, DAngle rollang, double interpfrac, float fov) { checkRotatedWalls(); @@ -359,7 +359,7 @@ void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sector All.Unclock(); } -void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortype* sect, DAngle angle, fixedhoriz horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double interpfrac) +void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortype* sect, DAngle angle, DAngle horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double interpfrac) { updatesector(position, §); if (!sect) return; diff --git a/source/core/rendering/render.h b/source/core/rendering/render.h index 2706040c8..daa4d634c 100644 --- a/source/core/rendering/render.h +++ b/source/core/rendering/render.h @@ -5,8 +5,8 @@ class FSerializer; struct IntRect; -void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sectortype* sectnum, DAngle angle, fixedhoriz horizon, DAngle rollang, double interpfrac, float fov = -1); -void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortype* sect, DAngle angle, fixedhoriz horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double interpfrac); +void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sectortype* sectnum, DAngle angle, DAngle horizon, DAngle rollang, double interpfrac, float fov = -1); +void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortype* sect, DAngle angle, DAngle horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double interpfrac); struct PortalDesc { diff --git a/source/games/blood/src/blood.h b/source/games/blood/src/blood.h index 2f683e46a..80ca2e8ad 100644 --- a/source/games/blood/src/blood.h +++ b/source/games/blood/src/blood.h @@ -133,13 +133,13 @@ struct GameInterface : public ::GameInterface void LevelCompleted(MapRecord* map, int skill) override; bool DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, const DAngle cang, const DVector2& xydim, const double czoom, double const interpfrac) override; void SetTileProps(int til, int surf, int vox, int shade) override; - double playerPitchMin() override { return -54.575; } - double playerPitchMax() override { return 43.15; } + DAngle playerPitchMin() override { return DAngle::fromDeg(-54.575); } + DAngle playerPitchMax() override { return DAngle::fromDeg(43.15); } void WarpToCoords(double x, double y, double z, DAngle a) override; void ToggleThirdPerson() override; void SwitchCoopView() override; void ToggleShowWeapon() override; - DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 80., horiz.Tan() * 80.); } + DVector3 chaseCamPos(DAngle ang, DAngle horiz) { return DVector3(-ang.ToVector() * 80., horiz.Tan() * 80.); } void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override; void EnterPortal(DCoreActor* viewer, int type) override; void LeavePortal(DCoreActor* viewer, int type) override; diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index c90c86a4a..dbfbecd3e 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -819,7 +819,7 @@ void playerStart(int nPlayer, int bNewLevel) pPlayer->actor->xspr.health = pDudeInfo->startHealth << 4; pPlayer->actor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; pPlayer->bloodlust = 0; - pPlayer->horizon.horiz = pPlayer->horizon.horizoff = pitchhoriz(nullAngle.Degrees()); + pPlayer->horizon.horiz = pPlayer->horizon.horizoff = nullAngle; pPlayer->slope = 0; pPlayer->fragger = nullptr; pPlayer->underwaterTime = 1200; @@ -1556,7 +1556,7 @@ void ProcessInput(PLAYER* pPlayer) } pPlayer->deathTime += 4; if (!bSeqStat) - pPlayer->horizon.addadjustment(pitchhoriz(((1. - BobVal(ClipHigh(pPlayer->deathTime << 3, 1024) + 512)) * gi->playerPitchMax()) - pPlayer->horizon.horiz.Degrees())); + pPlayer->horizon.addadjustment(deltaangle(pPlayer->horizon.horiz, gi->playerPitchMax() * (1. - BobVal(ClipHigh(pPlayer->deathTime << 3, 1024) + 512)))); if (pPlayer->curWeapon) pInput->setNewWeapon(pPlayer->curWeapon); if (pInput->actions & SB_OPEN) diff --git a/source/games/blood/src/prediction.cpp b/source/games/blood/src/prediction.cpp index 2656e2b8d..8b01de279 100644 --- a/source/games/blood/src/prediction.cpp +++ b/source/games/blood/src/prediction.cpp @@ -246,9 +246,9 @@ static void fakeProcessInput(PLAYER* pPlayer, InputPacket* pInput) } else { - predict.horizoff = interpolatedvalue(predict.horizoff, pitchhoriz(nullAngle.Degrees()), 0x4000); + predict.horizoff = interpolatedvalue(predict.horizoff, nullAngle, 0x4000); if (abs(predict.horizoff.Degrees()) < 1.79) - predict.horizoff = pitchhoriz(nullAngle.Degrees()); + predict.horizoff = nullAngle; } predict.slope = -predict.horiz.Tan() * 16384.; #endif diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 94a5d538d..912124a7f 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -405,14 +405,14 @@ void viewUpdateDelirium(PLAYER* pPlayer) // //--------------------------------------------------------------------------- -void viewUpdateShake(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, fixedhoriz& cH, double& pshakeX, double& pshakeY) +void viewUpdateShake(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, DAngle& cH, double& pshakeX, double& pshakeY) { auto doEffect = [&](const int& effectType) { if (effectType) { int nValue = ClipHigh(effectType * 8, 2000); - cH += pitchhoriz(HorizToPitch(QRandom2F(nValue * (1. / 256.)))); + cH += maphoriz(QRandom2F(nValue * (1. / 256.))); cA += DAngle::fromBuildf(QRandom2F(nValue * (1. / 256.))); cPos.X += QRandom2F(nValue * inttoworld) * inttoworld; cPos.Y += QRandom2F(nValue * inttoworld) * inttoworld; @@ -456,7 +456,7 @@ static void DrawMap(PLAYER* pPlayer, const double interpfrac) // //--------------------------------------------------------------------------- -static void SetupView(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, fixedhoriz& cH, sectortype*& pSector, double& zDelta, double& shakeX, double& shakeY, DAngle& rotscrnang, const double interpfrac) +static void SetupView(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, DAngle& cH, sectortype*& pSector, double& zDelta, double& shakeX, double& shakeY, DAngle& rotscrnang, const double interpfrac) { double bobWidth, bobHeight; @@ -513,7 +513,7 @@ static void SetupView(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, fixedhoriz& c } viewUpdateShake(pPlayer, cPos, cA, cH, shakeX, shakeY); - cH += pitchhoriz((1 - BobVal((pPlayer->tiltEffect << 2) + 512)) * 13.2); + cH += DAngle::fromDeg((1 - BobVal((pPlayer->tiltEffect << 2) + 512)) * 13.2); if (gViewPos == 0) { if (cl_viewhbob) @@ -650,8 +650,7 @@ void viewDrawScreen(bool sceneonly) UpdateBlend(pPlayer); DVector3 cPos; - DAngle cA, rotscrnang; - fixedhoriz cH; + DAngle cA, rotscrnang, cH; sectortype* pSector; double zDelta; double shakeX, shakeY; @@ -735,7 +734,7 @@ void viewDrawScreen(bool sceneonly) } if (!sceneonly) hudDraw(pPlayer, pSector, shakeX, shakeY, zDelta, basepal, interpfrac); - fixedhoriz deliriumPitchI = interpolatedvalue(maphoriz(deliriumPitchO), maphoriz(deliriumPitch), interpfrac); + DAngle deliriumPitchI = interpolatedvalue(maphoriz(deliriumPitchO), maphoriz(deliriumPitch), interpfrac); auto bakCstat = pPlayer->actor->spr.cstat; pPlayer->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP; render_drawrooms(pPlayer->actor, cPos, pSector, cA, cH + deliriumPitchI, rotscrnang, interpfrac); diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index a8424f972..a772186e8 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1382,7 +1382,7 @@ static bool weaponhitsprite(DDukeActor* proj, DDukeActor *targ, bool fireball) if (proj->spr.picnum == SPIT) { - ps[p].horizon.addadjustment(pitchhoriz(14.04)); + ps[p].horizon.addadjustment(DAngle::fromDeg(14.04)); ps[p].sync.actions |= SB_CENTERVIEW; if (ps[p].loogcnt == 0) diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 5e51be1ab..fc7caae99 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1006,7 +1006,7 @@ static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const DVector3 & guts_r(proj, RABBITJIBC, 2, myconnectindex); } - ps[p].horizon.addadjustment(pitchhoriz(14.04)); + ps[p].horizon.addadjustment(DAngle::fromDeg(14.04)); ps[p].sync.actions |= SB_CENTERVIEW; if (ps[p].loogcnt == 0) diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 8c436cc61..87e1852f1 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -55,7 +55,7 @@ struct GameInterface : public ::GameInterface void ToggleThirdPerson() override; void SwitchCoopView() override; void ToggleShowWeapon() override; - DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 64., horiz.Tan() * 64.); } + DVector3 chaseCamPos(DAngle ang, DAngle horiz) { return DVector3(-ang.ToVector() * 64., horiz.Tan() * 64.); } void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override; void UpdateCameras(double smoothratio) override; void EnterPortal(DCoreActor* viewer, int type) override; diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 86c37c67a..a237924b2 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -925,7 +925,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, case PLAYER_RETURN_TO_CENTER: if (bSet) ps[iPlayer].sync.actions |= SB_CENTERVIEW; - else SetGameVarID(lVar2, ps[iPlayer].sync.actions & SB_CENTERVIEW ? abs(int(ps[iPlayer].horizon.horiz.Tan() * (9. / pitchhoriz(GetMaxPitch()).Tan()))) : 0, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].sync.actions & SB_CENTERVIEW ? int(abs((ps[iPlayer].horizon.horiz * (DAngle::fromDeg(9.) / GetMaxPitch())).Degrees())) : 0, sActor, sPlayer); break; default: @@ -2243,10 +2243,10 @@ int ParseState::parse(void) ps[g_p].last_extra = g_ac->spr.extra = gs.max_player_health; ps[g_p].wantweaponfire = -1; - ps[g_p].horizon.ohoriz = ps[g_p].horizon.horiz = pitchhoriz(nullAngle.Degrees()); + ps[g_p].horizon.ohoriz = ps[g_p].horizon.horiz = nullAngle; ps[g_p].on_crane = nullptr; ps[g_p].frag_ps = g_p; - ps[g_p].horizon.ohorizoff = ps[g_p].horizon.horizoff = pitchhoriz(nullAngle.Degrees()); + ps[g_p].horizon.ohorizoff = ps[g_p].horizon.horizoff = nullAngle; ps[g_p].opyoff = 0; ps[g_p].wackedbyactor = nullptr; ps[g_p].shield_amount = gs.max_armour_amount; diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 8424d37b1..bd175e853 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -117,7 +117,7 @@ void forceplayerangle(int snum) { player_struct* p = &ps[snum]; - p->horizon.addadjustment(pitchhoriz(26.566)); + p->horizon.addadjustment(DAngle::fromDeg(26.566)); p->sync.actions |= SB_CENTERVIEW; p->angle.rotscrnang = p->angle.look_ang = (DAngle22_5 - randomAngle(45)) / 2.; } @@ -374,7 +374,7 @@ void dokneeattack(int snum, const std::initializer_list & respawnlist) { p->oknee_incs = p->knee_incs; p->knee_incs++; - p->horizon.addadjustment(pitchhoriz(-20.556)); + p->horizon.addadjustment(DAngle::fromDeg(-20.556)); p->sync.actions |= SB_CENTERVIEW; if (p->knee_incs > 15) { @@ -619,7 +619,7 @@ void playerisdead(int snum, int psectlotag, double floorz, double ceilingz) backupplayer(p); - p->horizon.horizoff = p->horizon.horiz = pitchhoriz(nullAngle.Degrees()); + p->horizon.horizoff = p->horizon.horiz = nullAngle; updatesector(p->pos, &p->cursector); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index f4bac9d26..1e174c2da 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1515,7 +1515,7 @@ void checkweapons_r(player_struct* p) } p->OnMotorcycle = 0; p->gotweapon[MOTORCYCLE_WEAPON] = false; - p->horizon.horiz = pitchhoriz(nullAngle.Degrees()); + p->horizon.horiz = nullAngle; p->moto_do_bump = 0; p->MotoSpeed = 0; p->TiltStatus = 0; @@ -1534,7 +1534,7 @@ void checkweapons_r(player_struct* p) } p->OnBoat = 0; p->gotweapon[BOAT_WEAPON] = false; - p->horizon.horiz = pitchhoriz(nullAngle.Degrees()); + p->horizon.horiz = nullAngle; p->moto_do_bump = 0; p->MotoSpeed = 0; p->TiltStatus = 0; @@ -2962,7 +2962,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) case RIFLEGUN_WEAPON: p->kickback_pic++; - p->horizon.addadjustment(pitchhoriz(0.4476)); + p->horizon.addadjustment(DAngle::fromDeg(0.4476)); p->recoil++; if (p->kickback_pic <= 12) @@ -3134,7 +3134,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) else if (p->kickback_pic == 12) { p->vel.XY() -= p->angle.ang.ToVector(); - p->horizon.addadjustment(pitchhoriz(8.88)); + p->horizon.addadjustment(DAngle::fromDeg(8.88)); p->recoil += 20; } if (p->kickback_pic > 20) @@ -4044,7 +4044,7 @@ void OnMotorcycle(player_struct *p, DDukeActor* motosprite) p->gotweapon[MOTORCYCLE_WEAPON] = true; p->vel.X = 0; p->vel.Y = 0; - p->horizon.horiz = pitchhoriz(nullAngle.Degrees()); + p->horizon.settarget(nullAngle); } if (!S_CheckActorSoundPlaying(p->GetActor(),186)) S_PlayActorSound(186, p->GetActor()); @@ -4075,7 +4075,7 @@ void OffMotorcycle(player_struct *p) p->gotweapon[MOTORCYCLE_WEAPON] = false; p->curr_weapon = p->last_full_weapon; checkavailweapon(p); - p->horizon.horiz = pitchhoriz(nullAngle.Degrees()); + p->horizon.settarget(nullAngle); p->moto_do_bump = 0; p->MotoSpeed = 0; p->TiltStatus = 0; @@ -4119,7 +4119,7 @@ void OnBoat(player_struct *p, DDukeActor* boat) p->gotweapon[BOAT_WEAPON] = true; p->vel.X = 0; p->vel.Y = 0; - p->horizon.horiz = pitchhoriz(nullAngle.Degrees()); + p->horizon.settarget(nullAngle); } } @@ -4137,7 +4137,7 @@ void OffBoat(player_struct *p) p->gotweapon[BOAT_WEAPON] = false; p->curr_weapon = p->last_full_weapon; checkavailweapon(p); - p->horizon.horiz = pitchhoriz(nullAngle.Degrees()); + p->horizon.settarget(nullAngle); p->moto_do_bump = 0; p->MotoSpeed = 0; p->TiltStatus = 0; diff --git a/source/games/duke/src/prediction.cpp b/source/games/duke/src/prediction.cpp index 7b4e03814..c3fe7496f 100644 --- a/source/games/duke/src/prediction.cpp +++ b/source/games/duke/src/prediction.cpp @@ -40,7 +40,7 @@ DVector3 omypos, mypos; int myxvel, myyvel, myzvel; int globalskillsound; DAngle myang, omyang; -fixedhoriz myhoriz, omyhoriz, myhorizoff, omyhorizoff; +DAngle myhoriz, omyhoriz, myhorizoff, omyhorizoff; int mycursectnum, myjumpingcounter; uint8_t myjumpingtoggle, myonground, myhardlanding,myreturntocenter; int fakemovefifoplc; diff --git a/source/games/duke/src/prediction.h b/source/games/duke/src/prediction.h index ce9a5f605..5b966a196 100644 --- a/source/games/duke/src/prediction.h +++ b/source/games/duke/src/prediction.h @@ -7,7 +7,7 @@ extern int myxvel, myyvel, myzvel; extern int globalskillsound; extern int mycursectnum, myjumpingcounter; extern DAngle myang, omyang; -extern fixedhoriz myhoriz, omyhoriz, myhorizoff, omyhorizoff; +extern DAngle myhoriz, omyhoriz, myhorizoff, omyhorizoff; extern uint8_t myjumpingtoggle, myonground, myhardlanding,myreturntocenter; extern int fakemovefifoplc; extern int myxbak[MOVEFIFOSIZ], myybak[MOVEFIFOSIZ], myzbak[MOVEFIFOSIZ]; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 7a2635bd8..d88740177 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -151,8 +151,8 @@ void resetplayerstats(int snum) p->footprintpal = 0; p->footprintshade = 0; p->jumping_toggle = 0; - p->horizon.ohoriz = p->horizon.horiz = pitchhoriz(17.354); - p->horizon.ohorizoff = p->horizon.horizoff = pitchhoriz(nullAngle.Degrees()); + p->horizon.ohoriz = p->horizon.horiz = DAngle::fromDeg(17.354); + p->horizon.ohorizoff = p->horizon.horizoff = nullAngle; p->bobcounter = 0; p->on_ground = 0; p->player_par = 0; diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index 2c2542e77..7491f3715 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -217,8 +217,7 @@ static int getdrugmode(player_struct *p, int oyrepeat) void displayrooms(int snum, double interpfrac, bool sceneonly) { DVector3 cpos; - DAngle cang, rotscrnang; - fixedhoriz choriz; + DAngle cang, rotscrnang, choriz; player_struct* p = &ps[snum]; diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index a6163fd28..b781f8921 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -231,11 +231,11 @@ struct GameInterface : public ::GameInterface void LevelCompleted(MapRecord *map, int skill) override; void NextLevel(MapRecord *map, int skill) override; bool DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, const DAngle cang, const DVector2& xydim, const double czoom, double const interpfrac) override; - double playerPitchMin() override { return -49.5; } - double playerPitchMax() override { return 49.5; } + DAngle playerPitchMin() override { return DAngle::fromDeg(-49.5); } + DAngle playerPitchMax() override { return DAngle::fromDeg(49.5); } void WarpToCoords(double x, double y, double z, DAngle ang) override; void ToggleThirdPerson() override; - DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 96., horiz.Tan() * 96.); } + DVector3 chaseCamPos(DAngle ang, DAngle horiz) { return DVector3(-ang.ToVector() * 96., horiz.Tan() * 96.); } void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override; int GetCurrentSkill() override; std::pair GetCoordinates() override; diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index e43009eac..a9ddcea43 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -410,7 +410,7 @@ void RestartPlayer(int nPlayer) plr->nThrust.Zero(); - plr->nDestVertPan = plr->horizon.ohoriz = plr->horizon.horiz = pitchhoriz(nullAngle.Degrees()); + plr->nDestVertPan = plr->horizon.ohoriz = plr->horizon.horiz = nullAngle; plr->nBreathTimer = 90; plr->nTauntTimer = RandomSize(3) + 3; @@ -506,7 +506,7 @@ void StartDeathSeq(int nPlayer, int nVal) StopFiringWeapon(nPlayer); - PlayerList[nPlayer].horizon.ohoriz = PlayerList[nPlayer].horizon.horiz = pitchhoriz(nullAngle.Degrees()); + PlayerList[nPlayer].horizon.ohoriz = PlayerList[nPlayer].horizon.horiz = nullAngle; PlayerList[nPlayer].oeyelevel = PlayerList[nPlayer].eyelevel = -55; PlayerList[nPlayer].nInvisible = 0; dVertPan[nPlayer] = 15; @@ -1079,7 +1079,7 @@ void AIPlayer::Tick(RunListEvent* ev) PlayerList[nPlayer].angle.settarget(ang, true); pPlayerActor->spr.angle = ang; - PlayerList[nPlayer].horizon.settarget(pitchhoriz(nullAngle.Degrees()), true); + PlayerList[nPlayer].horizon.settarget(nullAngle, true); sPlayerInput[nPlayer].vel.Zero(); pPlayerActor->vel.Zero(); @@ -1091,7 +1091,7 @@ void AIPlayer::Tick(RunListEvent* ev) StopLocalSound(); InitSpiritHead(); - PlayerList[nPlayer].nDestVertPan = pitchhoriz(nullAngle.Degrees()); + PlayerList[nPlayer].nDestVertPan = nullAngle; PlayerList[nPlayer].horizon.settarget(currentLevel->ex_ramses_horiz); } } @@ -1119,7 +1119,7 @@ void AIPlayer::Tick(RunListEvent* ev) } if (zVelB > 2 && !PlayerList[nPlayer].horizon.horiz.Sgn() && cl_slopetilting) { - PlayerList[nPlayer].nDestVertPan = pitchhoriz(nullAngle.Degrees()); + PlayerList[nPlayer].nDestVertPan = nullAngle; } } @@ -2503,7 +2503,7 @@ sectdone: double nVertPan = (pPlayer->nDestVertPan - pPlayer->horizon.horiz).Degrees(); if (nVertPan != 0) { - pPlayer->horizon.addadjustment(pitchhoriz(abs(nVertPan) >= 1.79 ? clamp(nVertPan, -1.79, 1.79) : nVertPan * 2.)); + pPlayer->horizon.addadjustment(DAngle::fromDeg(abs(nVertPan) >= 1.79 ? clamp(nVertPan, -1.79, 1.79) : nVertPan * 2.)); } } } @@ -2623,7 +2623,7 @@ sectdone: { if (PlayerList[nPlayer].horizon.horiz.Sgn() < 0) { - PlayerList[nPlayer].horizon.settarget(pitchhoriz(nullAngle.Degrees())); + PlayerList[nPlayer].horizon.settarget(nullAngle); PlayerList[nPlayer].eyelevel -= dVertPan[nPlayer]; } else @@ -2632,7 +2632,7 @@ sectdone: if (PlayerList[nPlayer].horizon.horiz.Degrees() >= 38) { - PlayerList[nPlayer].horizon.settarget(pitchhoriz(37.72)); + PlayerList[nPlayer].horizon.settarget(DAngle::fromDeg(37.72)); } else if (PlayerList[nPlayer].horizon.horiz.Sgn() <= 0) { diff --git a/source/games/exhumed/src/player.h b/source/games/exhumed/src/player.h index 767218218..11f0307b0 100644 --- a/source/games/exhumed/src/player.h +++ b/source/games/exhumed/src/player.h @@ -76,7 +76,7 @@ struct Player int16_t nLastWeapon; int16_t nRun; bool bPlayerPan, bLockPan; - fixedhoriz nDestVertPan; + DAngle nDestVertPan; PlayerHorizon horizon; PlayerAngle angle; diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index 0c1a369c9..21e6c7a97 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -192,7 +192,7 @@ void DrawView(double interpfrac, bool sceneonly) int nEnemyPal = -1; sectortype* pSector = nullptr; DAngle nCameraang, rotscrnang; - fixedhoriz nCamerapan = pitchhoriz(nullAngle.Degrees()); + DAngle nCamerapan = nullAngle; DoInterpolations(interpfrac); @@ -259,7 +259,7 @@ void DrawView(double interpfrac, bool sceneonly) if (nSnakeCam >= 0 && !sceneonly) { - nCamerapan = pitchhoriz(nullAngle.Degrees()); + nCamerapan = nullAngle; } else { diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 6b21f0148..1b21eac98 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -1232,8 +1232,7 @@ void RestorePortalState() void drawscreen(PLAYER* pp, double interpfrac, bool sceneonly) { - DAngle tang, trotscrnang; - fixedhoriz thoriz; + DAngle tang, trotscrnang, thoriz; sectortype* tsect; // prediction player if prediction is on, else regular player diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 3518e5f4b..05b55e84e 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -593,7 +593,7 @@ struct PLAYER double recoil_amt; int16_t recoil_speed; int16_t recoil_ndx; - fixedhoriz recoil_ohorizoff, recoil_horizoff; + DAngle recoil_ohorizoff, recoil_horizoff; DVector3 Revolve; DAngle RevolveDeltaAng; @@ -1883,7 +1883,7 @@ struct GameInterface : public ::GameInterface void WarpToCoords(double x, double y, double z, DAngle ang) override; void ToggleThirdPerson() override; void SwitchCoopView() override; - DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 128., horiz.Tan() * 128.); } + DVector3 chaseCamPos(DAngle ang, DAngle horiz) { return DVector3(-ang.ToVector() * 128., horiz.Tan() * 128.); } void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double smoothRatio) override; void UpdateCameras(double smoothratio) override; void EnterPortal(DCoreActor* viewer, int type) override; diff --git a/source/games/sw/src/jsector.cpp b/source/games/sw/src/jsector.cpp index 4300136a7..4cff503cb 100644 --- a/source/games/sw/src/jsector.cpp +++ b/source/games/sw/src/jsector.cpp @@ -400,7 +400,7 @@ void JS_InitMirrors(void) ///////////////////////////////////////////////////// // Draw a 3d screen to a specific tile ///////////////////////////////////////////////////// -void drawroomstotile(const DVector3& pos, DAngle ang, fixedhoriz horiz, sectortype* dacursect, short tilenume, double smoothratio) +void drawroomstotile(const DVector3& pos, DAngle ang, DAngle horiz, sectortype* dacursect, short tilenume, double smoothratio) { auto canvas = tileGetCanvas(tilenume); if (!canvas) return; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 6106ad18d..77d8570ee 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1738,7 +1738,7 @@ void DoPlayerBeginRecoil(PLAYER* pp, double pix_amt) pp->recoil_amt = pix_amt; pp->recoil_speed = 80; pp->recoil_ndx = 0; - pp->recoil_ohorizoff = pp->recoil_horizoff = pitchhoriz(nullAngle.Degrees()); + pp->recoil_ohorizoff = pp->recoil_horizoff = nullAngle; } //--------------------------------------------------------------------------- @@ -1755,13 +1755,13 @@ void DoPlayerRecoil(PLAYER* pp) if (BobVal(pp->recoil_ndx) < 0) { pp->Flags &= ~(PF_RECOIL); - pp->recoil_ohorizoff = pp->recoil_horizoff = pitchhoriz(nullAngle.Degrees()); + pp->recoil_ohorizoff = pp->recoil_horizoff = nullAngle; return; } // move pp->q16horiz up and down pp->recoil_ohorizoff = pp->recoil_horizoff; - pp->recoil_horizoff = pitchhoriz(pp->recoil_amt * BobVal(pp->recoil_ndx)); + pp->recoil_horizoff = DAngle::fromDeg(pp->recoil_amt * BobVal(pp->recoil_ndx)); } //--------------------------------------------------------------------------- @@ -6008,12 +6008,12 @@ static void DoPlayerDeathHoriz(PLAYER* pp, double target, double speed) { if ((pp->horizon.horiz.Degrees() - target) > 0.4476) { - pp->horizon.addadjustment(pitchhoriz(-speed)); + pp->horizon.addadjustment(DAngle::fromDeg(-speed)); } if ((target - pp->horizon.horiz.Degrees()) > 0.4476) { - pp->horizon.addadjustment(pitchhoriz(speed)); + pp->horizon.addadjustment(DAngle::fromDeg(speed)); } } @@ -6161,7 +6161,7 @@ void DoPlayerDeathCheckKeys(PLAYER* pp) plActor->spr.xrepeat = PLAYER_NINJA_XREPEAT; plActor->spr.yrepeat = PLAYER_NINJA_YREPEAT; - pp->horizon.horiz = pitchhoriz(nullAngle.Degrees()); + pp->horizon.horiz = nullAngle; DoPlayerResetMovement(pp); plActor->user.ID = NINJA_RUN_R0; PlayerDeathReset(pp); @@ -7178,7 +7178,7 @@ void InitAllPlayers(void) extern bool NewGame; //int fz,cz; - pfirst->horizon.horiz = pitchhoriz(nullAngle.Degrees()); + pfirst->horizon.horiz = nullAngle; // Initialize all [MAX_SW_PLAYERS] arrays here! for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++) @@ -7222,7 +7222,7 @@ void InitAllPlayers(void) pp->FadeAmt = 0; pp->FadeTics = 0; pp->StartColor = 0; - pp->horizon.horizoff = pitchhoriz(nullAngle.Degrees()); + pp->horizon.horizoff = nullAngle; INITLIST(&pp->PanelSpriteList); } diff --git a/source/games/sw/src/predict.cpp b/source/games/sw/src/predict.cpp index 171962ede..566957b76 100644 --- a/source/games/sw/src/predict.cpp +++ b/source/games/sw/src/predict.cpp @@ -46,7 +46,7 @@ struct PREDICT { int x,y,z; DAngle ang; - fixedhoriz horiz; + // fixedhoriz horiz; short filler; }; diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 9120b6be5..d50f9a367 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -15384,7 +15384,7 @@ int InitTracerUzi(PLAYER* pp) // //--------------------------------------------------------------------------- -int InitTracerTurret(DSWActor* actor, DSWActor* Operator, fixedhoriz horiz) +int InitTracerTurret(DSWActor* actor, DSWActor* Operator, DAngle horiz) { // Spawn a shot // Inserting and setting up variables diff --git a/wadsrc/static/zscript/games/sw/swgame.zs b/wadsrc/static/zscript/games/sw/swgame.zs index 810163041..a9f195741 100644 --- a/wadsrc/static/zscript/games/sw/swgame.zs +++ b/wadsrc/static/zscript/games/sw/swgame.zs @@ -209,7 +209,7 @@ struct SWPlayer native native double recoil_amt; native int16 recoil_speed; native int16 recoil_ndx; - native int recoil_horizoff; + native double recoil_horizoff; native double RevolveDeltaAng;