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

Use glm::length2 instead of glm::length where possible

This commit is contained in:
docentYT
2026-04-27 23:27:08 +02:00
parent 7d561f8443
commit cba106e22e
9 changed files with 34 additions and 21 deletions

View File

@@ -630,8 +630,9 @@ std::pair<int, int> TSubModel::Load(cParser &parser, bool dynamic)
if (idx > 0)
{
// jeśli pierwszy trójkąt będzie zdegenerowany, to zostanie usunięty i nie ma co sprawdzać
if ((glm::length((vertex)->position - (vertex - 1)->position) > 1000.0) || (glm::length((vertex - 1)->position - (vertex - 2)->position) > 1000.0) ||
(glm::length((vertex - 2)->position - (vertex)->position) > 1000.0))
// length2 is better than length for comparing because it does not require sqrt function
if ((glm::length2((vertex)->position - (vertex - 1)->position) > 1000.0 * 1000.0) || (glm::length2((vertex - 1)->position - (vertex - 2)->position) > 1000.0 * 1000.0) ||
(glm::length2((vertex - 2)->position - (vertex)->position) > 1000.0 * 1000.0))
{
// jeżeli są dalej niż 2km od siebie //Ra 15-01:
// obiekt wstawiany nie powinien być większy niż 300m (trójkąty terenu w E3D mogą mieć 1.5km)