mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-21 19:11:06 +00:00
- Remove fixedhoriz::asbuildf()
and associated buildf friend.
* The new friend `tanhoriz()` is just for the input code for now.
This commit is contained in:
parent
d8a6471680
commit
4ef9ec93ea
7 changed files with 17 additions and 13 deletions
|
@ -70,7 +70,7 @@ class fixedhoriz
|
|||
|
||||
friend constexpr fixedhoriz q16horiz(fixed_t v);
|
||||
friend constexpr fixedhoriz buildhoriz(int v);
|
||||
friend fixedhoriz buildfhoriz(double v);
|
||||
friend constexpr fixedhoriz tanhoriz(double v);
|
||||
friend fixedhoriz pitchhoriz(double v);
|
||||
|
||||
friend FSerializer &Serialize(FSerializer &arc, const char *key, fixedhoriz &obj, fixedhoriz *defval);
|
||||
|
@ -82,7 +82,6 @@ public:
|
|||
|
||||
// This class intentionally makes no allowances for implicit type conversions because those would render it ineffective.
|
||||
constexpr short asbuild() const { return FixedToInt(value); }
|
||||
constexpr double asbuildf() const { return FixedToFloat(value); }
|
||||
constexpr fixed_t asq16() const { return value; }
|
||||
constexpr double Tan() const { return FixedToFloat<23>(value); }
|
||||
double Degrees() const { return HorizToPitch(value); }
|
||||
|
@ -183,7 +182,7 @@ public:
|
|||
|
||||
inline constexpr fixedhoriz q16horiz(fixed_t v) { return fixedhoriz(v); }
|
||||
inline constexpr fixedhoriz buildhoriz(int v) { return fixedhoriz(IntToFixed(v)); }
|
||||
inline fixedhoriz buildfhoriz(double v) { return fixedhoriz(FloatToFixed(v)); }
|
||||
inline constexpr fixedhoriz tanhoriz(double v) { return fixedhoriz(FloatToFixed<23>(v)); }
|
||||
inline fixedhoriz pitchhoriz(double v) { return fixedhoriz(PitchToHoriz(v)); }
|
||||
|
||||
inline FSerializer &Serialize(FSerializer &arc, const char *key, fixedhoriz &obj, fixedhoriz *defval)
|
||||
|
|
|
@ -48,7 +48,7 @@ inline static double getCorrectedScale(const double scaleAdjust)
|
|||
|
||||
inline static fixedhoriz getscaledhoriz(const double value, const double scaleAdjust, const fixedhoriz object, const double push)
|
||||
{
|
||||
return buildfhoriz(getCorrectedScale(scaleAdjust) * ((object.asbuildf() * getTicrateScale(value)) + push));
|
||||
return tanhoriz(getCorrectedScale(scaleAdjust) * ((object.Tan() * getTicrateScale(value)) + push));
|
||||
}
|
||||
|
||||
inline static DAngle getscaledangle(const double value, const double scaleAdjust, const DAngle object, const DAngle push)
|
||||
|
@ -60,7 +60,7 @@ inline static void scaletozero(fixedhoriz& object, const double value, const dou
|
|||
{
|
||||
if (auto sgn = object.Sgn())
|
||||
{
|
||||
object -= getscaledhoriz(value, scaleAdjust, object, push == DBL_MAX ? sgn * 2. / 9. : push);
|
||||
object -= getscaledhoriz(value, scaleAdjust, object, push == DBL_MAX ? sgn * (1. / 576.) : push);
|
||||
if (sgn != object.Sgn()) object = q16horiz(0);
|
||||
}
|
||||
}
|
||||
|
@ -428,12 +428,12 @@ 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 (horizoff.asq16() < IntToFixed(100)) horizoff += getscaledhoriz(HORIZOFFSPEED, scaleAdjust, buildhoriz(100) - horizoff, 1.);
|
||||
if (horizoff.Degrees() < 38) horizoff += getscaledhoriz(HORIZOFFSPEED, scaleAdjust, pitchhoriz(38) - horizoff, 0.0078125);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope.
|
||||
scaletozero(horizoff, HORIZOFFSPEED, scaleAdjust, horizoff.Sgn());
|
||||
scaletozero(horizoff, HORIZOFFSPEED, scaleAdjust, horizoff.Sgn() * (1. / 128.));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ 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);
|
||||
|
||||
|
@ -729,3 +730,7 @@ constexpr DAngle mapangle(int mapang)
|
|||
{
|
||||
return DAngle::fromBuild(mapang);
|
||||
}
|
||||
inline fixedhoriz maphoriz(double maphoriz)
|
||||
{
|
||||
return pitchhoriz(atan2(maphoriz, 128.) * (180. / pi::pi()));
|
||||
}
|
||||
|
|
|
@ -2214,7 +2214,7 @@ void trPlayerCtrlSetLookAngle(int value, PLAYER* pPlayer)
|
|||
adjustment = 0;
|
||||
}
|
||||
|
||||
pPlayer->horizon.settarget(buildfhoriz(100. * tan(adjustment * pi::pi() * (1. / 1024.))));
|
||||
pPlayer->horizon.settarget(maphoriz(100. * tan(adjustment * pi::pi() * (1. / 1024.))));
|
||||
pPlayer->horizon.lockinput();
|
||||
}
|
||||
|
||||
|
|
|
@ -412,7 +412,7 @@ void viewUpdateShake(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, fixedhoriz& cH
|
|||
if (effectType)
|
||||
{
|
||||
int nValue = ClipHigh(effectType * 8, 2000);
|
||||
cH += buildfhoriz(QRandom2F(nValue * (1. / 256.)));
|
||||
cH += pitchhoriz(HorizToPitch(QRandom2F(nValue * (1. / 256.))));
|
||||
cA += DAngle::fromBuildf(QRandom2F(nValue * (1. / 256.)));
|
||||
cPos.X += QRandom2F(nValue * inttoworld) * inttoworld;
|
||||
cPos.Y += QRandom2F(nValue * inttoworld) * inttoworld;
|
||||
|
|
|
@ -1761,7 +1761,7 @@ static void onMotorcycle(int snum, ESyncBits &actions)
|
|||
}
|
||||
if (horiz != FRACUNIT)
|
||||
{
|
||||
p->horizon.addadjustment(buildfhoriz(horiz) - p->horizon.horiz);
|
||||
p->horizon.addadjustment(maphoriz(horiz) - p->horizon.horiz);
|
||||
}
|
||||
|
||||
const DAngle adjust = mapangle(-510);
|
||||
|
@ -2029,7 +2029,7 @@ static void onBoat(int snum, ESyncBits &actions)
|
|||
}
|
||||
if (horiz != FRACUNIT)
|
||||
{
|
||||
p->horizon.addadjustment(buildfhoriz(horiz) - p->horizon.horiz);
|
||||
p->horizon.addadjustment(maphoriz(horiz) - p->horizon.horiz);
|
||||
}
|
||||
|
||||
if (p->MotoSpeed > 0 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight))
|
||||
|
|
|
@ -2500,10 +2500,10 @@ sectdone:
|
|||
|
||||
if (cl_slopetilting && !pPlayer->bPlayerPan && !pPlayer->bLockPan)
|
||||
{
|
||||
double nVertPan = (pPlayer->nDestVertPan - pPlayer->horizon.horiz).Tan() * 32.;
|
||||
double nVertPan = (pPlayer->nDestVertPan - pPlayer->horizon.horiz).Degrees();
|
||||
if (nVertPan != 0)
|
||||
{
|
||||
pPlayer->horizon.addadjustment(buildfhoriz(abs(nVertPan) >= 4 ? clamp(nVertPan, -4., 4.) : nVertPan * 2.));
|
||||
pPlayer->horizon.addadjustment(pitchhoriz(abs(nVertPan) >= 1.79 ? clamp(nVertPan, -1.79, 1.79) : nVertPan * 2.));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue