Skip to content

Commit

Permalink
Add NiPoint3 friend operators
Browse files Browse the repository at this point in the history
  • Loading branch information
powerof3 committed Dec 3, 2024
1 parent f4478e5 commit 4afa34a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/RE/N/NiPoint3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
32 changes: 32 additions & 0 deletions src/RE/N/NiPoint3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4afa34a

Please sign in to comment.