From 4afa34ab7e8f2ceaa62351f2db3c6f500e3f9944 Mon Sep 17 00:00:00 2001 From: powerof3 Date: Wed, 4 Dec 2024 05:14:24 +0530 Subject: [PATCH] Add `NiPoint3` friend operators --- include/RE/N/NiPoint3.h | 5 +++++ src/RE/N/NiPoint3.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/RE/N/NiPoint3.h b/include/RE/N/NiPoint3.h index 4b4a338e9..fe9ac4736 100644 --- a/include/RE/N/NiPoint3.h +++ b/include/RE/N/NiPoint3.h @@ -30,6 +30,11 @@ namespace RE NiPoint3& operator*=(float a_scalar); NiPoint3& operator/=(float a_scalar); + friend NiPoint3 operator+(float a_lhs, const NiPoint3& a_rhs); + friend NiPoint3 operator-(float a_lhs, const NiPoint3& a_rhs); + friend NiPoint3 operator*(float a_lhs, const NiPoint3& a_rhs); + friend NiPoint3 operator/(float a_lhs, const NiPoint3& a_rhs); + [[nodiscard]] NiPoint3 Cross(const NiPoint3& pt) const; [[nodiscard]] float Dot(const NiPoint3& pt) const; [[nodiscard]] float GetDistance(const NiPoint3& a_pt) const noexcept; diff --git a/src/RE/N/NiPoint3.cpp b/src/RE/N/NiPoint3.cpp index 4e353af67..a0ad7dd88 100644 --- a/src/RE/N/NiPoint3.cpp +++ b/src/RE/N/NiPoint3.cpp @@ -104,6 +104,38 @@ namespace RE return operator*=(1.0F / a_scalar); } + NiPoint3 operator+(float a_lhs, const NiPoint3& a_rhs) + { + return NiPoint3( + a_lhs + a_rhs.x, + a_lhs + a_rhs.y, + a_lhs + a_rhs.z); + } + + NiPoint3 operator-(float a_lhs, const NiPoint3& a_rhs) + { + return NiPoint3( + a_lhs - a_rhs.x, + a_lhs - a_rhs.y, + a_lhs - a_rhs.z); + } + + NiPoint3 operator*(float a_lhs, const NiPoint3& a_rhs) + { + return NiPoint3( + a_lhs * a_rhs.x, + a_lhs * a_rhs.y, + a_lhs * a_rhs.z); + } + + NiPoint3 operator/(float a_lhs, const NiPoint3& a_rhs) + { + return NiPoint3( + a_lhs / a_rhs.x, + a_lhs / a_rhs.y, + a_lhs / a_rhs.z); + } + NiPoint3 NiPoint3::Cross(const NiPoint3& a_pt) const { return NiPoint3(