- Cut over to DAngle from fixedhoriz and remove the latter.

This commit is contained in:
Mitchell Richters 2022-09-28 13:39:01 +10:00 committed by Christoph Oelckers
parent 0d8b2ba59d
commit 8d3f3c6025
35 changed files with 110 additions and 312 deletions

View file

@ -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 <math.h>
#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<class T>
constexpr fixedhoriz &operator*= (const T other)
{
value = value * other;
return *this;
}
template<class T>
constexpr fixedhoriz operator* (const T other) const
{
return value * other;
}
};
inline fixedhoriz pitchhoriz(double v) { return fixedhoriz(fixed_t(clamp<double>(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);
}

View file

@ -37,7 +37,7 @@ IntRect viewport3d;
double cameradist, cameraclock; 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; if (!*psect) return false;

View file

@ -4,7 +4,6 @@
#include "gamestruct.h" #include "gamestruct.h"
#include "build.h" #include "build.h"
#include "coreactor.h" #include "coreactor.h"
#include "fixedhorizon.h"
#include "intrect.h" #include "intrect.h"
#include "geometry.h" #include "geometry.h"
@ -268,7 +267,7 @@ extern double cameradist, cameraclock;
void loaddefinitionsfile(const char* fn, bool cumulative = false, bool maingrp = false); 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); int getslopeval(sectortype* sect, const DVector3& pos, double bazez);
bool cansee(const DVector3& start, sectortype* sect1, const DVector3& end, sectortype* sect2); 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); 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))); return g_sinbam(xs_CRoundToUInt(val * (1 << 21)));
} }
inline double GetMinPitch() inline DAngle GetMinPitch()
{ {
return gi->playerPitchMin(); return gi->playerPitchMin();
} }
inline double GetMaxPitch() inline DAngle GetMaxPitch()
{ {
return gi->playerPitchMax(); return gi->playerPitchMax();
} }
inline double ClampViewPitch(const double pitch) inline DAngle ClampViewPitch(const DAngle pitch)
{ {
return clamp(pitch, GetMinPitch(), GetMaxPitch()); return clamp(pitch, GetMinPitch(), GetMaxPitch());
} }

View file

