From e3cefef78deb909f31899cf8de963575fdbfc8d4 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Fri, 19 Feb 2021 05:20:27 +0700 Subject: [PATCH] remove faceforward, reflect and refract functions --- README.md | 18 ------------------ headers/vmath.hpp/vmath_fun.hpp | 20 -------------------- headers/vmath.hpp/vmath_vec_fun.hpp | 17 ----------------- untests/vmath_fun_tests.cpp | 4 ---- untests/vmath_vec_fun_tests.cpp | 4 ---- 5 files changed, 63 deletions(-) diff --git a/README.md b/README.md index 6bd7672..c172d60 100644 --- a/README.md +++ b/README.md @@ -1283,15 +1283,6 @@ constexpr T distance2(T x, T y) noexcept; template < floating_point T > T normalize(T x) noexcept; - -template < floating_point T > -constexpr T faceforward(T n, T i, T nref) noexcept; - -template < floating_point T > -constexpr T reflect(T i, T n) noexcept; - -template < floating_point T > -T refract(T i, T n, T eta) noexcept; ``` #### Vector @@ -1320,15 +1311,6 @@ constexpr vec cross(const vec& xs, const vec& ys); template < typename T, size_t Size > vec normalize(const vec& xs); - -template < typename T, size_t Size > -constexpr vec faceforward(const vec& n, const vec& i, const vec& nref); - -template < typename T, size_t Size > -constexpr vec reflect(const vec& i, const vec& n); - -template < typename T, size_t Size > -vec refract(const vec& i, const vec& n, T eta); ``` #### Quaternion diff --git a/headers/vmath.hpp/vmath_fun.hpp b/headers/vmath.hpp/vmath_fun.hpp index 0e43580..3701c02 100644 --- a/headers/vmath.hpp/vmath_fun.hpp +++ b/headers/vmath.hpp/vmath_fun.hpp @@ -342,26 +342,6 @@ namespace vmath_hpp normalize(T x) noexcept { return x * rsqrt(length2(x)); } - - template < typename T > - [[nodiscard]] std::enable_if_t, T> - constexpr faceforward(T n, T i, T nref) noexcept { - return dot(nref, i) < T(0) ? n : -n; - } - - template < typename T > - [[nodiscard]] std::enable_if_t, T> - constexpr reflect(T i, T n) noexcept { - return i - n * dot(n, i) * T(2); - } - - template < typename T > - [[nodiscard]] std::enable_if_t, T> - refract(T i, T n, T eta) noexcept { - const T d = dot(n, i); - const T k = T(1) - eta * eta * (T(1) - d * d); - return T(k >= T(0)) * (eta * i - (eta * d + sqrt(k)) * n); - } } // diff --git a/headers/vmath.hpp/vmath_vec_fun.hpp b/headers/vmath.hpp/vmath_vec_fun.hpp index 0218a43..979a3ec 100644 --- a/headers/vmath.hpp/vmath_vec_fun.hpp +++ b/headers/vmath.hpp/vmath_vec_fun.hpp @@ -861,23 +861,6 @@ namespace vmath_hpp [[nodiscard]] vec normalize(const vec& xs) { return xs * rsqrt(length2(xs)); } - - template < typename T, std::size_t Size > - [[nodiscard]] constexpr vec faceforward(const vec& n, const vec& i, const vec& nref) { - return dot(nref, i) < T(0) ? n : -n; - } - - template < typename T, std::size_t Size > - [[nodiscard]] constexpr vec reflect(const vec& i, const vec& n) { - return i - n * dot(n, i) * T(2); - } - - template < typename T, std::size_t Size > - [[nodiscard]] vec refract(const vec& i, const vec& n, T eta) { - const T d = dot(n, i); - const T k = T(1) - eta * eta * (T(1) - d * d); - return T(k >= T(0)) * (eta * i - (eta * d + sqrt(k)) * n); - } } // diff --git a/untests/vmath_fun_tests.cpp b/untests/vmath_fun_tests.cpp index b105a74..8de5f9a 100644 --- a/untests/vmath_fun_tests.cpp +++ b/untests/vmath_fun_tests.cpp @@ -118,10 +118,6 @@ TEST_CASE("vmath/fun") { STATIC_CHECK(dot(2.f, 5.f) == uapprox(10.f)); CHECK(normalize(0.5f) == uapprox(1.f)); - - STATIC_CHECK(faceforward(1.f, 2.f, 3.f) == uapprox(-1.f)); - STATIC_CHECK(reflect(1.f, 2.f) == uapprox(-7.f)); - CHECK(refract(1.f, 2.f, 1.f) == uapprox(-7.f)); } SUBCASE("Relational Functions") { diff --git a/untests/vmath_vec_fun_tests.cpp b/untests/vmath_vec_fun_tests.cpp index 873c26f..88008e1 100644 --- a/untests/vmath_vec_fun_tests.cpp +++ b/untests/vmath_vec_fun_tests.cpp @@ -260,10 +260,6 @@ TEST_CASE("vmath/vec_fun") { STATIC_CHECK(cross(int2(1,0),int2(0,1)) == 1); STATIC_CHECK(cross(int3(1,0,0),int3(0,1,0)) == int3(0,0,1)); CHECK(normalize(float2(0.5f,0.f)).x == uapprox(1.f)); - - STATIC_CHECK(faceforward(float2(1.f), float2(2.f), float2(3.f)).x == uapprox(-1.f)); - STATIC_CHECK(reflect(float2(1.f), float2(2.f)).x == uapprox(-15.f)); - CHECK(refract(float2(1.f), float2(2.f), 1.f).x == uapprox(-15.f)); } SUBCASE("Relational Functions") {