From 6f78731d8fc0b5b7e2539fa902421eeab241f764 Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 18 Jun 2023 16:33:39 +0200 Subject: [PATCH] normalize will now normalize if either x or y is non-zero previously 100,0 would return 100,0 instead of 1,0 --- src/corelib/math/vec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/math/vec.h b/src/corelib/math/vec.h index 601e6c4..9a62b93 100644 --- a/src/corelib/math/vec.h +++ b/src/corelib/math/vec.h @@ -18,7 +18,7 @@ void clamp_magnitude(float* xx, float* yy, float max_magnitude) { static inline void normalize(float* xx, float* yy) { float x = *xx, y = *yy; - if(x != 0 && y != 0) { + if(x != 0 || y != 0) { const float m = sqrtf(x*x + y*y); x /= m; y /= m; *xx = x; *yy = y;