diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index 169480496..f89e67081 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -28,6 +28,16 @@ BitArray clipsectormap; int32_t quickloadboard=0; +static inline int bsin(const int ang) +{ + return int(g_sinbam(ang * (1 << 21)) * 16384); +} + +static inline int bcos(const int ang) +{ + return int(g_cosbam(ang * (1 << 21)) * 16384); +} + ////////// CLIPMOVE ////////// inline uint8_t bitmap_test(uint8_t const* const ptr, int const n) { return ptr[n >> 3] & (1 << (n & 7)); } diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 1ce8fa6f2..5d065a9e3 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -197,42 +197,6 @@ inline void dragpoint(walltype* startwall, const DVector2& pos) } -//--------------------------------------------------------------------------- -// -// Constants used for Build sine/cosine functions. -// -//--------------------------------------------------------------------------- - -enum -{ - BAMBITS = 21, - BAMUNIT = 1 << BAMBITS, -}; - -constexpr double BAngRadian = pi::pi() * (1. / 1024.); - -//--------------------------------------------------------------------------- -// -// Build sine inline functions. -// -//--------------------------------------------------------------------------- - -inline int bsin(const int ang) -{ - return int(g_sinbam(ang * BAMUNIT) * 16384); -} - -//--------------------------------------------------------------------------- -// -// Build cosine inline functions. -// -//--------------------------------------------------------------------------- - -inline int bcos(const int ang) -{ - return int(g_cosbam(ang * BAMUNIT) * 16384); -} - //--------------------------------------------------------------------------- // // diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 5a5c17b6c..961477b01 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1675,7 +1675,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight)) { velAdjustment = p->vehTurnLeft ? -adjust : adjust; - auto angAdjustment = (velAdjustment > nullAngle ? 350 : -350) << BAMBITS; + auto angAdjustment = velAdjustment > nullAngle ? 734003200 : -734003200; if (p->moto_on_mud || p->moto_on_oil || !p->NotOnWater) { @@ -1712,7 +1712,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) } p->vel.XY() += (p->GetActor()->spr.Angles.Yaw + velAdjustment).ToVector() * currSpeed; - p->GetActor()->spr.Angles.Yaw += deltaangle(p->GetActor()->spr.Angles.Yaw, p->GetActor()->spr.Angles.Yaw - DAngle::fromBam(angAdjustment)); + p->GetActor()->spr.Angles.Yaw = (p->GetActor()->spr.Angles.Yaw - DAngle::fromBam(angAdjustment)).Normalized360(); } else if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->moto_on_mud || p->moto_on_oil)) { @@ -1942,7 +1942,7 @@ static void onBoat(int snum, ESyncBits &actions) int currSpeed = int(p->MotoSpeed * 4.); DAngle velAdjustment = p->vehTurnLeft ? -adjust : adjust; - auto angAdjustment = (velAdjustment > nullAngle ? 350 : -350) << BAMBITS; + auto angAdjustment = velAdjustment > nullAngle ? 734003200 : -734003200; if (p->moto_do_bump) { @@ -1956,7 +1956,7 @@ static void onBoat(int snum, ESyncBits &actions) } p->vel.XY() += (p->GetActor()->spr.Angles.Yaw + velAdjustment).ToVector() * currSpeed; - p->GetActor()->spr.Angles.Yaw += deltaangle(p->GetActor()->spr.Angles.Yaw, p->GetActor()->spr.Angles.Yaw - DAngle::fromBam(angAdjustment)); + p->GetActor()->spr.Angles.Yaw = (p->GetActor()->spr.Angles.Yaw - DAngle::fromBam(angAdjustment)).Normalized360(); } if (p->NotOnWater && p->MotoSpeed > 50) p->MotoSpeed -= (p->MotoSpeed / 2.); diff --git a/source/games/exhumed/src/sound.cpp b/source/games/exhumed/src/sound.cpp index ddacdd546..d6666ae36 100644 --- a/source/games/exhumed/src/sound.cpp +++ b/source/games/exhumed/src/sound.cpp @@ -455,9 +455,9 @@ void EXSoundEngine::CalcPosVel(int type, const void* source, const float pt[3], else if (type == SOURCE_Swirly) { int which = *(int*)source; - double phase = (PlayClock << (4 + which)) * BAngRadian; - pos->X = fcampos.X + float(256 * cos(phase)); - pos->Z = fcampos.Z + float(256 * sin(phase)); + double phase = PlayClock << (4 + which); + pos->X = fcampos.X + float(256 * BobVal(phase + 512)); + pos->Z = fcampos.Z + float(256 * BobVal(phase)); } else if (type == SOURCE_EXBoss) {