@ -176,14 +176,11 @@ void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double cons
// Test if we have input to process. // Test if we have input to process.
if (horz || *actions & (SB_AIM_UP | SB_AIM_DOWN | SB_LOOK_UP | SB_LOOK_DOWN | SB_CENTERVIEW)) 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. // Process mouse input.
if (horz) if (horz)
{ {
*actions &= ~SB_CENTERVIEW; *actions &= ~SB_CENTERVIEW;
pitch += horz; horiz += DAngle::fromDeg(horz);
} }
// Process keyboard input. // Process keyboard input.
@ -192,27 +189,20 @@ void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double cons
if (*actions & (up | down)) if (*actions & (up | down))
{ {
if (lock) *actions &= ~SB_CENTERVIEW; else *actions |= SB_CENTERVIEW; 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_AIM_UP, SB_AIM_DOWN, PITCH_AIMSPEED, true);
doKbdInput(SB_LOOK_UP, SB_LOOK_DOWN, PITCH_LOOKSPEED, false); 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))) if ((*actions & SB_CENTERVIEW) && !(*actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
{ {
scaletozero(tmpangle, PITCH_CENTRESPEED * (PITCH_CNTRSINEOFFSET - abs(tmpangle)).Sin(), scaleAdjust); scaletozero(horiz, PITCH_CENTRESPEED * (PITCH_CNTRSINEOFFSET - abs(horiz)).Sin(), scaleAdjust);
if (!tmpangle.Sgn()) if (!horiz.Sgn()) *actions &= ~SB_CENTERVIEW;
{
tmpangle = nullAngle;
*actions &= ~SB_CENTERVIEW;
}
} }
// clamp before converting back to horizon // clamp before converting back to horizon
horiz = pitchhoriz(ClampViewPitch(tmpangle.Degrees())); horiz = ClampViewPitch(horiz);
} }
} }
else else
@ -295,9 +285,6 @@ void PlayerHorizon::calcviewpitch(const DVector2& pos, DAngle const ang, bool co
{ {
if (cl_slopetilting && cursectnum != nullptr) if (cl_slopetilting && cursectnum != nullptr)
{ {
// Temporarily hold horizoff as pitch.
auto tmpangle = DAngle::fromDeg(horizoff.Degrees());
if (aimmode && canslopetilt) // If the floor is sloped if (aimmode && canslopetilt) // If the floor is sloped
{ {
// Get a point, 512 (64 for Blood) units ahead of player's position // 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 // accordingly
if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslopeptr(tempsect, rotpt) - k) <= 4)) 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) if (climbing)
{ {
// tilt when climbing but you can't even really tell it. // 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 else
{ {
// Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope. // 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. // Clamp off against the maximum allowed pitch.
horizoff = pitchhoriz(ClampViewPitch(tmpangle.Degrees())); horizoff = ClampViewPitch(horizoff);
} }
} }

View file

@ -1,7 +1,6 @@
#pragma once #pragma once
#include "m_fixed.h" #include "m_fixed.h"
#include "fixedhorizon.h"
#include "gamecvars.h" #include "gamecvars.h"
#include "gamestruct.h" #include "gamestruct.h"
#include "gamefuncs.h" #include "gamefuncs.h"
@ -9,7 +8,7 @@
struct PlayerHorizon struct PlayerHorizon
{ {
fixedhoriz horiz, ohoriz, horizoff, ohorizoff; DAngle horiz, ohoriz, horizoff, ohorizoff;
friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w, PlayerHorizon* def); friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w, PlayerHorizon* def);
@ -30,12 +29,12 @@ struct PlayerHorizon
} }
// Commonly used getters. // Commonly used getters.
fixedhoriz osum() { return ohoriz + ohorizoff; } DAngle osum() { return ohoriz + ohorizoff; }
fixedhoriz sum() { return horiz + horizoff; } DAngle sum() { return horiz + horizoff; }
fixedhoriz interpolatedsum(double const interpfrac) { return interpolatedvalue(osum(), sum(), interpfrac); } DAngle interpolatedsum(double const interpfrac) { return interpolatedvalue(osum(), sum(), interpfrac); }
// Ticrate playsim adjustment helpers. // Ticrate playsim adjustment helpers.
void resetadjustment() { adjustment = 0; } void resetadjustment() { adjustment = nullAngle; }
bool targetset() { return target.Sgn(); } bool targetset() { return target.Sgn(); }
// Input locking helpers. // Input locking helpers.
@ -47,11 +46,11 @@ struct PlayerHorizon
double horizsumfrac(double const interpfrac) { return (!SyncInput() ? sum() : interpolatedsum(interpfrac)).Tan() * 8.; } double horizsumfrac(double const interpfrac) { return (!SyncInput() ? sum() : interpolatedsum(interpfrac)).Tan() * 8.; }
// Ticrate playsim adjustment setters and processor. // Ticrate playsim adjustment setters and processor.
void addadjustment(fixedhoriz const value) void addadjustment(DAngle const value)
{ {
if (!SyncInput()) if (!SyncInput())
{ {
adjustment += value.Degrees(); adjustment += value;
} }
else 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. // Clamp incoming variable because sometimes the caller can exceed bounds.
value = pitchhoriz(ClampViewPitch(value.Degrees())); value = ClampViewPitch(value);
if (!SyncInput() && !backup) if (!SyncInput() && !backup)
{ {
target = value.Sgn() ? value : pitchhoriz(minAngle.Degrees()); target = value.Sgn() ? value : minAngle;
} }
else else
{ {
@ -79,27 +78,26 @@ struct PlayerHorizon
{ {
if (targetset()) 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 else
{ {
horiz = target; horiz = target;
target = pitchhoriz(nullAngle.Degrees()); target = nullAngle;
} }
} }
else if (adjustment) else if (adjustment.Sgn())
{ {
horiz += pitchhoriz(scaleAdjust * adjustment); horiz += adjustment * scaleAdjust;
} }
} }
private: private:
fixedhoriz target; DAngle target, adjustment;
double adjustment;
bool inputdisabled; bool inputdisabled;
}; };
@ -165,7 +163,7 @@ struct PlayerAngle
{ {
if (!SyncInput() && !backup) if (!SyncInput() && !backup)
{ {
target = value.Sgn() ? value : DAngle::fromBam(1); target = value.Sgn() ? value : minAngle;
} }
else else
{ {

View file

@ -7,7 +7,7 @@ bool System_WantGuiCapture(); // During playing this tells us whether the game m
#include "engineerrors.h" #include "engineerrors.h"
#include "stats.h" #include "stats.h"
#include "packet.h" #include "packet.h"
#include "fixedhorizon.h" #include "serializer.h"
#include "inputstate.h" #include "inputstate.h"
#include "maptypes.h" #include "maptypes.h"
@ -109,13 +109,13 @@ struct GameInterface
virtual void LevelCompleted(MapRecord* map, int skill) {} 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 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 void SetTileProps(int tile, int surf, int vox, int shade) {}
virtual double playerPitchMin() { return -57.375; } virtual DAngle playerPitchMin() { return DAngle::fromDeg(-57.375); }
virtual double playerPitchMax() { return 57.375; } virtual DAngle playerPitchMax() { return DAngle::fromDeg(57.375); }
virtual void WarpToCoords(double x, double y, double z, DAngle a) {} virtual void WarpToCoords(double x, double y, double z, DAngle a) {}
virtual void ToggleThirdPerson() { } virtual void ToggleThirdPerson() { }
virtual void SwitchCoopView() { Printf("Unsupported command\n"); } virtual void SwitchCoopView() { Printf("Unsupported command\n"); }
virtual void ToggleShowWeapon() { 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 processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) = 0;
virtual void UpdateCameras(double smoothratio) {} virtual void UpdateCameras(double smoothratio) {}
virtual void EnterPortal(DCoreActor* viewer, int type) {} virtual void EnterPortal(DCoreActor* viewer, int type) {}

View file

@ -149,7 +149,7 @@ struct MapRecord
// game specific stuff // game specific stuff
int rr_startsound = 0; int rr_startsound = 0;
int rr_mamaspawn = 15; 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! int ex_ramses_cdtrack = -1; // this is not music, it is the actual dialogue!
FString ex_ramses_pup; FString ex_ramses_pup;
FString ex_ramses_text; FString ex_ramses_text;

View file

@ -32,7 +32,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
#include "tflags.h" #include "tflags.h"
#include "intvec.h" #include "intvec.h"
#include "dobject.h" #include "dobject.h"
#include "fixedhorizon.h"
void MarkVerticesForSector(int sector); void MarkVerticesForSector(int sector);
@ -730,7 +729,7 @@ constexpr DAngle mapangle(int mapang)
{ {
return DAngle::fromBuild(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()));
} }

View file

@ -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{}; FRenderViewpoint r_viewpoint{};
r_viewpoint.CameraActor = cam; r_viewpoint.CameraActor = cam;
@ -200,7 +200,7 @@ FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int s
r_viewpoint.SectCount = sectnum; r_viewpoint.SectCount = sectnum;
r_viewpoint.Pos = { position.X, -position.Y, -position.Z }; r_viewpoint.Pos = { position.X, -position.Y, -position.Z };
r_viewpoint.HWAngles.Yaw = FAngle::fromDeg(-90.f + (float)angle.Degrees()); 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.HWAngles.Roll = FAngle::fromDeg(-(float)rollang.Degrees());
r_viewpoint.FieldOfView = FAngle::fromDeg(fov > 0? fov : (float)r_fov); r_viewpoint.FieldOfView = FAngle::fromDeg(fov > 0? fov : (float)r_fov);
r_viewpoint.RotAngle = angle.BAMs(); r_viewpoint.RotAngle = angle.BAMs();
@ -305,7 +305,7 @@ static void CheckTimer(FRenderState &state, uint64_t ShaderStartTime)
void animatecamsprite(double s); 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(); checkRotatedWalls();
@ -359,7 +359,7 @@ void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sector
All.Unclock(); 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, &sect); updatesector(position, &sect);
if (!sect) return; if (!sect) return;

View file

@ -5,8 +5,8 @@
class FSerializer; class FSerializer;
struct IntRect; 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_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, 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);
struct PortalDesc struct PortalDesc
{ {

View file

@ -133,13 +133,13 @@ struct GameInterface : public ::GameInterface
void LevelCompleted(MapRecord* map, int skill) override; 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; 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; void SetTileProps(int til, int surf, int vox, int shade) override;
double playerPitchMin() override { return -54.575; } DAngle playerPitchMin() override { return DAngle::fromDeg(-54.575); }
double playerPitchMax() override { return 43.15; } DAngle playerPitchMax() override { return DAngle::fromDeg(43.15); }
void WarpToCoords(double x, double y, double z, DAngle a) override; void WarpToCoords(double x, double y, double z, DAngle a) override;
void ToggleThirdPerson() override; void ToggleThirdPerson() override;
void SwitchCoopView() override; void SwitchCoopView() override;
void ToggleShowWeapon() 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 processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override;
void EnterPortal(DCoreActor* viewer, int type) override; void EnterPortal(DCoreActor* viewer, int type) override;
void LeavePortal(DCoreActor* viewer, int type) override; void LeavePortal(DCoreActor* viewer, int type) override;

View file

@ -819,7 +819,7 @@ void playerStart(int nPlayer, int bNewLevel)
pPlayer->actor->xspr.health = pDudeInfo->startHealth << 4; pPlayer->actor->xspr.health = pDudeInfo->startHealth << 4;
pPlayer->actor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; pPlayer->actor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
pPlayer->bloodlust = 0; pPlayer->bloodlust = 0;
pPlayer->horizon.horiz = pPlayer->horizon.horizoff = pitchhoriz(nullAngle.Degrees()); pPlayer->horizon.horiz = pPlayer->horizon.horizoff = nullAngle;
pPlayer->slope = 0; pPlayer->slope = 0;
pPlayer->fragger = nullptr; pPlayer->fragger = nullptr;
pPlayer->underwaterTime = 1200; pPlayer->underwaterTime = 1200;
@ -1556,7 +1556,7 @@ void ProcessInput(PLAYER* pPlayer)
} }
pPlayer->deathTime += 4; pPlayer->deathTime += 4;
if (!bSeqStat) 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) if (pPlayer->curWeapon)
pInput->setNewWeapon(pPlayer->curWeapon); pInput->setNewWeapon(pPlayer->curWeapon);
if (pInput->actions & SB_OPEN) if (pInput->actions & SB_OPEN)

View file

@ -246,9 +246,9 @@ static void fakeProcessInput(PLAYER* pPlayer, InputPacket* pInput)
} }
else else
{ {
predict.horizoff = interpolatedvalue(predict.horizoff, pitchhoriz(nullAngle.Degrees()), 0x4000); predict.horizoff = interpolatedvalue(predict.horizoff, nullAngle, 0x4000);
if (abs(predict.horizoff.Degrees()) < 1.79) if (abs(predict.horizoff.Degrees()) < 1.79)
predict.horizoff = pitchhoriz(nullAngle.Degrees()); predict.horizoff = nullAngle;
} }
predict.slope = -predict.horiz.Tan() * 16384.; predict.slope = -predict.horiz.Tan() * 16384.;
#endif #endif

View file

@ -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) auto doEffect = [&](const int& effectType)
{ {
if (effectType) if (effectType)
{ {
int nValue = ClipHigh(effectType * 8, 2000); 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.))); cA += DAngle::fromBuildf(QRandom2F(nValue * (1. / 256.)));
cPos.X += QRandom2F(nValue * inttoworld) * inttoworld; cPos.X += QRandom2F(nValue * inttoworld) * inttoworld;
cPos.Y += 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; 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); 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 (gViewPos == 0)
{ {
if (cl_viewhbob) if (cl_viewhbob)
@ -650,8 +650,7 @@ void viewDrawScreen(bool sceneonly)
UpdateBlend(pPlayer); UpdateBlend(pPlayer);
DVector3 cPos; DVector3 cPos;
DAngle cA, rotscrnang; DAngle cA, rotscrnang, cH;
fixedhoriz cH;
sectortype* pSector; sectortype* pSector;
double zDelta; double zDelta;
double shakeX, shakeY; double shakeX, shakeY;
@ -735,7 +734,7 @@ void viewDrawScreen(bool sceneonly)
} }
if (!sceneonly) hudDraw(pPlayer, pSector, shakeX, shakeY, zDelta, basepal, interpfrac); 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; auto bakCstat = pPlayer->actor->spr.cstat;
pPlayer->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP; 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); render_drawrooms(pPlayer->actor, cPos, pSector, cA, cH + deliriumPitchI, rotscrnang, interpfrac);

