diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index 380c3b298..c81f1f0af 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -53,6 +53,7 @@ namespace Nz constexpr Vector3& Minimize(const Vector3& vec); constexpr Vector3 Project(const Vector3& normal) const; + constexpr Vector3 ProjectOnPlane(const Vector3& normal) const; Vector3& Normalize(T* length = nullptr); diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index dd7d9b42b..317cc94ef 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -290,6 +290,13 @@ namespace Nz return normal * dot; } + template + constexpr Vector3 Vector3::ProjectOnPlane(const Vector3& normal) const + { + float dot = DotProduct(normal); + return *this - normal * dot; + } + /*! * \brief Normalizes the current vector * \return A reference to this vector