refactor(Core/Misc): sin() to std::sin() (#9795)

This commit is contained in:
Kitzunu
2022-01-06 19:29:40 +01:00
committed by GitHub
parent 66e6d33116
commit cb7e355291
66 changed files with 212 additions and 211 deletions

View File

@@ -1022,7 +1022,8 @@ bool Position::HasInLine(WorldObject const* target, float width) const
return false;
width += target->GetObjectSize();
float angle = GetRelativeAngle(target);
return std::fabs(sin(angle)) * GetExactDist2d(target->GetPositionX(), target->GetPositionY()) < width;
return std::fabs(std::sin(angle)) * GetExactDist2d(target->GetPositionX(), target->GetPositionY()) < width;
}
std::string Position::ToString() const
@@ -1519,8 +1520,8 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m
void Position::RelocateOffset(const Position& offset)
{
m_positionX = GetPositionX() + (offset.GetPositionX() * cos(GetOrientation()) + offset.GetPositionY() * sin(GetOrientation() + M_PI));
m_positionY = GetPositionY() + (offset.GetPositionY() * cos(GetOrientation()) + offset.GetPositionX() * sin(GetOrientation()));
m_positionX = GetPositionX() + (offset.GetPositionX() * cos(GetOrientation()) + offset.GetPositionY() * std::sin(GetOrientation() + M_PI));
m_positionY = GetPositionY() + (offset.GetPositionY() * cos(GetOrientation()) + offset.GetPositionX() * std::sin(GetOrientation()));
m_positionZ = GetPositionZ() + offset.GetPositionZ();
m_orientation = GetOrientation() + offset.GetOrientation();
}
@@ -1530,8 +1531,8 @@ void Position::GetPositionOffsetTo(const Position& endPos, Position& retOffset)
float dx = endPos.GetPositionX() - GetPositionX();
float dy = endPos.GetPositionY() - GetPositionY();
retOffset.m_positionX = dx * cos(GetOrientation()) + dy * sin(GetOrientation());
retOffset.m_positionY = dy * cos(GetOrientation()) - dx * sin(GetOrientation());
retOffset.m_positionX = dx * cos(GetOrientation()) + dy * std::sin(GetOrientation());
retOffset.m_positionY = dy * cos(GetOrientation()) - dx * std::sin(GetOrientation());
retOffset.m_positionZ = endPos.GetPositionZ() - GetPositionZ();
retOffset.m_orientation = endPos.GetOrientation() - GetOrientation();
}
@@ -1559,7 +1560,7 @@ void Position::GetSinCos(const float x, const float y, float& vsin, float& vcos)
{
float angle = (float)rand_norm() * static_cast<float>(2 * M_PI);
vcos = cos(angle);
vsin = sin(angle);
vsin = std::sin(angle);
}
else
{
@@ -1678,7 +1679,7 @@ void WorldObject::GetRandomPoint(const Position& pos, float distance, float& ran
float new_dist = (float)rand_norm() * static_cast<float>(distance);
rand_x = pos.m_positionX + new_dist * cos(angle);
rand_y = pos.m_positionY + new_dist * sin(angle);
rand_y = pos.m_positionY + new_dist * std::sin(angle);
rand_z = pos.m_positionZ;
Acore::NormalizeMapCoord(rand_x);
@@ -2863,7 +2864,7 @@ void WorldObject::MovePosition(Position& pos, float dist, float angle)
angle += m_orientation;
float destx, desty, destz, ground, floor;
destx = pos.m_positionX + dist * cos(angle);
desty = pos.m_positionY + dist * sin(angle);
desty = pos.m_positionY + dist * std::sin(angle);
// Prevent invalid coordinates here, position is unchanged
if (!Acore::IsValidMapCoord(destx, desty))
@@ -2884,7 +2885,7 @@ void WorldObject::MovePosition(Position& pos, float dist, float angle)
if (std::fabs(pos.m_positionZ - destz) > 6.0f)
{
destx -= step * cos(angle);
desty -= step * sin(angle);
desty -= step * std::sin(angle);
ground = GetMapHeight(destx, desty, MAX_HEIGHT);
floor = GetMapHeight(destx, desty, pos.m_positionZ);
destz = std::fabs(ground - pos.m_positionZ) <= std::fabs(floor - pos.m_positionZ) ? ground : floor;
@@ -2945,7 +2946,7 @@ void WorldObject::MovePositionToFirstCollision(Position& pos, float dist, float
angle += GetOrientation();
float destx, desty, destz;
destx = pos.m_positionX + dist * cos(angle);
desty = pos.m_positionY + dist * sin(angle);
desty = pos.m_positionY + dist * std::sin(angle);
destz = pos.m_positionZ;
if (!GetMap()->CheckCollisionAndGetValidCoords(this, pos.m_positionX, pos.m_positionY, pos.m_positionZ, destx, desty, destz, false))