View file

@ -1382,7 +1382,7 @@ static bool weaponhitsprite(DDukeActor* proj, DDukeActor *targ, bool fireball)
if (proj->spr.picnum == SPIT) 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; ps[p].sync.actions |= SB_CENTERVIEW;
if (ps[p].loogcnt == 0) if (ps[p].loogcnt == 0)

View file

@ -1006,7 +1006,7 @@ static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const DVector3 &
guts_r(proj, RABBITJIBC, 2, myconnectindex); 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; ps[p].sync.actions |= SB_CENTERVIEW;
if (ps[p].loogcnt == 0) if (ps[p].loogcnt == 0)

View file

@ -55,7 +55,7 @@ struct GameInterface : public ::GameInterface
void ToggleThirdPerson() override; void ToggleThirdPerson() override;
void SwitchCoopView() override; void SwitchCoopView() override;
void ToggleShowWeapon() 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 processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override;
void UpdateCameras(double smoothratio) override; void UpdateCameras(double smoothratio) override;
void EnterPortal(DCoreActor* viewer, int type) override; void EnterPortal(DCoreActor* viewer, int type) override;

View file

@ -925,7 +925,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
case PLAYER_RETURN_TO_CENTER: case PLAYER_RETURN_TO_CENTER:
if (bSet) ps[iPlayer].sync.actions |= SB_CENTERVIEW; 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; break;
default: 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].last_extra = g_ac->spr.extra = gs.max_player_health;
ps[g_p].wantweaponfire = -1; 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].on_crane = nullptr;
ps[g_p].frag_ps = g_p; 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].opyoff = 0;
ps[g_p].wackedbyactor = nullptr; ps[g_p].wackedbyactor = nullptr;
ps[g_p].shield_amount = gs.max_armour_amount; ps[g_p].shield_amount = gs.max_armour_amount;

