17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-01 17:15:37 +01:00

refactor(sonar): make narrowing conversions explicit (cpp:S5276)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jerrrrycho
2026-10-10 15:16:28 +02:00
parent 80464d0bc1
commit 8c23c1fe2b
53 changed files with 468 additions and 468 deletions

View File

@@ -40,8 +40,8 @@ void TCamera::Reset() {
void TCamera::OnCursorMove(double x, double y) {
m_rotationoffsets.x += y;
m_rotationoffsets.y += x;
m_rotationoffsets.x += static_cast<float>(y);
m_rotationoffsets.y += static_cast<float>(x);
}
static double ComputeAxisSpeed(double param, double walkspeed, double maxspeed, double threshold) {
@@ -142,13 +142,13 @@ void TCamera::Update()
// update rotation
auto const rotationfactor { std::min( 1.0, 20 * deltatime ) };
Angle.y -= m_rotationoffsets.y * rotationfactor;
m_rotationoffsets.y *= 1.0 - rotationfactor;
Angle.y = std::remainder(Angle.y, 2.0 * M_PI);
Angle.y -= static_cast<float>(m_rotationoffsets.y * rotationfactor);
m_rotationoffsets.y *= static_cast<float>(1.0 - rotationfactor);
Angle.y = static_cast<float>(std::remainder(Angle.y, 2.0 * M_PI));
// Limit the camera pitch to +/- 90°.
Angle.x = std::clamp(Angle.x - m_rotationoffsets.x * rotationfactor, -M_PI_2, M_PI_2);
m_rotationoffsets.x *= 1.0 - rotationfactor;
Angle.x = static_cast<float>(std::clamp(Angle.x - m_rotationoffsets.x * rotationfactor, -M_PI_2, M_PI_2));
m_rotationoffsets.x *= static_cast<float>(1.0 - rotationfactor);
// update position
if( m_owner == nullptr
@@ -215,12 +215,12 @@ void TCamera::RaLook()
{ // zmiana kierunku patrzenia - przelicza Yaw
auto where = LookAt - Pos /*+ Math3D::vector3(0, 3, 0)*/; // trochę w górę od szyn
if( where.x != 0.0 || where.z != 0.0 ) {
Angle.y = atan2( -where.x, -where.z ); // kąt horyzontalny
Angle.y = static_cast<float>(atan2( -where.x, -where.z )); // kąt horyzontalny
m_rotationoffsets.y = 0.0;
}
double l = glm::length(where);
if( l > 0.0 ) {
Angle.x = asin( where.y / l ); // kąt w pionie
Angle.x = static_cast<float>(asin( where.y / l )); // kąt w pionie
m_rotationoffsets.x = 0.0;
}
};