Limit should only be positive, because it's the length

This commit is contained in:
Vinícius Bispo 2024-09-16 15:43:50 -03:00 committed by GitHub
parent 41e2c50ab8
commit 89d2a38c0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -397,7 +397,7 @@ RMAPI Vector2 Vector2Normalize(Vector2 v)
RMAPI Vector2 Vector2Limit(Vector2 v, float limit) { RMAPI Vector2 Vector2Limit(Vector2 v, float limit) {
Vector2 result = {v.x, x.y}; Vector2 result = {v.x, x.y};
float length = sqrtf((v.x * v.x) + (v.y * v.y)) float length = sqrtf((v.x * v.x) + (v.y * v.y))
if (length > limit) { if (length > limit && limit > 0) {
float ilength = 1.0f/length; float ilength = 1.0f/length;
result.x = v.x*ilength*limit; result.x = v.x*ilength*limit;
result.y = v.y*ilength*limit; result.y = v.y*ilength*limit;