View file

@ -117,7 +117,7 @@ void forceplayerangle(int snum)
{ {
player_struct* p = &ps[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->sync.actions |= SB_CENTERVIEW;
p->angle.rotscrnang = p->angle.look_ang = (DAngle22_5 - randomAngle(45)) / 2.; p->angle.rotscrnang = p->angle.look_ang = (DAngle22_5 - randomAngle(45)) / 2.;
} }
@ -374,7 +374,7 @@ void dokneeattack(int snum, const std::initializer_list<int> & respawnlist)
{ {
p->oknee_incs = p->knee_incs; p->oknee_incs = p->knee_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; p->sync.actions |= SB_CENTERVIEW;
if (p->knee_incs > 15) if (p->knee_incs > 15)
{ {
@ -619,7 +619,7 @@ void playerisdead(int snum, int psectlotag, double floorz, double ceilingz)
backupplayer(p); backupplayer(p);
p->horizon.horizoff = p->horizon.horiz = pitchhoriz(nullAngle.Degrees()); p->horizon.horizoff = p->horizon.horiz = nullAngle;
updatesector(p->pos, &p->cursector); updatesector(p->pos, &p->cursector);

View file

@ -1515,7 +1515,7 @@ void checkweapons_r(player_struct* p)
} }
p->OnMotorcycle = 0; p->OnMotorcycle = 0;
p->gotweapon[MOTORCYCLE_WEAPON] = false; p->gotweapon[MOTORCYCLE_WEAPON] = false;
p->horizon.horiz = pitchhoriz(nullAngle.Degrees()); p->horizon.horiz = nullAngle;
p->moto_do_bump = 0; p->moto_do_bump = 0;
p->MotoSpeed = 0; p->MotoSpeed = 0;
p->TiltStatus = 0; p->TiltStatus = 0;
@ -1534,7 +1534,7 @@ void checkweapons_r(player_struct* p)
} }
p->OnBoat = 0; p->OnBoat = 0;
p->gotweapon[BOAT_WEAPON] = false; p->gotweapon[BOAT_WEAPON] = false;
p->horizon.horiz = pitchhoriz(nullAngle.Degrees()); p->horizon.horiz = nullAngle;
p->moto_do_bump = 0; p->moto_do_bump = 0;
p->MotoSpeed = 0; p->MotoSpeed = 0;
p->TiltStatus = 0; p->TiltStatus = 0;
@ -2962,7 +2962,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
case RIFLEGUN_WEAPON: case RIFLEGUN_WEAPON:
p->kickback_pic++; p->kickback_pic++;
p->horizon.addadjustment(pitchhoriz(0.4476)); p->horizon.addadjustment(DAngle::fromDeg(0.4476));
p->recoil++; p->recoil++;
if (p->kickback_pic <= 12) if (p->kickback_pic <= 12)
@ -3134,7 +3134,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
else if (p->kickback_pic == 12) else if (p->kickback_pic == 12)
{ {
p->vel.XY() -= p->angle.ang.ToVector(); p->vel.XY() -= p->angle.ang.ToVector();
p->horizon.addadjustment(pitchhoriz(8.88)); p->horizon.addadjustment(DAngle::fromDeg(8.88));
p->recoil += 20; p->recoil += 20;
} }
if (p->kickback_pic > 20) if (p->kickback_pic > 20)
@ -4044,7 +4044,7 @@ void OnMotorcycle(player_struct *p, DDukeActor* motosprite)
p->gotweapon[MOTORCYCLE_WEAPON] = true; p->gotweapon[MOTORCYCLE_WEAPON] = true;
p->vel.X = 0; p->vel.X = 0;
p->vel.Y = 0; p->vel.Y = 0;
p->horizon.horiz = pitchhoriz(nullAngle.Degrees()); p->horizon.settarget(nullAngle);
} }
if (!S_CheckActorSoundPlaying(p->GetActor(),186)) if (!S_CheckActorSoundPlaying(p->GetActor(),186))
S_PlayActorSound(186, p->GetActor()); S_PlayActorSound(186, p->GetActor());
@ -4075,7 +4075,7 @@ void OffMotorcycle(player_struct *p)
p->gotweapon[MOTORCYCLE_WEAPON] = false; p->gotweapon[MOTORCYCLE_WEAPON] = false;
p->curr_weapon = p->last_full_weapon; p->curr_weapon = p->last_full_weapon;
checkavailweapon(p); checkavailweapon(p);
p->horizon.horiz = pitchhoriz(nullAngle.Degrees()); p->horizon.settarget(nullAngle);
p->moto_do_bump = 0; p->moto_do_bump = 0;
p->MotoSpeed = 0; p->MotoSpeed = 0;
p->TiltStatus = 0; p->TiltStatus = 0;
@ -4119,7 +4119,7 @@ void OnBoat(player_struct *p, DDukeActor* boat)
p->gotweapon[BOAT_WEAPON] = true; p->gotweapon[BOAT_WEAPON] = true;
p->vel.X = 0; p->vel.X = 0;
p->vel.Y = 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->gotweapon[BOAT_WEAPON] = false;
p->curr_weapon = p->last_full_weapon; p->curr_weapon = p->last_full_weapon;
checkavailweapon(p); checkavailweapon(p);
p->horizon.horiz = pitchhoriz(nullAngle.Degrees()); p->horizon.settarget(nullAngle);
p->moto_do_bump = 0; p->moto_do_bump = 0;
p->MotoSpeed = 0; p->MotoSpeed = 0;
p->TiltStatus = 0; p->TiltStatus = 0;

