Browse Source

Don't normalize zero length vectors. (#1896)

pull/1900/head
Jeffery Myers 3 years ago
committed by GitHub
parent
commit
c706b33b30
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      src/raymath.h

+ 5
- 1
src/raymath.h View File

@ -282,7 +282,11 @@ RMDEF Vector2 Vector2Divide(Vector2 v1, Vector2 v2)
// Normalize provided vector
RMDEF Vector2 Vector2Normalize(Vector2 v)
{
Vector2 result = Vector2Scale(v, 1/Vector2Length(v));
float length = Vector2Length(v);
if (length <= 0)
return v;
Vector2 result = Vector2Scale(v, 1/length);
return result;
}

Loading…
Cancel
Save