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

@@ -152,7 +152,7 @@ bool FleeingMovementGenerator<T>::_getPoint(T* owner, float& x, float& y, float&
}
temp_x = x + distance * cos(angle);
temp_y = y + distance * sin(angle);
temp_y = y + distance * std::sin(angle);
float temp_z = z;
if (!_map->CanReachPositionAndGetValidCoords(owner, temp_x, temp_y, temp_z, true, true))
@@ -162,8 +162,8 @@ bool FleeingMovementGenerator<T>::_getPoint(T* owner, float& x, float& y, float&
if (!(temp_z - z) || distance / std::fabs(temp_z - z) > 1.0f)
{
float temp_z_left = _map->GetHeight(owner->GetPhaseMask(), temp_x + 1.0f * cos(angle + static_cast<float>(M_PI / 2)), temp_y + 1.0f * sin(angle + static_cast<float>(M_PI / 2)), z, true);
float temp_z_right = _map->GetHeight(owner->GetPhaseMask(), temp_x + 1.0f * cos(angle - static_cast<float>(M_PI / 2)), temp_y + 1.0f * sin(angle - static_cast<float>(M_PI / 2)), z, true);
float temp_z_left = _map->GetHeight(owner->GetPhaseMask(), temp_x + 1.0f * cos(angle + static_cast<float>(M_PI / 2)), temp_y + 1.0f * std::sin(angle + static_cast<float>(M_PI / 2)), z, true);
float temp_z_right = _map->GetHeight(owner->GetPhaseMask(), temp_x + 1.0f * cos(angle - static_cast<float>(M_PI / 2)), temp_y + 1.0f * std::sin(angle - static_cast<float>(M_PI / 2)), z, true);
if (std::fabs(temp_z_left - temp_z) < 1.2f && std::fabs(temp_z_right - temp_z) < 1.2f)
{
// use new values

View File

@@ -65,7 +65,7 @@ void PointMovementGenerator<T>::DoInitialize(T* unit)
if (G3D::fuzzyEq(unit->GetPositionX(), i_x) && G3D::fuzzyEq(unit->GetPositionY(), i_y))
{
i_x += 0.2f * cos(unit->GetOrientation());
i_y += 0.2f * sin(unit->GetOrientation());
i_y += 0.2f * std::sin(unit->GetOrientation());
}
init.MoveTo(i_x, i_y, i_z, true);
@@ -77,7 +77,7 @@ void PointMovementGenerator<T>::DoInitialize(T* unit)
if (G3D::fuzzyEq(unit->GetPositionX(), i_x) && G3D::fuzzyEq(unit->GetPositionY(), i_y))
{
i_x += 0.2f * cos(unit->GetOrientation());
i_y += 0.2f * sin(unit->GetOrientation());
i_y += 0.2f * std::sin(unit->GetOrientation());
}
init.MoveTo(i_x, i_y, i_z, true);

View File

@@ -247,7 +247,7 @@ void RandomMovementGenerator<Creature>::DoInitialize(Creature* creature)
{
float angle = (M_PI * 2.0f / (float)RANDOM_POINTS_NUMBER) * i;
float factor = 0.5f + rand_norm() * 0.5f;
_destinationPoints.push_back(G3D::Vector3(_initialPosition.GetPositionX() + _wanderDistance * cos(angle)*factor, _initialPosition.GetPositionY() + _wanderDistance * sin(angle)*factor, _initialPosition.GetPositionZ()));
_destinationPoints.push_back(G3D::Vector3(_initialPosition.GetPositionX() + _wanderDistance * cos(angle)*factor, _initialPosition.GetPositionY() + _wanderDistance * std::sin(angle)*factor, _initialPosition.GetPositionZ()));
}
}

View File

@@ -308,23 +308,23 @@ static Position const PredictPosition(Unit* target)
if (target->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FORWARD))
{
pos.m_positionX += cos(orientation) * speed;
pos.m_positionY += sin(orientation) * speed;
pos.m_positionY += std::sin(orientation) * speed;
}
else if (target->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_BACKWARD))
{
pos.m_positionX -= cos(orientation) * speed;
pos.m_positionY -= sin(orientation) * speed;
pos.m_positionY -= std::sin(orientation) * speed;
}
if (target->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_STRAFE_LEFT))
{
pos.m_positionX += cos(orientation + M_PI / 2.f) * speed;
pos.m_positionY += sin(orientation + M_PI / 2.f) * speed;
pos.m_positionY += std::sin(orientation + M_PI / 2.f) * speed;
}
else if (target->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_STRAFE_RIGHT))
{
pos.m_positionX += cos(orientation - M_PI / 2.f) * speed;
pos.m_positionY += sin(orientation - M_PI / 2.f) * speed;
pos.m_positionY += std::sin(orientation - M_PI / 2.f) * speed;
}
return pos;