View file

@ -40,7 +40,7 @@ DVector3 omypos, mypos;
int myxvel, myyvel, myzvel; int myxvel, myyvel, myzvel;
int globalskillsound; int globalskillsound;
DAngle myang, omyang; DAngle myang, omyang;
fixedhoriz myhoriz, omyhoriz, myhorizoff, omyhorizoff; DAngle myhoriz, omyhoriz, myhorizoff, omyhorizoff;
int mycursectnum, myjumpingcounter; int mycursectnum, myjumpingcounter;
uint8_t myjumpingtoggle, myonground, myhardlanding,myreturntocenter; uint8_t myjumpingtoggle, myonground, myhardlanding,myreturntocenter;
int fakemovefifoplc; int fakemovefifoplc;

View file

@ -7,7 +7,7 @@ extern int myxvel, myyvel, myzvel;
extern int globalskillsound; extern int globalskillsound;
extern int mycursectnum, myjumpingcounter; extern int mycursectnum, myjumpingcounter;
extern DAngle myang, omyang; extern DAngle myang, omyang;
extern fixedhoriz myhoriz, omyhoriz, myhorizoff, omyhorizoff; extern DAngle myhoriz, omyhoriz, myhorizoff, omyhorizoff;
extern uint8_t myjumpingtoggle, myonground, myhardlanding,myreturntocenter; extern uint8_t myjumpingtoggle, myonground, myhardlanding,myreturntocenter;
extern int fakemovefifoplc; extern int fakemovefifoplc;
extern int myxbak[MOVEFIFOSIZ], myybak[MOVEFIFOSIZ], myzbak[MOVEFIFOSIZ]; extern int myxbak[MOVEFIFOSIZ], myybak[MOVEFIFOSIZ], myzbak[MOVEFIFOSIZ];

View file

@ -151,8 +151,8 @@ void resetplayerstats(int snum)
p->footprintpal = 0; p->footprintpal = 0;
p->footprintshade = 0; p->footprintshade = 0;
p->jumping_toggle = 0; p->jumping_toggle = 0;
p->horizon.ohoriz = p->horizon.horiz = pitchhoriz(17.354); p->horizon.ohoriz = p->horizon.horiz = DAngle::fromDeg(17.354);
p->horizon.ohorizoff = p->horizon.horizoff = pitchhoriz(nullAngle.Degrees()); p->horizon.ohorizoff = p->horizon.horizoff = nullAngle;
p->bobcounter = 0; p->bobcounter = 0;
p->on_ground = 0; p->on_ground = 0;
p->player_par = 0; p->player_par = 0;

View file

