diff --git a/src/corelib/math/vec.h b/src/corelib/math/vec.h index 9a62b93..1129da3 100644 --- a/src/corelib/math/vec.h +++ b/src/corelib/math/vec.h @@ -25,6 +25,14 @@ void normalize(float* xx, float* yy) { } } +#define NORMALIZE(_xx, _yy) \ +if(_xx != 0 || _yy != 0) { \ + const float m = sqrtf(_xx*_xx + _yy*_yy); \ + _xx /= m; _yy /= m; \ +} else { \ + _xx = 0; _yy = 0; \ +} + static inline int move_towards(float* out_x, float* out_y, float x, float y, float tx, float ty, float max_delta) { const float diff_x = tx - x,