From d0085e834eb7d6d4842ff5f46bebf5cdef4ff85e Mon Sep 17 00:00:00 2001 From: h4570 Date: Sun, 14 Aug 2022 20:59:59 +0200 Subject: [PATCH] add getNormalized() --- engine/inc/math/vec4.hpp | 2 ++ engine/src/math/vec4.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/engine/inc/math/vec4.hpp b/engine/inc/math/vec4.hpp index 458ee76..29cbf42 100644 --- a/engine/inc/math/vec4.hpp +++ b/engine/inc/math/vec4.hpp @@ -87,6 +87,8 @@ class Vec4 { /** Normalize vector */ void normalize(); + Vec4 getNormalized() const; + /** Returns distance between two vectors */ float distanceTo(const Vec4& v) const; diff --git a/engine/src/math/vec4.cpp b/engine/src/math/vec4.cpp index b73b153..559edf0 100644 --- a/engine/src/math/vec4.cpp +++ b/engine/src/math/vec4.cpp @@ -228,6 +228,12 @@ void Vec4::normalize() { : "r"(this->xyzw)); } +Vec4 Vec4::getNormalized() const { + Vec4 result(*this); + result.normalize(); + return result; +} + float Vec4::distanceTo(const Vec4& v) const { float result; asm volatile(