@ -217,8 +217,7 @@ static int getdrugmode(player_struct *p, int oyrepeat)
void displayrooms(int snum, double interpfrac, bool sceneonly) void displayrooms(int snum, double interpfrac, bool sceneonly)
{ {
DVector3 cpos; DVector3 cpos;
DAngle cang, rotscrnang; DAngle cang, rotscrnang, choriz;
fixedhoriz choriz;
player_struct* p = &ps[snum]; player_struct* p = &ps[snum];

View file

@ -231,11 +231,11 @@ struct GameInterface : public ::GameInterface
void LevelCompleted(MapRecord *map, int skill) override; void LevelCompleted(MapRecord *map, int skill) override;
void NextLevel(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; 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; } DAngle playerPitchMin() override { return DAngle::fromDeg(-49.5); }
double playerPitchMax() override { return 49.5; } DAngle playerPitchMax() override { return DAngle::fromDeg(49.5); }
void WarpToCoords(double x, double y, double z, DAngle ang) override; void WarpToCoords(double x, double y, double z, DAngle ang) override;
void ToggleThirdPerson() 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; void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override;
int GetCurrentSkill() override; int GetCurrentSkill() override;
std::pair<DVector3, DAngle> GetCoordinates() override; std::pair<DVector3, DAngle> GetCoordinates() override;

View file

@ -410,7 +410,7 @@ void RestartPlayer(int nPlayer)
plr->nThrust.Zero(); 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->nBreathTimer = 90;
plr->nTauntTimer = RandomSize(3) + 3; plr->nTauntTimer = RandomSize(3) + 3;
@ -506,7 +506,7 @@ void StartDeathSeq(int nPlayer, int nVal)
StopFiringWeapon(nPlayer); 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].oeyelevel = PlayerList[nPlayer].eyelevel = -55;
PlayerList[nPlayer].nInvisible = 0; PlayerList[nPlayer].nInvisible = 0;
dVertPan[nPlayer] = 15; dVertPan[nPlayer] = 15;
@ -1079,7 +1079,7 @@ void AIPlayer::Tick(RunListEvent* ev)
PlayerList[nPlayer].angle.settarget(ang, true); PlayerList[nPlayer].angle.settarget(ang, true);
pPlayerActor->spr.angle = ang; pPlayerActor->spr.angle = ang;
PlayerList[nPlayer].horizon.settarget(pitchhoriz(nullAngle.Degrees()), true); PlayerList[nPlayer].horizon.settarget(nullAngle, true);
sPlayerInput[nPlayer].vel.Zero(); sPlayerInput[nPlayer].vel.Zero();
pPlayerActor->vel.Zero(); pPlayerActor->vel.Zero();
@ -1091,7 +1091,7 @@ void AIPlayer::Tick(RunListEvent* ev)
StopLocalSound(); StopLocalSound();
InitSpiritHead(); InitSpiritHead();
PlayerList[nPlayer].nDestVertPan = pitchhoriz(nullAngle.Degrees()); PlayerList[nPlayer].nDestVertPan = nullAngle;
PlayerList[nPlayer].horizon.settarget(currentLevel->ex_ramses_horiz); 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) { 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(); double nVertPan = (pPlayer->nDestVertPan - pPlayer->horizon.horiz).Degrees();
if (nVertPan != 0) 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) if (PlayerList[nPlayer].horizon.horiz.Sgn() < 0)
{ {
PlayerList[nPlayer].horizon.settarget(pitchhoriz(nullAngle.Degrees())); PlayerList[nPlayer].horizon.settarget(nullAngle);
PlayerList[nPlayer].eyelevel -= dVertPan[nPlayer]; PlayerList[nPlayer].eyelevel -= dVertPan[nPlayer];
} }
else else
@ -2632,7 +2632,7 @@ sectdone:
if (PlayerList[nPlayer].horizon.horiz.Degrees() >= 38) 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) else if (PlayerList[nPlayer].horizon.horiz.Sgn() <= 0)
{ {

View file

@ -76,7 +76,7 @@ struct Player
int16_t nLastWeapon; int16_t nLastWeapon;
int16_t nRun; int16_t nRun;
bool bPlayerPan, bLockPan; bool bPlayerPan, bLockPan;
fixedhoriz nDestVertPan; DAngle nDestVertPan;
PlayerHorizon horizon; PlayerHorizon horizon;
PlayerAngle angle; PlayerAngle angle;

View file

@ -192,7 +192,7 @@ void DrawView(double interpfrac, bool sceneonly)
int nEnemyPal = -1; int nEnemyPal = -1;
sectortype* pSector = nullptr; sectortype* pSector = nullptr;
DAngle nCameraang, rotscrnang; DAngle nCameraang, rotscrnang;
fixedhoriz nCamerapan = pitchhoriz(nullAngle.Degrees()); DAngle nCamerapan = nullAngle;
DoInterpolations(interpfrac); DoInterpolations(interpfrac);
@ -259,7 +259,7 @@ void DrawView(double interpfrac, bool sceneonly)
if (nSnakeCam >= 0 && !sceneonly) if (nSnakeCam >= 0 && !sceneonly)
{ {
nCamerapan = pitchhoriz(nullAngle.Degrees()); nCamerapan = nullAngle;
} }
else else
{ {

View file

@ -1232,8 +1232,7 @@ void RestorePortalState()
void drawscreen(PLAYER* pp, double interpfrac, bool sceneonly) void drawscreen(PLAYER* pp, double interpfrac, bool sceneonly)
{ {
DAngle tang, trotscrnang; DAngle tang, trotscrnang, thoriz;
fixedhoriz thoriz;
sectortype* tsect; sectortype* tsect;
// prediction player if prediction is on, else regular player // prediction player if prediction is on, else regular player

View file

@ -593,7 +593,7 @@ struct PLAYER
double recoil_amt; double recoil_amt;
int16_t recoil_speed; int16_t recoil_speed;
int16_t recoil_ndx; int16_t recoil_ndx;
fixedhoriz recoil_ohorizoff, recoil_horizoff; DAngle recoil_ohorizoff, recoil_horizoff;
DVector3 Revolve; DVector3 Revolve;
DAngle RevolveDeltaAng; DAngle RevolveDeltaAng;
@ -1883,7 +1883,7 @@ struct GameInterface : public ::GameInterface
void WarpToCoords(double x, double y, double z, DAngle ang) override; void WarpToCoords(double x, double y, double z, DAngle ang) override;
void ToggleThirdPerson() override; void ToggleThirdPerson() override;
void SwitchCoopView() 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 processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double smoothRatio) override;
void UpdateCameras(double smoothratio) override; void UpdateCameras(double smoothratio) override;
void EnterPortal(DCoreActor* viewer, int type) override; void EnterPortal(DCoreActor* viewer, int type) override;

View file

@ -400,7 +400,7 @@ void JS_InitMirrors(void)
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
// Draw a 3d screen to a specific tile // 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); auto canvas = tileGetCanvas(tilenume);
if (!canvas) return; if (!canvas) return;

View file

@ -1738,7 +1738,7 @@ void DoPlayerBeginRecoil(PLAYER* pp, double pix_amt)
pp->recoil_amt = pix_amt; pp->recoil_amt = pix_amt;
pp->recoil_speed = 80; pp->recoil_speed = 80;
pp->recoil_ndx = 0; 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) if (BobVal(pp->recoil_ndx) < 0)
{ {
pp->Flags &= ~(PF_RECOIL); pp->Flags &= ~(PF_RECOIL);
pp->recoil_ohorizoff = pp->recoil_horizoff = pitchhoriz(nullAngle.Degrees()); pp->recoil_ohorizoff = pp->recoil_horizoff = nullAngle;
return; return;
} }
// move pp->q16horiz up and down // move pp->q16horiz up and down
pp->recoil_ohorizoff = pp->recoil_horizoff; 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) 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) 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.xrepeat = PLAYER_NINJA_XREPEAT;
plActor->spr.yrepeat = PLAYER_NINJA_YREPEAT; plActor->spr.yrepeat = PLAYER_NINJA_YREPEAT;
pp->horizon.horiz = pitchhoriz(nullAngle.Degrees()); pp->horizon.horiz = nullAngle;
DoPlayerResetMovement(pp); DoPlayerResetMovement(pp);
plActor->user.ID = NINJA_RUN_R0; plActor->user.ID = NINJA_RUN_R0;
PlayerDeathReset(pp); PlayerDeathReset(pp);
@ -7178,7 +7178,7 @@ void InitAllPlayers(void)
extern bool NewGame; extern bool NewGame;
//int fz,cz; //int fz,cz;
pfirst->horizon.horiz = pitchhoriz(nullAngle.Degrees()); pfirst->horizon.horiz = nullAngle;
// Initialize all [MAX_SW_PLAYERS] arrays here! // Initialize all [MAX_SW_PLAYERS] arrays here!
for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++) for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++)
@ -7222,7 +7222,7 @@ void InitAllPlayers(void)
pp->FadeAmt = 0; pp->FadeAmt = 0;
pp->FadeTics = 0; pp->FadeTics = 0;
pp->StartColor = 0; pp->StartColor = 0;
pp->horizon.horizoff = pitchhoriz(nullAngle.Degrees()); pp->horizon.horizoff = nullAngle;
INITLIST(&pp->PanelSpriteList); INITLIST(&pp->PanelSpriteList);
} }

View file

@ -46,7 +46,7 @@ struct PREDICT
{ {
int x,y,z; int x,y,z;
DAngle ang; DAngle ang;
fixedhoriz horiz; // fixedhoriz horiz;
short filler; short filler;
}; };

View file

@ -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 // Spawn a shot
// Inserting and setting up variables // Inserting and setting up variables

View file

@ -209,7 +209,7 @@ struct SWPlayer native
native double recoil_amt; native double recoil_amt;
native int16 recoil_speed; native int16 recoil_speed;
native int16 recoil_ndx; native int16 recoil_ndx;
native int recoil_horizoff; native double recoil_horizoff;
native double RevolveDeltaAng; native double RevolveDeltaAng;