mirror of
https://github.com/g-truc/glm.git
synced 2024-11-26 02:04:35 +00:00
Fixed swizzle functions and tests
This commit is contained in:
parent
e30685ef96
commit
c7b6cf56e3
@ -59,10 +59,15 @@ option(GLM_TEST_ENABLE_LANG_EXTENSIONS "Enable language extensions" OFF)
|
||||
|
||||
if(GLM_TEST_ENABLE_LANG_EXTENSIONS)
|
||||
set(CMAKE_CXX_EXTENSIONS ON)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
add_compile_options(/Ze)
|
||||
endif()
|
||||
message(STATUS "GLM: Build with C++ language extensions")
|
||||
else()
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
add_compile_options(/Za)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(GLM_TEST_ENABLE_FAST_MATH "Enable fast math optimizations" OFF)
|
||||
|
@ -3,31 +3,30 @@
|
||||
|
||||
#ifndef GLM_SETUP_INCLUDED
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#define GLM_VERSION_MAJOR 0
|
||||
#define GLM_VERSION_MINOR 9
|
||||
#define GLM_VERSION_PATCH 9
|
||||
#define GLM_VERSION_REVISION 0
|
||||
#define GLM_VERSION 990
|
||||
#define GLM_VERSION_REVISION 1
|
||||
#define GLM_VERSION 991
|
||||
|
||||
#define GLM_SETUP_INCLUDED GLM_VERSION
|
||||
|
||||
#if defined(GLM_FORCE_SWIZZLE) && defined(GLM_FORCE_UNRESTRICTED_GENTYPE)
|
||||
# error "Both GLM_FORCE_SWIZZLE and GLM_FORCE_UNRESTRICTED_GENTYPE can't be defined at the same time"
|
||||
#endif
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Active states
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#define GLM_DISABLE 0
|
||||
#define GLM_ENABLE 1
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Messages
|
||||
|
||||
#define GLM_MESSAGES_ENABLED 1
|
||||
#define GLM_MESSAGES_DISABLE 0
|
||||
|
||||
#if defined(GLM_FORCE_MESSAGES)
|
||||
# define GLM_MESSAGES GLM_MESSAGES_ENABLED
|
||||
# define GLM_MESSAGES GLM_ENABLE
|
||||
#else
|
||||
# define GLM_MESSAGES GLM_MESSAGES_DISABLE
|
||||
# define GLM_MESSAGES GLM_DISABLE
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
@ -38,13 +37,13 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Version
|
||||
|
||||
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_VERSION_DISPLAYED)
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_VERSION_DISPLAYED)
|
||||
# define GLM_MESSAGE_VERSION_DISPLAYED
|
||||
# pragma message ("GLM: version 0.9.9.0")
|
||||
# pragma message ("GLM: version 0.9.9.1")
|
||||
#endif//GLM_MESSAGES
|
||||
|
||||
// Report compiler detection
|
||||
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_COMPILER_DISPLAYED)
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_COMPILER_DISPLAYED)
|
||||
# define GLM_MESSAGE_COMPILER_DISPLAYED
|
||||
# if GLM_COMPILER & GLM_COMPILER_CUDA
|
||||
# pragma message("GLM: CUDA compiler detected")
|
||||
@ -61,6 +60,13 @@
|
||||
# endif
|
||||
#endif//GLM_MESSAGES
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Incompatible GLM_FORCE defines
|
||||
|
||||
#if defined(GLM_FORCE_SWIZZLE) && defined(GLM_FORCE_UNRESTRICTED_GENTYPE)
|
||||
# error "Both GLM_FORCE_SWIZZLE and GLM_FORCE_UNRESTRICTED_GENTYPE can't be defined at the same time"
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Build model
|
||||
|
||||
@ -76,7 +82,7 @@
|
||||
# error "GLM_MODEL undefined, your compiler may not be supported by GLM. Add #define GLM_MODEL 0 to ignore this message."
|
||||
#endif//GLM_MODEL
|
||||
|
||||
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_MODEL_DISPLAYED)
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_MODEL_DISPLAYED)
|
||||
# define GLM_MESSAGE_MODEL_DISPLAYED
|
||||
# if(GLM_MODEL == GLM_MODEL_64)
|
||||
# pragma message("GLM: 64 bits model")
|
||||
@ -85,7 +91,7 @@
|
||||
# endif//GLM_MODEL
|
||||
#endif//GLM_MESSAGES
|
||||
|
||||
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_ARCH_DISPLAYED)
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_ARCH_DISPLAYED)
|
||||
# define GLM_MESSAGE_ARCH_DISPLAYED
|
||||
# if(GLM_ARCH == GLM_ARCH_PURE)
|
||||
# pragma message("GLM: Platform independent code")
|
||||
@ -158,14 +164,14 @@
|
||||
#endif
|
||||
|
||||
#if defined(GLM_FORCE_CXX2A)
|
||||
# if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_FORCE_CXX2A_DISPLAYED)
|
||||
# if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_FORCE_CXX2A_DISPLAYED)
|
||||
# define GLM_MESSAGE_FORCE_CXX2A_DISPLAYED
|
||||
# pragma message("GLM: Force the use of C++2a only")
|
||||
# endif//GLM_MESSAGES
|
||||
# define GLM_LANG (GLM_LANG_CXX2A | GLM_MSC_EXT)
|
||||
# define GLM_LANG_STL11_FORCED
|
||||
#elif defined(GLM_FORCE_CXX17)
|
||||
# if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_FORCE_CXX17_DISPLAYED)
|
||||
# if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_FORCE_CXX17_DISPLAYED)
|
||||
# define GLM_MESSAGE_FORCE_CXX17_DISPLAYED
|
||||
# if (__cplusplus >= 201703L) || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC15_7)) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC80)) || ((GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER >= GLM_COMPILER_CLANG50))
|
||||
# pragma message("GLM: Force the use of C++17 only")
|
||||
@ -176,7 +182,7 @@
|
||||
# define GLM_LANG (GLM_LANG_CXX17 | GLM_MSC_EXT)
|
||||
# define GLM_LANG_STL11_FORCED
|
||||
#elif defined(GLM_FORCE_CXX14)
|
||||
# if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_FORCE_CXX14_DISPLAYED)
|
||||
# if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_FORCE_CXX14_DISPLAYED)
|
||||
# define GLM_MESSAGE_FORCE_CXX14_DISPLAYED
|
||||
# if (__cplusplus >= 201402L) || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC15)) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC50)) || ((GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER >= GLM_COMPILER_CLANG34))
|
||||
# pragma message("GLM: Force the use of C++14 only")
|
||||
@ -187,7 +193,7 @@
|
||||
# define GLM_LANG (GLM_LANG_CXX14 | GLM_MSC_EXT)
|
||||
# define GLM_LANG_STL11_FORCED
|
||||
#elif defined(GLM_FORCE_CXX11)
|
||||
# if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_FORCE_CXX11_DISPLAYED)
|
||||
# if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_FORCE_CXX11_DISPLAYED)
|
||||
# define GLM_MESSAGE_FORCE_CXX11_DISPLAYED
|
||||
# if (__cplusplus >= 201103L) || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14)) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC49)) || ((GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER >= GLM_COMPILER_CLANG33))
|
||||
# pragma message("GLM: Force the use of C++11 only")
|
||||
@ -217,7 +223,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_LANG_DISPLAYED)
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_LANG_DISPLAYED)
|
||||
# define GLM_MESSAGE_LANG_DISPLAYED
|
||||
|
||||
# if GLM_LANG & GLM_LANG_CXX17_FLAG
|
||||
@ -237,7 +243,7 @@
|
||||
# endif//GLM_LANG
|
||||
|
||||
# if GLM_LANG & (GLM_LANG_CXXGNU_FLAG | GLM_LANG_CXXMS_FLAG)
|
||||
# pragma message("GLM: Language extensions enabled")
|
||||
# pragma message("GLM: C++ language extensions enabled")
|
||||
# endif//GLM_LANG
|
||||
#endif//GLM_MESSAGES
|
||||
|
||||
@ -416,12 +422,6 @@
|
||||
# define GLM_CONSTEXPR_CXX14
|
||||
#endif
|
||||
|
||||
//
|
||||
#define GLM_HAS_ONLY_XYZW ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER < GLM_COMPILER_GCC46))
|
||||
#if GLM_HAS_ONLY_XYZW
|
||||
# pragma message("GLM: GCC older than 4.6 has a bug presenting the use of rgba and stpq components")
|
||||
#endif
|
||||
|
||||
//
|
||||
#if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
# define GLM_HAS_ASSIGNABLE 1
|
||||
@ -555,18 +555,15 @@
|
||||
|
||||
// User defines: GLM_FORCE_SWIZZLE
|
||||
|
||||
#define GLM_SWIZZLE_ENABLED 1
|
||||
#define GLM_SWIZZLE_DISABLE 0
|
||||
|
||||
#if defined(GLM_FORCE_SWIZZLE) && (GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
# define GLM_SWIZZLE GLM_SWIZZLE_ENABLED
|
||||
#if defined(GLM_FORCE_SWIZZLE)
|
||||
# define GLM_SWIZZLE GLM_ENABLE
|
||||
#else
|
||||
# define GLM_SWIZZLE GLM_SWIZZLE_DISABLE
|
||||
# define GLM_SWIZZLE GLM_DISABLE
|
||||
#endif
|
||||
|
||||
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED)
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED)
|
||||
# define GLM_MESSAGE_SWIZZLE_DISPLAYED
|
||||
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_SWIZZLE == GLM_ENABLE
|
||||
# pragma message("GLM: Swizzling operators enabled")
|
||||
# else
|
||||
# pragma message("GLM: Swizzling operators disabled, #define GLM_FORCE_SWIZZLE to enable swizzle operators")
|
||||
@ -584,7 +581,7 @@
|
||||
# define GLM_UNRESTRICTED_GENTYPE 0
|
||||
#endif
|
||||
|
||||
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_UNRESTRICTED_GENTYPE_DISPLAYED)
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_UNRESTRICTED_GENTYPE_DISPLAYED)
|
||||
# define GLM_MESSAGE_UNRESTRICTED_GENTYPE_DISPLAYED
|
||||
# ifdef GLM_FORCE_UNRESTRICTED_GENTYPE
|
||||
# pragma message("GLM: Use unrestricted genType")
|
||||
@ -594,7 +591,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Force single only (remove explicit float64 types)
|
||||
|
||||
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_SINGLE_ONLY_DISPLAYED)
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_SINGLE_ONLY_DISPLAYED)
|
||||
# define GLM_MESSAGE_SINGLE_ONLY_DISPLAYED
|
||||
# ifdef GLM_FORCE_SINGLE_ONLY
|
||||
# pragma message("GLM: Using only single precision floating-point types")
|
||||
@ -613,7 +610,7 @@
|
||||
# define GLM_DEPTH_CLIP_SPACE GLM_DEPTH_NEGATIVE_ONE_TO_ONE
|
||||
#endif
|
||||
|
||||
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_DEPTH_DISPLAYED)
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_DEPTH_DISPLAYED)
|
||||
# define GLM_MESSAGE_DEPTH_DISPLAYED
|
||||
# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE
|
||||
# pragma message("GLM: Depth clip space: Zero to one")
|
||||
@ -635,7 +632,7 @@
|
||||
# define GLM_COORDINATE_SYSTEM GLM_RIGHT_HANDED
|
||||
#endif
|
||||
|
||||
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_HANDED_DISPLAYED)
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_HANDED_DISPLAYED)
|
||||
# define GLM_MESSAGE_HANDED_DISPLAYED
|
||||
# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED
|
||||
# pragma message("GLM: Coordinate system: left handed")
|
||||
@ -739,7 +736,7 @@ namespace glm
|
||||
# endif
|
||||
}//namespace glm
|
||||
|
||||
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_FORCE_SIZE_T_LENGTH)
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_FORCE_SIZE_T_LENGTH)
|
||||
# define GLM_MESSAGE_FORCE_SIZE_T_LENGTH
|
||||
# if defined GLM_FORCE_SIZE_T_LENGTH
|
||||
# pragma message("GLM: .length() returns glm::length_t, a typedef of std::size_t")
|
||||
|
@ -4,8 +4,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "type_vec.hpp"
|
||||
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_LANG & GLM_LANG_CXXMS_FLAG
|
||||
#if GLM_SWIZZLE == GLM_ENABLE
|
||||
# if GLM_HAS_ANONYMOUS_STRUCT
|
||||
# include "_swizzle.hpp"
|
||||
# else
|
||||
# include "_swizzle_func.hpp"
|
||||
@ -26,10 +26,7 @@ namespace glm
|
||||
|
||||
// -- Data --
|
||||
|
||||
# if GLM_HAS_ONLY_XYZW
|
||||
T x, y;
|
||||
|
||||
# elif GLM_LANG & GLM_LANG_CXXMS_FLAG
|
||||
# if GLM_HAS_ANONYMOUS_STRUCT
|
||||
union
|
||||
{
|
||||
struct{ T x, y; };
|
||||
@ -38,7 +35,7 @@ namespace glm
|
||||
|
||||
typename detail::storage<2, T, detail::is_aligned<Q>::value>::type data;
|
||||
|
||||
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_SWIZZLE == GLM_ENABLE
|
||||
GLM_SWIZZLE2_2_MEMBERS(T, Q, x, y)
|
||||
GLM_SWIZZLE2_2_MEMBERS(T, Q, r, g)
|
||||
GLM_SWIZZLE2_2_MEMBERS(T, Q, s, t)
|
||||
@ -54,9 +51,9 @@ namespace glm
|
||||
union {T x, r, s;};
|
||||
union {T y, g, t;};
|
||||
|
||||
//# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
// GLM_SWIZZLE_GEN_VEC_FROM_VEC2(T, Q)
|
||||
//# endif//GLM_SWIZZLE
|
||||
# if GLM_SWIZZLE == GLM_ENABLE
|
||||
GLM_SWIZZLE_GEN_VEC_FROM_VEC2(T, Q)
|
||||
# endif//GLM_SWIZZLE
|
||||
# endif
|
||||
|
||||
// -- Component accesses --
|
||||
@ -109,13 +106,13 @@ namespace glm
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 GLM_EXPLICIT vec(vec<2, U, P> const& v);
|
||||
|
||||
// -- Swizzle constructors --
|
||||
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_HAS_ANONYMOUS_STRUCT && GLM_SWIZZLE == GLM_ENABLE
|
||||
template<int E0, int E1>
|
||||
GLM_FUNC_DECL vec(detail::_swizzle<2, T, Q, E0, E1,-1,-2> const& that)
|
||||
{
|
||||
*this = that();
|
||||
}
|
||||
# endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# endif//GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
// -- Unary arithmetic operators --
|
||||
|
||||
|
@ -4,13 +4,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "type_vec.hpp"
|
||||
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_LANG & GLM_LANG_CXXMS_FLAG
|
||||
#if GLM_SWIZZLE == GLM_ENABLE
|
||||
# if GLM_HAS_ANONYMOUS_STRUCT
|
||||
# include "_swizzle.hpp"
|
||||
# else
|
||||
# include "_swizzle_func.hpp"
|
||||
# endif
|
||||
#endif //GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
#endif //GLM_SWIZZLE == GLM_ENABLE
|
||||
#include <cstddef>
|
||||
|
||||
namespace glm
|
||||
@ -26,10 +26,7 @@ namespace glm
|
||||
|
||||
// -- Data --
|
||||
|
||||
# if GLM_HAS_ONLY_XYZW
|
||||
T x, y, z;
|
||||
|
||||
# elif GLM_LANG & GLM_LANG_CXXMS_FLAG
|
||||
# if GLM_HAS_ANONYMOUS_STRUCT
|
||||
union
|
||||
{
|
||||
struct{ T x, y, z; };
|
||||
@ -38,7 +35,7 @@ namespace glm
|
||||
|
||||
typename detail::storage<3, T, detail::is_aligned<Q>::value>::type data;
|
||||
|
||||
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_SWIZZLE == GLM_ENABLE
|
||||
GLM_SWIZZLE3_2_MEMBERS(T, Q, x, y, z)
|
||||
GLM_SWIZZLE3_2_MEMBERS(T, Q, r, g, b)
|
||||
GLM_SWIZZLE3_2_MEMBERS(T, Q, s, t, p)
|
||||
@ -55,9 +52,9 @@ namespace glm
|
||||
union { T y, g, t; };
|
||||
union { T z, b, p; };
|
||||
|
||||
//# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
// GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, Q)
|
||||
//# endif//GLM_SWIZZLE
|
||||
# if GLM_SWIZZLE == GLM_ENABLE
|
||||
GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, Q)
|
||||
# endif//GLM_SWIZZLE
|
||||
# endif//GLM_LANG
|
||||
|
||||
// -- Component accesses --
|
||||
@ -127,7 +124,7 @@ namespace glm
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 GLM_EXPLICIT vec(vec<3, U, P> const& v);
|
||||
|
||||
// -- Swizzle constructors --
|
||||
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_HAS_ANONYMOUS_STRUCT && GLM_SWIZZLE == GLM_ENABLE
|
||||
template<int E0, int E1, int E2>
|
||||
GLM_FUNC_DECL vec(detail::_swizzle<3, T, Q, E0, E1, E2, -1> const& that)
|
||||
{
|
||||
@ -145,7 +142,7 @@ namespace glm
|
||||
{
|
||||
*this = vec(scalar, v());
|
||||
}
|
||||
# endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# endif//GLM_HAS_ANONYMOUS_STRUCT && GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
// -- Unary arithmetic operators --
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "type_vec.hpp"
|
||||
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_LANG & GLM_LANG_CXXMS_FLAG
|
||||
#if GLM_SWIZZLE == GLM_ENABLE
|
||||
# if GLM_HAS_ANONYMOUS_STRUCT
|
||||
# include "_swizzle.hpp"
|
||||
# else
|
||||
# include "_swizzle_func.hpp"
|
||||
@ -26,10 +26,7 @@ namespace glm
|
||||
|
||||
// -- Data --
|
||||
|
||||
# if GLM_HAS_ONLY_XYZW
|
||||
T x, y, z, w;
|
||||
|
||||
# elif GLM_HAS_ANONYMOUS_STRUCT
|
||||
# if GLM_HAS_ANONYMOUS_STRUCT
|
||||
union
|
||||
{
|
||||
struct { T x, y, z, w; };
|
||||
@ -38,7 +35,7 @@ namespace glm
|
||||
|
||||
typename detail::storage<4, T, detail::is_aligned<Q>::value>::type data;
|
||||
|
||||
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_SWIZZLE == GLM_ENABLE
|
||||
GLM_SWIZZLE4_2_MEMBERS(T, Q, x, y, z, w)
|
||||
GLM_SWIZZLE4_2_MEMBERS(T, Q, r, g, b, a)
|
||||
GLM_SWIZZLE4_2_MEMBERS(T, Q, s, t, p, q)
|
||||
@ -56,9 +53,9 @@ namespace glm
|
||||
union { T z, b, p; };
|
||||
union { T w, a, q; };
|
||||
|
||||
//# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
// GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, Q)
|
||||
//# endif//GLM_SWIZZLE
|
||||
# if GLM_SWIZZLE == GLM_ENABLE
|
||||
GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, Q)
|
||||
# endif//GLM_SWIZZLE
|
||||
# endif
|
||||
|
||||
// -- Component accesses --
|
||||
@ -178,7 +175,7 @@ namespace glm
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 GLM_EXPLICIT vec(vec<4, U, P> const& v);
|
||||
|
||||
// -- Swizzle constructors --
|
||||
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_HAS_ANONYMOUS_STRUCT && GLM_SWIZZLE == GLM_ENABLE
|
||||
template<int E0, int E1, int E2, int E3>
|
||||
GLM_FUNC_DECL vec(detail::_swizzle<4, T, Q, E0, E1, E2, E3> const& that)
|
||||
{
|
||||
@ -220,7 +217,7 @@ namespace glm
|
||||
{
|
||||
*this = vec<4, T, Q>(x, v());
|
||||
}
|
||||
# endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# endif//GLM_HAS_ANONYMOUS_STRUCT && GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
// -- Unary arithmetic operators --
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_SWIZZLE == GLM_ENABLE
|
||||
template<qualifier Q, int E0, int E1, int E2, int E3>
|
||||
struct _swizzle_base1<4, float, Q, E0,E1,E2,E3, true> : public _swizzle_base0<float, 4>
|
||||
{
|
||||
@ -49,7 +49,7 @@ namespace detail
|
||||
return Result;
|
||||
}
|
||||
};
|
||||
# endif// GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# endif// GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
template<qualifier Q>
|
||||
struct compute_vec4_add<float, Q, true>
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
#include "../fwd.hpp"
|
||||
#include "../detail/type_vec.hpp"
|
||||
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_LANG & GLM_LANG_CXXMS_FLAG
|
||||
#if GLM_SWIZZLE == GLM_ENABLE
|
||||
# if GLM_HAS_ANONYMOUS_STRUCT
|
||||
# include "../detail/_swizzle.hpp"
|
||||
# else
|
||||
# include "../detail/_swizzle_func.hpp"
|
||||
@ -43,10 +43,7 @@ namespace glm
|
||||
|
||||
// -- Data --
|
||||
|
||||
# if GLM_HAS_ONLY_XYZW
|
||||
T x;
|
||||
|
||||
# elif GLM_LANG & GLM_LANG_CXXMS_FLAG
|
||||
# if GLM_HAS_ANONYMOUS_STRUCT
|
||||
union
|
||||
{
|
||||
T x;
|
||||
@ -55,7 +52,7 @@ namespace glm
|
||||
|
||||
typename detail::storage<1, T, detail::is_aligned<Q>::value>::type data;
|
||||
/*
|
||||
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_SWIZZLE == GLM_ENABLE
|
||||
_GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, x)
|
||||
_GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, r)
|
||||
_GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, s)
|
||||
@ -70,7 +67,7 @@ namespace glm
|
||||
# else
|
||||
union {T x, r, s;};
|
||||
/*
|
||||
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_SWIZZLE == GLM_ENABLE
|
||||
GLM_SWIZZLE_GEN_VEC_FROM_VEC1(T, Q, tvec2, tvec2, tvec3, tvec4)
|
||||
# endif//GLM_SWIZZLE*/
|
||||
# endif
|
||||
@ -113,13 +110,13 @@ namespace glm
|
||||
|
||||
// -- Swizzle constructors --
|
||||
/*
|
||||
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_HAS_ANONYMOUS_STRUCT && GLM_SWIZZLE == GLM_ENABLE
|
||||
template<int E0>
|
||||
GLM_FUNC_DECL tvec(detail::_swizzle<1, T, Q, tvec1, E0, -1,-2,-3> const& that)
|
||||
{
|
||||
*this = that();
|
||||
}
|
||||
# endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# endif//GLM_SWIZZLE == GLM_ENABLE
|
||||
*/
|
||||
// -- Unary arithmetic operators --
|
||||
|
||||
|
@ -50,7 +50,7 @@ int test_vec4_ctor()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_SWIZZLE == GLM_ENABLE && GLM_HAS_ANONYMOUS_STRUCT
|
||||
{
|
||||
glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B = A.xyzw;
|
||||
@ -79,7 +79,36 @@ int test_vec4_ctor()
|
||||
Error += glm::all(glm::equal(A, L)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, M)) ? 0 : 1;
|
||||
}
|
||||
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# elif GLM_SWIZZLE == GLM_ENABLE
|
||||
{
|
||||
glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B = A.xyzw();
|
||||
glm::vec4 C(A.xyzw());
|
||||
glm::vec4 D(A.xyzw());
|
||||
glm::vec4 E(A.x, A.yzw());
|
||||
glm::vec4 F(A.x, A.yzw());
|
||||
glm::vec4 G(A.xyz(), A.w);
|
||||
glm::vec4 H(A.xyz(), A.w);
|
||||
glm::vec4 I(A.xy(), A.zw());
|
||||
glm::vec4 J(A.xy(), A.zw());
|
||||
glm::vec4 K(A.x, A.y, A.zw());
|
||||
glm::vec4 L(A.x, A.yz(), A.w);
|
||||
glm::vec4 M(A.xy(), A.z, A.w);
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, F)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, G)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, H)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, I)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, J)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, K)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, L)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, M)) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
{
|
||||
glm::vec4 A(1);
|
||||
@ -311,7 +340,7 @@ int test_vec4_swizzle_partial()
|
||||
|
||||
glm::vec4 A(1, 2, 3, 4);
|
||||
|
||||
# if GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_SWIZZLE_RELAX)
|
||||
# if GLM_HAS_ANONYMOUS_STRUCT && GLM_SWIZZLE == GLM_ENABLE
|
||||
{
|
||||
glm::vec4 B(A.xy, A.zw);
|
||||
Error += A == B ? 0 : 1;
|
||||
|
@ -2,20 +2,18 @@
|
||||
#define GLM_FORCE_SWIZZLE
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#if !GLM_HAS_ONLY_XYZW
|
||||
|
||||
static int test_ivec2_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
#if GLM_SWIZZLE == GLM_ENABLE
|
||||
glm::ivec2 A(1, 2);
|
||||
glm::ivec2 B = A.yx();
|
||||
glm::ivec2 C = B.yx();
|
||||
|
||||
Error += A != B ? 0 : 1;
|
||||
Error += A == C ? 0 : 1;
|
||||
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
#endif//GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
return Error;
|
||||
}
|
||||
@ -24,14 +22,14 @@ int test_ivec3_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
#if GLM_SWIZZLE == GLM_ENABLE
|
||||
glm::ivec3 A(1, 2, 3);
|
||||
glm::ivec3 B = A.zyx();
|
||||
glm::ivec3 C = B.zyx();
|
||||
|
||||
Error += A != B ? 0 : 1;
|
||||
Error += A == C ? 0 : 1;
|
||||
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
#endif//GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
return Error;
|
||||
}
|
||||
@ -40,14 +38,14 @@ int test_ivec4_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
#if GLM_SWIZZLE == GLM_ENABLE
|
||||
glm::ivec4 A(1, 2, 3, 4);
|
||||
glm::ivec4 B = A.wzyx();
|
||||
glm::ivec4 C = B.wzyx();
|
||||
|
||||
Error += A != B ? 0 : 1;
|
||||
Error += A == C ? 0 : 1;
|
||||
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
#endif//GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
return Error;
|
||||
}
|
||||
@ -56,7 +54,7 @@ int test_vec4_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
#if GLM_SWIZZLE == GLM_ENABLE
|
||||
glm::vec4 A(1, 2, 3, 4);
|
||||
glm::vec4 B = A.wzyx();
|
||||
glm::vec4 C = B.wzyx();
|
||||
@ -66,23 +64,19 @@ int test_vec4_swizzle()
|
||||
|
||||
float f = glm::dot(C.wzyx(), C.xyzw());
|
||||
Error += glm::abs(f - 20.f) < 0.01f ? 0 : 1;
|
||||
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
#endif//GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
return Error;
|
||||
}
|
||||
#endif//!GLM_HAS_ONLY_XYZW
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if !GLM_HAS_ONLY_XYZW
|
||||
Error += test_ivec2_swizzle();
|
||||
Error += test_ivec3_swizzle();
|
||||
Error += test_ivec4_swizzle();
|
||||
|
||||
Error += test_vec4_swizzle();
|
||||
# endif//!GLM_HAS_ONLY_XYZW
|
||||
Error += test_ivec2_swizzle();
|
||||
Error += test_ivec3_swizzle();
|
||||
Error += test_ivec4_swizzle();
|
||||
Error += test_vec4_swizzle();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
@ -69,18 +69,6 @@ int test_vec1_ctor()
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
{
|
||||
glm::vec2 A = glm::vec2(1.0f, 2.0f);
|
||||
glm::vec2 B = A.xy;
|
||||
glm::vec2 C(A.xy);
|
||||
glm::vec2 D(A.xy());
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
}
|
||||
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
|
||||
{
|
||||
glm::vec2 A = glm::vec2(2.0f);
|
||||
@ -137,6 +125,24 @@ static int test_vec1_operator_increment()
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#if GLM_HAS_ANONYMOUS_STRUCT && GLM_SWIZZLE == GLM_ENABLE
|
||||
{
|
||||
glm::vec1 A = glm::vec1(1.0f);
|
||||
//glm::vec1 B = A.x;
|
||||
glm::vec1 C(A.x);
|
||||
|
||||
//Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
}
|
||||
#endif//GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR_CXX14
|
||||
@ -155,6 +161,7 @@ int main()
|
||||
Error += test_vec1_ctor();
|
||||
Error += test_vec1_operators();
|
||||
Error += test_vec1_operator_increment();
|
||||
Error += test_swizzle();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
|
@ -236,19 +236,6 @@ static int test_ctor()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
{
|
||||
glm::vec2 A = glm::vec2(1.0f, 2.0f);
|
||||
glm::vec2 B = A.xy;
|
||||
glm::vec2 C(A.xy);
|
||||
glm::vec2 D(A.xy());
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
}
|
||||
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
|
||||
{
|
||||
glm::vec2 A = glm::vec2(2.0f);
|
||||
glm::vec2 B = glm::vec2(2.0f, 3.0f);
|
||||
@ -357,6 +344,35 @@ static int test_constexpr()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_SWIZZLE == GLM_ENABLE && GLM_HAS_ANONYMOUS_STRUCT
|
||||
{
|
||||
glm::vec2 A = glm::vec2(1.0f, 2.0f);
|
||||
glm::vec2 B = A.xy;
|
||||
glm::vec2 C(A.xy);
|
||||
glm::vec2 D(A.xy());
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
}
|
||||
# elif GLM_SWIZZLE == GLM_ENABLE
|
||||
{
|
||||
glm::vec2 A = glm::vec2(1.0f, 2.0f);
|
||||
glm::vec2 B = A.xy();
|
||||
glm::vec2 C(A.xy());
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
@ -365,6 +381,7 @@ int main()
|
||||
Error += test_ctor();
|
||||
Error += test_operators();
|
||||
Error += test_operator_increment();
|
||||
Error += test_swizzle();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
|
@ -27,7 +27,7 @@ int test_vec3_ctor()
|
||||
Error += std::is_copy_constructible<glm::vec3>::value ? 0 : 1;
|
||||
# endif
|
||||
|
||||
#if (GLM_HAS_INITIALIZER_LISTS)
|
||||
# if GLM_HAS_INITIALIZER_LISTS
|
||||
{
|
||||
glm::vec3 a{ 0, 1, 2 };
|
||||
std::vector<glm::vec3> v = {
|
||||
@ -43,28 +43,7 @@ int test_vec3_ctor()
|
||||
{4, 5, 6},
|
||||
{8, 9, 0}};
|
||||
}
|
||||
#endif
|
||||
|
||||
#if(GLM_LANG & GLM_LANG_CXXMS_FLAG && defined(GLM_FORCE_SWIZZLE))
|
||||
{
|
||||
glm::vec3 A = glm::vec3(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B = A.xyz;
|
||||
glm::vec3 C(A.xyz);
|
||||
glm::vec3 D(A.xyz());
|
||||
glm::vec3 E(A.x, A.yz);
|
||||
glm::vec3 F(A.x, A.yz());
|
||||
glm::vec3 G(A.xy, A.z);
|
||||
glm::vec3 H(A.xy(), A.z);
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, F)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, G)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, H)) ? 0 : 1;
|
||||
}
|
||||
#endif//(GLM_LANG & GLM_LANG_CXXMS_FLAG && defined(GLM_FORCE_SWIZZLE))
|
||||
# endif
|
||||
|
||||
{
|
||||
glm::vec3 A(1);
|
||||
@ -338,7 +317,7 @@ int test_vec3_swizzle3_2()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
# if GLM_SWIZZLE == GLM_ENABLE && GLM_HAS_ANONYMOUS_STRUCT
|
||||
|
||||
glm::vec3 v(1, 2, 3);
|
||||
glm::vec2 u;
|
||||
@ -402,7 +381,7 @@ int test_vec3_swizzle3_3()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
# if GLM_SWIZZLE == GLM_ENABLE && GLM_HAS_ANONYMOUS_STRUCT
|
||||
glm::vec3 v(1, 2, 3);
|
||||
glm::vec3 u;
|
||||
|
||||
@ -424,7 +403,6 @@ int test_vec3_swizzle3_3()
|
||||
return Error;
|
||||
}
|
||||
|
||||
#if !GLM_HAS_ONLY_XYZW
|
||||
int test_vec3_swizzle_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
@ -432,7 +410,7 @@ int test_vec3_swizzle_operators()
|
||||
glm::vec3 u = glm::vec3(1, 2, 3);
|
||||
glm::vec3 v = glm::vec3(10, 20, 30);
|
||||
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
# if GLM_SWIZZLE == GLM_ENABLE && GLM_HAS_ANONYMOUS_STRUCT
|
||||
glm::vec3 q;
|
||||
|
||||
// Swizzle, swizzle binary operators
|
||||
@ -469,7 +447,7 @@ int test_vec3_swizzle_functions()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
# if GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
// NOTE: template functions cannot pick up the implicit conversion from
|
||||
// a swizzle to the unswizzled type, therefore the operator() must be
|
||||
@ -503,7 +481,7 @@ int test_vec3_swizzle_functions()
|
||||
r = glm::dot(s.xyzw(), t.xyzw()); Error += (int(r) == 300) ? 0 : 1;
|
||||
r = glm::dot(s.xyz(), t.xyz()); Error += (int(r) == 140) ? 0 : 1;
|
||||
|
||||
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
#endif//GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
return Error;
|
||||
}
|
||||
@ -512,9 +490,10 @@ int test_vec3_swizzle_partial()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_SWIZZLE == GLM_ENABLE && GLM_HAS_ANONYMOUS_STRUCT
|
||||
|
||||
glm::vec3 A(1, 2, 3);
|
||||
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
{
|
||||
glm::vec3 B(A.xy, 3.0f);
|
||||
Error += A == B ? 0 : 1;
|
||||
@ -529,15 +508,14 @@ int test_vec3_swizzle_partial()
|
||||
glm::vec3 B(A.xyz);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG
|
||||
# endif//GLM_SWIZZLE == GLM_ENABLE && GLM_HAS_ANONYMOUS_STRUCT
|
||||
|
||||
return Error;
|
||||
}
|
||||
#endif//!GLM_HAS_ONLY_XYZW
|
||||
|
||||
static int test_operator_increment()
|
||||
{
|
||||
int Error(0);
|
||||
int Error = 0;
|
||||
|
||||
glm::ivec3 v0(1);
|
||||
glm::ivec3 v1(v0);
|
||||
@ -562,6 +540,53 @@ static int test_operator_increment()
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_SWIZZLE == GLM_ENABLE && GLM_HAS_ANONYMOUS_STRUCT
|
||||
{
|
||||
glm::vec3 A = glm::vec3(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B = A.xyz;
|
||||
glm::vec3 C(A.xyz);
|
||||
glm::vec3 D(A.xyz());
|
||||
glm::vec3 E(A.x, A.yz);
|
||||
glm::vec3 F(A.x, A.yz());
|
||||
glm::vec3 G(A.xy, A.z);
|
||||
glm::vec3 H(A.xy(), A.z);
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, F)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, G)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, H)) ? 0 : 1;
|
||||
}
|
||||
# elif GLM_SWIZZLE == GLM_ENABLE
|
||||
{
|
||||
glm::vec3 A = glm::vec3(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B = A.xyz();
|
||||
glm::vec3 C(A.xyz());
|
||||
glm::vec3 D(A.xyz());
|
||||
glm::vec3 E(A.x, A.yz());
|
||||
glm::vec3 F(A.x, A.yz());
|
||||
glm::vec3 G(A.xy(), A.z);
|
||||
glm::vec3 H(A.xy(), A.z);
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, F)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, G)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, H)) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR_CXX14
|
||||
@ -583,16 +608,15 @@ int main()
|
||||
Error += test_bvec3_ctor();
|
||||
Error += test_vec3_operators();
|
||||
Error += test_vec3_size();
|
||||
Error += test_vec3_swizzle3_2();
|
||||
Error += test_vec3_swizzle3_3();
|
||||
Error += test_operator_increment();
|
||||
Error += test_constexpr();
|
||||
|
||||
# if !GLM_HAS_ONLY_XYZW
|
||||
Error += test_vec3_swizzle_partial();
|
||||
Error += test_vec3_swizzle_operators();
|
||||
Error += test_vec3_swizzle_functions();
|
||||
# endif//!GLM_HAS_ONLY_XYZW
|
||||
Error += test_swizzle();
|
||||
Error += test_vec3_swizzle3_2();
|
||||
Error += test_vec3_swizzle3_3();
|
||||
Error += test_vec3_swizzle_partial();
|
||||
Error += test_vec3_swizzle_operators();
|
||||
Error += test_vec3_swizzle_functions();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
@ -74,37 +74,6 @@ static int test_vec4_ctor()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
{
|
||||
glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B = A.xyzw;
|
||||
glm::vec4 C(A.xyzw);
|
||||
glm::vec4 D(A.xyzw());
|
||||
glm::vec4 E(A.x, A.yzw);
|
||||
glm::vec4 F(A.x, A.yzw());
|
||||
glm::vec4 G(A.xyz, A.w);
|
||||
glm::vec4 H(A.xyz(), A.w);
|
||||
glm::vec4 I(A.xy, A.zw);
|
||||
glm::vec4 J(A.xy(), A.zw());
|
||||
glm::vec4 K(A.x, A.y, A.zw);
|
||||
glm::vec4 L(A.x, A.yz, A.w);
|
||||
glm::vec4 M(A.xy, A.z, A.w);
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, F)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, G)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, H)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, I)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, J)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, K)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, L)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, M)) ? 0 : 1;
|
||||
}
|
||||
#endif// GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
|
||||
|
||||
{
|
||||
glm::vec4 A(1);
|
||||
glm::vec4 B(1, 1, 1, 1);
|
||||
@ -516,7 +485,7 @@ static int test_swizzle_partial()
|
||||
|
||||
glm::vec4 A(1, 2, 3, 4);
|
||||
|
||||
# if GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_SWIZZLE_RELAX)
|
||||
# if GLM_SWIZZLE == GLM_ENABLE && GLM_HAS_ANONYMOUS_STRUCT
|
||||
{
|
||||
glm::vec4 B(A.xy, A.zw);
|
||||
Error += A == B ? 0 : 1;
|
||||
@ -542,7 +511,74 @@ static int test_swizzle_partial()
|
||||
glm::vec4 B(1.0f, A.yzw);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
# endif
|
||||
# endif//GLM_SWIZZLE == GLM_ENABLE
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_SWIZZLE == GLM_ENABLE && GLM_HAS_ANONYMOUS_STRUCT
|
||||
{
|
||||
glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B = A.xyzw;
|
||||
glm::vec4 C(A.xyzw);
|
||||
glm::vec4 D(A.xyzw());
|
||||
glm::vec4 E(A.x, A.yzw);
|
||||
glm::vec4 F(A.x, A.yzw());
|
||||
glm::vec4 G(A.xyz, A.w);
|
||||
glm::vec4 H(A.xyz(), A.w);
|
||||
glm::vec4 I(A.xy, A.zw);
|
||||
glm::vec4 J(A.xy(), A.zw());
|
||||
glm::vec4 K(A.x, A.y, A.zw);
|
||||
glm::vec4 L(A.x, A.yz, A.w);
|
||||
glm::vec4 M(A.xy, A.z, A.w);
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, F)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, G)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, H)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, I)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, J)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, K)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, L)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, M)) ? 0 : 1;
|
||||
}
|
||||
# elif GLM_SWIZZLE == GLM_ENABLE
|
||||
{
|
||||
glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B = A.xyzw();
|
||||
glm::vec4 C(A.xyzw());
|
||||
glm::vec4 D(A.xyzw());
|
||||
glm::vec4 E(A.x, A.yzw());
|
||||
glm::vec4 F(A.x, A.yzw());
|
||||
glm::vec4 G(A.xyz(), A.w);
|
||||
glm::vec4 H(A.xyz(), A.w);
|
||||
glm::vec4 I(A.xy(), A.zw());
|
||||
glm::vec4 J(A.xy(), A.zw());
|
||||
glm::vec4 K(A.x, A.y, A.zw());
|
||||
glm::vec4 L(A.x, A.yz(), A.w);
|
||||
glm::vec4 M(A.xy(), A.z, A.w);
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, F)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, G)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, H)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, I)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, J)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, K)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, L)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, M)) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_SWIZZLE == GLM_ENABLE && GLM_HAS_ANONYMOUS_STRUCT
|
||||
|
||||
return Error;
|
||||
}
|
||||
@ -782,6 +818,7 @@ int main()
|
||||
Error += test_size();
|
||||
Error += test_operators();
|
||||
Error += test_equal();
|
||||
Error += test_swizzle();
|
||||
Error += test_swizzle_partial();
|
||||
Error += test_simd();
|
||||
Error += test_operator_increment();
|
||||
|
@ -1,4 +1,6 @@
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/glm.hpp>
|
||||
#if GLM_LANG & GLM_LANG_CXXMS_FLAG
|
||||
#include <glm/gtc/type_precision.hpp>
|
||||
#include <glm/gtx/io.hpp>
|
||||
#include <iostream>
|
||||
@ -174,3 +176,11 @@ int main()
|
||||
|
||||
return Error;
|
||||
}
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif// GLM_LANG & GLM_LANG_CXXMS_FLAG
|
Loading…
Reference in New Issue
Block a user