diff --git a/include/blt/math/vectors.h b/include/blt/math/vectors.h index 7744ab8..0f1ff7a 100644 --- a/include/blt/math/vectors.h +++ b/include/blt/math/vectors.h @@ -63,8 +63,11 @@ namespace blt { return std::sqrt(total); } - [[nodiscard]] inline vec normalize() const { - return *this / this->magnitude(); + [[nodiscard]] inline vec& normalize() const { + auto mag = this->magnitude(); + if (mag == 0) + return *this; + return *this / mag; } inline T& operator[](int index) {