- Tidy up remaining Build angle constants in gamefuncs.h.

This commit is contained in:
Mitchell Richters 2022-12-11 12:16:02 +11:00 committed by Christoph Oelckers
parent de8353f085
commit c3f276a08a
4 changed files with 17 additions and 43 deletions

View file

@ -28,6 +28,16 @@ BitArray clipsectormap;
int32_t quickloadboard=0; 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 ////////// ////////// CLIPMOVE //////////
inline uint8_t bitmap_test(uint8_t const* const ptr, int const n) { return ptr[n >> 3] & (1 << (n & 7)); } inline uint8_t bitmap_test(uint8_t const* const ptr, int const n) { return ptr[n >> 3] & (1 << (n & 7)); }

View file

@ -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);
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// //

View file

@ -1675,7 +1675,7 @@ static void onMotorcycle(int snum, ESyncBits &actions)
if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight)) if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight))
{ {
velAdjustment = p->vehTurnLeft ? -adjust : adjust; 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) 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->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)) 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.); int currSpeed = int(p->MotoSpeed * 4.);
DAngle velAdjustment = p->vehTurnLeft ? -adjust : adjust; DAngle velAdjustment = p->vehTurnLeft ? -adjust : adjust;
auto angAdjustment = (velAdjustment > nullAngle ? 350 : -350) << BAMBITS; auto angAdjustment = velAdjustment > nullAngle ? 734003200 : -734003200;
if (p->moto_do_bump) 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->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) if (p->NotOnWater && p->MotoSpeed > 50)
p->MotoSpeed -= (p->MotoSpeed / 2.); p->MotoSpeed -= (p->MotoSpeed / 2.);

View file

@ -455,9 +455,9 @@ void EXSoundEngine::CalcPosVel(int type, const void* source, const float pt[3],
else if (type == SOURCE_Swirly) else if (type == SOURCE_Swirly)
{ {
int which = *(int*)source; int which = *(int*)source;
double phase = (PlayClock << (4 + which)) * BAngRadian; double phase = PlayClock << (4 + which);
pos->X = fcampos.X + float(256 * cos(phase)); pos->X = fcampos.X + float(256 * BobVal(phase + 512));
pos->Z = fcampos.Z + float(256 * sin(phase)); pos->Z = fcampos.Z + float(256 * BobVal(phase));
} }
else if (type == SOURCE_EXBoss) else if (type == SOURCE_EXBoss)
{ {