16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00

Use the sq function to force constexpr expressions for numeric literals and enhance readability

This commit is contained in:
docentYT
2026-04-28 13:23:14 +02:00
parent 6be1b0886d
commit ca839652bf
15 changed files with 64 additions and 59 deletions

View File

@@ -569,7 +569,7 @@ void driver_mode::update_camera(double const Deltatime)
Camera.Reset(); // likwidacja obrotów - patrzy horyzontalnie na południe
if (Camera.m_owner == nullptr)
{
if (controlled && glm::length2(controlled->GetPosition() - Camera.Pos) < 1500 * 1500) // length2 is better than length for comparing because it does not require sqrt function
if (controlled && glm::length2(controlled->GetPosition() - Camera.Pos) < sq(1500)) // length2 is better than length for comparing because it does not require sqrt function
{
// gdy bliżej niż 1.5km
Camera.LookAt = controlled->GetPosition() + 0.4 * controlled->VectorUp() * controlled->MoverParameters->Dim.H;
@@ -583,7 +583,7 @@ void driver_mode::update_camera(double const Deltatime)
if (d && pDynamicNearest)
{
// jeśli jakiś jest znaleziony wcześniej
if (100.0 * glm::length2(d->GetPosition() - Camera.Pos) > glm::length2(pDynamicNearest->GetPosition() - Camera.Pos)) // length2 is better than length for comparing because it does not require sqrt function
if (sq(10.0) * glm::length2(d->GetPosition() - Camera.Pos) > glm::length2(pDynamicNearest->GetPosition() - Camera.Pos)) // length2 is better than length for comparing because it does not require sqrt function
{
d = pDynamicNearest; // jeśli najbliższy nie jest 10 razy bliżej niż
}