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::dot for squared length

This commit is contained in:
docentYT
2026-04-27 23:13:12 +02:00
parent d5d1825e38
commit 7d561f8443
4 changed files with 10 additions and 12 deletions

View File

@@ -96,14 +96,14 @@ void TAnimContainer::UpdateModel() {
if (fTranslateSpeed != 0.0)
{
auto dif = vTranslateTo - vTranslation; // wektor w kierunku docelowym
double l2 = glm::dot(dif, dif); // długość wektora potrzebnego przemieszczenia
double l2 = glm::length2(dif); // długość wektora potrzebnego przemieszczenia
if (l2 >= 0.0001)
{ // jeśli do przemieszczenia jest ponad 1cm
auto s = glm::normalize(dif); // jednostkowy wektor kierunku // Długość wektora nie jest równa 0, sprawdzane wcześniej więc wektor normalny będzie zawsze prawidłowy.
s = s *
(fTranslateSpeed *
Timer::GetDeltaTime()); // przemieszczenie w podanym czasie z daną prędkością
if (glm::dot(s, s) < l2) //żeby nie jechało na drugą stronę
if (glm::length2(s) < l2) //żeby nie jechało na drugą stronę
vTranslation += s;
else
vTranslation = vTranslateTo; // koniec animacji, "koniec animowania" uruchomi
@@ -113,7 +113,7 @@ void TAnimContainer::UpdateModel() {
{ // koniec animowania
vTranslation = vTranslateTo;
fTranslateSpeed = 0.0; // wyłączenie przeliczania wektora
if (glm::dot(vTranslation, vTranslation) <= 0.0001) // jeśli jest w punkcie początkowym
if (glm::length2(vTranslation) <= 0.0001) // jeśli jest w punkcie początkowym
iAnim &= ~2; // wyłączyć zmianę pozycji submodelu
if( evDone ) {
// wykonanie eventu informującego o zakończeniu