Compare commits
1 Commits
sekiei
...
ef9c7ac15d
Author | SHA1 | Date | |
---|---|---|---|
ef9c7ac15d |
@ -7,12 +7,6 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
#if GLM_ENABLE_CONSTEXPR_MATH == GLM_ENABLE
|
||||
# include <gcem.hpp>
|
||||
#endif
|
||||
// END @MEWIN
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
@ -40,12 +34,10 @@ namespace detail
|
||||
template<length_t L, typename T, qualifier Q, bool Aligned>
|
||||
struct compute_sqrt
|
||||
{
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
GLM_FUNC_QUALIFIER GLM_MATH_CONSTEXPR static vec<L, T, Q> call(vec<L, T, Q> const& x)
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& x)
|
||||
{
|
||||
return detail::functor1<vec, L, T, T, Q>::call(GLM_MATH_BASE_NS::sqrt, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(std::sqrt, x);
|
||||
}
|
||||
// END @MEWIN
|
||||
};
|
||||
|
||||
template<length_t L, typename T, qualifier Q, bool Aligned>
|
||||
@ -131,13 +123,9 @@ namespace detail
|
||||
}
|
||||
|
||||
// sqrt
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
using GLM_MATH_BASE_NS::sqrt;
|
||||
// END @MEWIN
|
||||
using std::sqrt;
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
GLM_FUNC_QUALIFIER GLM_MATH_CONSTEXPR vec<L, T, Q> sqrt(vec<L, T, Q> const& x)
|
||||
// END @MEWIN
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> sqrt(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sqrt' only accept floating-point inputs");
|
||||
return detail::compute_sqrt<L, T, Q, detail::is_aligned<Q>::value>::call(x);
|
||||
|
@ -7,9 +7,7 @@ namespace detail
|
||||
template<length_t L, typename T, qualifier Q, bool Aligned>
|
||||
struct compute_length
|
||||
{
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
GLM_FUNC_QUALIFIER GLM_MATH_CONSTEXPR static T call(vec<L, T, Q> const& v)
|
||||
// END @MEWIN
|
||||
GLM_FUNC_QUALIFIER static T call(vec<L, T, Q> const& v)
|
||||
{
|
||||
return sqrt(dot(v, v));
|
||||
}
|
||||
@ -18,9 +16,7 @@ namespace detail
|
||||
template<length_t L, typename T, qualifier Q, bool Aligned>
|
||||
struct compute_distance
|
||||
{
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
GLM_FUNC_QUALIFIER static GLM_MATH_CONSTEXPR T call(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1)
|
||||
// END @MEWIN
|
||||
GLM_FUNC_QUALIFIER static T call(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1)
|
||||
{
|
||||
return length(p1 - p0);
|
||||
}
|
||||
@ -129,9 +125,7 @@ namespace detail
|
||||
|
||||
// length
|
||||
template<typename genType>
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
GLM_FUNC_QUALIFIER GLM_MATH_CONSTEXPR genType length(genType x)
|
||||
// END @MEWIN
|
||||
GLM_FUNC_QUALIFIER genType length(genType x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'length' accepts only floating-point inputs");
|
||||
|
||||
@ -139,9 +133,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
GLM_FUNC_QUALIFIER GLM_MATH_CONSTEXPR T length(vec<L, T, Q> const& v)
|
||||
// END @MEWIN
|
||||
GLM_FUNC_QUALIFIER T length(vec<L, T, Q> const& v)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'length' accepts only floating-point inputs");
|
||||
|
||||
@ -150,9 +142,7 @@ namespace detail
|
||||
|
||||
// distance
|
||||
template<typename genType>
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
GLM_FUNC_QUALIFIER GLM_MATH_CONSTEXPR genType distance(genType const& p0, genType const& p1)
|
||||
// END @MEWIN
|
||||
GLM_FUNC_QUALIFIER genType distance(genType const& p0, genType const& p1)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'distance' accepts only floating-point inputs");
|
||||
|
||||
@ -160,9 +150,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
GLM_FUNC_QUALIFIER GLM_MATH_CONSTEXPR T distance(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1)
|
||||
// END @MEWIN
|
||||
GLM_FUNC_QUALIFIER T distance(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1)
|
||||
{
|
||||
return detail::compute_distance<L, T, Q, detail::is_aligned<Q>::value>::call(p0, p1);
|
||||
}
|
||||
|
@ -308,26 +308,7 @@
|
||||
# define GLM_CONSTEXPR
|
||||
#endif
|
||||
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
#if !defined(GLM_ENABLE_CONSTEXPR_MATH)
|
||||
# if (GLM_LANG & GLM_LANG_CXX17_FLAG)
|
||||
# define GLM_ENABLE_CONSTEXPR_MATH __has_include(<gcem.hpp>)
|
||||
# else
|
||||
# define GLM_ENABLE_CONSTEXPR_MATH 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if GLM_ENABLE_CONSTEXPR_MATH == GLM_ENABLE
|
||||
# define GLM_MATH_CONSTEXPR GLM_CONSTEXPR
|
||||
# define GLM_MATH_BASE_NS gcem
|
||||
#else
|
||||
# define GLM_MATH_CONSTEXPR GLM_INLINE
|
||||
# define GLM_MATH_BASE_NS std
|
||||
#endif
|
||||
|
||||
// END @MEWIN
|
||||
//
|
||||
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
# if (GLM_COMPILER & GLM_COMPILER_CLANG)
|
||||
# if __has_feature(cxx_if_constexpr)
|
||||
|
@ -20,12 +20,6 @@
|
||||
#include "detail/type_vec4.hpp"
|
||||
#include <cmath>
|
||||
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
#if GLM_ENABLE_CONSTEXPR_MATH == GLM_ENABLE
|
||||
# include <gcem.hpp>
|
||||
#endif
|
||||
// END @MEWIN
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup core_func_exponential
|
||||
@ -97,9 +91,7 @@ namespace glm
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sqrt.xml">GLSL sqrt man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
GLM_FUNC_DECL GLM_MATH_CONSTEXPR vec<L, T, Q> sqrt(vec<L, T, Q> const& v);
|
||||
// END @MEWIN
|
||||
GLM_FUNC_DECL vec<L, T, Q> sqrt(vec<L, T, Q> const& v);
|
||||
|
||||
/// Returns the reciprocal of the positive square root of v.
|
||||
///
|
||||
|
@ -27,9 +27,7 @@ namespace glm
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/length.xml">GLSL length man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
GLM_FUNC_DECL GLM_MATH_CONSTEXPR T length(vec<L, T, Q> const& x);
|
||||
// END @MEWIN
|
||||
GLM_FUNC_DECL T length(vec<L, T, Q> const& x);
|
||||
|
||||
/// Returns the distance between p0 and p1, i.e., length(p0 - p1).
|
||||
///
|
||||
@ -39,9 +37,7 @@ namespace glm
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/distance.xml">GLSL distance man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
GLM_FUNC_DECL GLM_MATH_CONSTEXPR T distance(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1);
|
||||
// END @MEWIN
|
||||
GLM_FUNC_DECL T distance(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1);
|
||||
|
||||
/// Returns the dot product of x and y, i.e., result = x * y.
|
||||
///
|
||||
|
@ -1,4 +1,3 @@
|
||||
// @MEWIN - 2023-01-02 - Added support for spaceship operator.
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -8,48 +7,27 @@
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
struct vec;
|
||||
|
||||
template<length_t C, length_t R, typename T, qualifier Q>
|
||||
struct mat;
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR std::strong_ordering operator<=>(const vec<L, T, Q>& left, const vec<L, T, Q>& right)
|
||||
template<length_t l, typename T, qualifier q>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR std::strong_ordering operator<=>(const glm::vec<l, T, q>& left, const glm::vec<l, T, q>& right)
|
||||
{
|
||||
if (left[0] != right[0]) {
|
||||
return left[0] <=> right[0];
|
||||
}
|
||||
if constexpr (L > 1) {
|
||||
if constexpr (l > 1) {
|
||||
if (left[1] != right[1]) {
|
||||
return left[1] <=> right[1];
|
||||
}
|
||||
}
|
||||
if constexpr (L > 2) {
|
||||
if constexpr (l > 2) {
|
||||
if (left[2] != right[2]) {
|
||||
return left[2] <=> right[2];
|
||||
}
|
||||
}
|
||||
if constexpr (L > 3) {
|
||||
if constexpr (l > 3) {
|
||||
if (left[3] != right[3]) {
|
||||
return left[3] <=> right[3];
|
||||
}
|
||||
}
|
||||
return std::strong_ordering::equal;
|
||||
}
|
||||
|
||||
template<length_t C, length_t R, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR std::strong_ordering operator<=>(const mat<C, R, T, Q>& left, const mat<C, R, T, Q>& right)
|
||||
{
|
||||
for (int col = 0; col < C; ++col)
|
||||
{
|
||||
for (int row = 0; row < R; ++row)
|
||||
{
|
||||
if (left[col][row] != right[col][row]) {
|
||||
return left[col][row] <=> right[col][row];
|
||||
}
|
||||
}
|
||||
}
|
||||
return std::strong_ordering::equal;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user