Compare commits
3 Commits
ef9c7ac15d
...
sekiei
Author | SHA1 | Date | |
---|---|---|---|
7dd1d85434 | |||
16b7a1d7d4 | |||
cab263a56d |
@ -7,6 +7,12 @@
|
||||
#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
|
||||
{
|
||||
@ -34,10 +40,12 @@ namespace detail
|
||||
template<length_t L, typename T, qualifier Q, bool Aligned>
|
||||
struct compute_sqrt
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& x)
|
||||
// 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)
|
||||
{
|
||||
return detail::functor1<vec, L, T, T, Q>::call(std::sqrt, x);
|
||||
return detail::functor1<vec, L, T, T, Q>::call(GLM_MATH_BASE_NS::sqrt, x);
|
||||
}
|
||||
// END @MEWIN
|
||||
};
|
||||
|
||||
template<length_t L, typename T, qualifier Q, bool Aligned>
|
||||
@ -123,9 +131,13 @@ namespace detail
|
||||
}
|
||||
|
||||
// sqrt
|
||||
using std::sqrt;
|
||||
// BEGIN @MEWIN - 2023-01-12 - Made some math functions constexpr using gcem.
|
||||
using GLM_MATH_BASE_NS::sqrt;
|
||||
// END @MEWIN
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> sqrt(vec<L, T, Q> const& x)
|
||||
// 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_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,7 +7,9 @@ namespace detail
|
||||
template<length_t L, typename T, qualifier Q, bool Aligned>
|
||||
struct compute_length
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static T call(vec<L, T, Q> const& v)
|
||||
// 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
|
||||
{
|
||||
return sqrt(dot(v, v));
|
||||
}
|
||||
@ -16,7 +18,9 @@ namespace detail
|
||||
template<length_t L, typename T, qualifier Q, bool Aligned>
|
||||
struct compute_distance
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static T call(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1)
|
||||
// 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
|
||||
{
|
||||
return length(p1 - p0);
|
||||
}
|
||||
@ -125,7 +129,9 @@ namespace detail
|
||||
|
||||
// length
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType length(genType x)
|
||||
// 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_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'length' accepts only floating-point inputs");
|
||||
|
||||
@ -133,7 +139,9 @@ namespace detail
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T length(vec<L, T, Q> const& v)
|
||||
// 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_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'length' accepts only floating-point inputs");
|
||||
|
||||
@ -142,7 +150,9 @@ namespace detail
|
||||
|
||||
// distance
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType distance(genType const& p0, genType const& p1)
|
||||
// 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_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'distance' accepts only floating-point inputs");
|
||||
|
||||
@ -150,7 +160,9 @@ namespace detail
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T distance(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1)
|
||||
// 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
|
||||
{
|
||||
return detail::compute_distance<L, T, Q, detail::is_aligned<Q>::value>::call(p0, p1);
|
||||
}
|
||||
|
@ -308,7 +308,26 @@
|
||||
# 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,6 +20,12 @@
|
||||
#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
|
||||
@ -91,7 +97,9 @@ 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>
|
||||
GLM_FUNC_DECL vec<L, T, Q> sqrt(vec<L, T, Q> const& v);
|
||||
// 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
|
||||
|
||||
/// Returns the reciprocal of the positive square root of v.
|
||||
///
|
||||
|
@ -27,7 +27,9 @@ 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>
|
||||
GLM_FUNC_DECL T length(vec<L, T, Q> const& x);
|
||||
// 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
|
||||
|
||||
/// Returns the distance between p0 and p1, i.e., length(p0 - p1).
|
||||
///
|
||||
@ -37,7 +39,9 @@ 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>
|
||||
GLM_FUNC_DECL T distance(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1);
|
||||
// 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
|
||||
|
||||
/// Returns the dot product of x and y, i.e., result = x * y.
|
||||
///
|
||||
|
55
glm/gtx/spaceship.hpp
Normal file
55
glm/gtx/spaceship.hpp
Normal file
@ -0,0 +1,55 @@
|
||||
// @MEWIN - 2023-01-02 - Added support for spaceship operator.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <compare>
|
||||
#include "../detail/qualifier.hpp"
|
||||
#include "../detail/setup.hpp"
|
||||
|
||||
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)
|
||||
{
|
||||
if (left[0] != right[0]) {
|
||||
return left[0] <=> right[0];
|
||||
}
|
||||
if constexpr (L > 1) {
|
||||
if (left[1] != right[1]) {
|
||||
return left[1] <=> right[1];
|
||||
}
|
||||
}
|
||||
if constexpr (L > 2) {
|
||||
if (left[2] != right[2]) {
|
||||
return left[2] <=> right[2];
|
||||
}
|
||||
}
|
||||
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