remove faceforward, reflect and refract functions

This commit is contained in:
BlackMATov
2021-02-19 05:20:27 +07:00
parent 1ba41e14b0
commit e3cefef78d
5 changed files with 0 additions and 63 deletions

View File

@@ -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<T, 3> cross(const vec<T, 3>& xs, const vec<T, 3>& ys);
template < typename T, size_t Size >
vec<T, Size> normalize(const vec<T, Size>& xs);
template < typename T, size_t Size >
constexpr vec<T, Size> faceforward(const vec<T, Size>& n, const vec<T, Size>& i, const vec<T, Size>& nref);
template < typename T, size_t Size >
constexpr vec<T, Size> reflect(const vec<T, Size>& i, const vec<T, Size>& n);
template < typename T, size_t Size >
vec<T, Size> refract(const vec<T, Size>& i, const vec<T, Size>& n, T eta);
```
#### Quaternion

View File

@@ -342,26 +342,6 @@ namespace vmath_hpp
normalize(T x) noexcept {
return x * rsqrt(length2(x));
}
template < typename T >
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<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<std::is_floating_point_v<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<std::is_floating_point_v<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);
}
}
//

View File

@@ -861,23 +861,6 @@ namespace vmath_hpp
[[nodiscard]] vec<T, Size> normalize(const vec<T, Size>& xs) {
return xs * rsqrt(length2(xs));
}
template < typename T, std::size_t Size >
[[nodiscard]] constexpr vec<T, Size> faceforward(const vec<T, Size>& n, const vec<T, Size>& i, const vec<T, Size>& nref) {
return dot(nref, i) < T(0) ? n : -n;
}
template < typename T, std::size_t Size >
[[nodiscard]] constexpr vec<T, Size> reflect(const vec<T, Size>& i, const vec<T, Size>& n) {
return i - n * dot(n, i) * T(2);
}
template < typename T, std::size_t Size >
[[nodiscard]] vec<T, Size> refract(const vec<T, Size>& i, const vec<T, Size>& 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);
}
}
//

View File

@@ -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") {

View File

@@ -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") {