Sfoglia il codice sorgente

slightly optimize Vector3Normalize (#2982)

pull/2986/head
Rico P 2 anni fa
committed by GitHub
parent
commit
8b8eddc8e2
Non sono state trovate chiavi note per questa firma nel database ID Chiave GPG: 4AEE18F83AFDEB23
1 ha cambiato i file con 7 aggiunte e 5 eliminazioni
  1. +7
    -5
      src/raymath.h

+ 7
- 5
src/raymath.h Vedi File

@ -703,12 +703,14 @@ RMAPI Vector3 Vector3Normalize(Vector3 v)
Vector3 result = v;
float length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);
if (length == 0.0f) length = 1.0f;
float ilength = 1.0f/length;
if (length != 0.0f)
{
float ilength = 1.0f/length;
result.x *= ilength;
result.y *= ilength;
result.z *= ilength;
result.x *= ilength;
result.y *= ilength;
result.z *= ilength;
}
return result;
}

Caricamento…
Annulla
Salva