Fixed swizzle functions and tests

This commit is contained in:
Groove 2018-07-12 00:36:59 +02:00
parent e30685ef96
commit c7b6cf56e3
14 changed files with 319 additions and 211 deletions

View File

@ -59,10 +59,15 @@ option(GLM_TEST_ENABLE_LANG_EXTENSIONS "Enable language extensions" OFF)
if(GLM_TEST_ENABLE_LANG_EXTENSIONS) if(GLM_TEST_ENABLE_LANG_EXTENSIONS)
set(CMAKE_CXX_EXTENSIONS ON) 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") message(STATUS "GLM: Build with C++ language extensions")
else() else()
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/Za)
endif()
endif() endif()
option(GLM_TEST_ENABLE_FAST_MATH "Enable fast math optimizations" OFF) option(GLM_TEST_ENABLE_FAST_MATH "Enable fast math optimizations" OFF)

View File

@ -3,31 +3,30 @@
#ifndef GLM_SETUP_INCLUDED #ifndef GLM_SETUP_INCLUDED
#include <cassert>
#include <cstddef>
#define GLM_VERSION_MAJOR 0 #define GLM_VERSION_MAJOR 0
#define GLM_VERSION_MINOR 9 #define GLM_VERSION_MINOR 9
#define GLM_VERSION_PATCH 9 #define GLM_VERSION_PATCH 9
#define GLM_VERSION_REVISION 0 #define GLM_VERSION_REVISION 1
#define GLM_VERSION 990 #define GLM_VERSION 991
#define GLM_SETUP_INCLUDED GLM_VERSION #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" // Active states
#endif
#include <cassert> #define GLM_DISABLE 0
#include <cstddef> #define GLM_ENABLE 1
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
// Messages // Messages
#define GLM_MESSAGES_ENABLED 1
#define GLM_MESSAGES_DISABLE 0
#if defined(GLM_FORCE_MESSAGES) #if defined(GLM_FORCE_MESSAGES)
# define GLM_MESSAGES GLM_MESSAGES_ENABLED # define GLM_MESSAGES GLM_ENABLE
#else #else
# define GLM_MESSAGES GLM_MESSAGES_DISABLE # define GLM_MESSAGES GLM_DISABLE
#endif #endif
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
@ -38,13 +37,13 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
// Version // 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 # define GLM_MESSAGE_VERSION_DISPLAYED
# pragma message ("GLM: version 0.9.9.0") # pragma message ("GLM: version 0.9.9.1")
#endif//GLM_MESSAGES #endif//GLM_MESSAGES
// Report compiler detection // 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 # define GLM_MESSAGE_COMPILER_DISPLAYED
# if GLM_COMPILER & GLM_COMPILER_CUDA # if GLM_COMPILER & GLM_COMPILER_CUDA
# pragma message("GLM: CUDA compiler detected") # pragma message("GLM: CUDA compiler detected")
@ -61,6 +60,13 @@
# endif # endif
#endif//GLM_MESSAGES #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 // 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." # error "GLM_MODEL undefined, your compiler may not be supported by GLM. Add #define GLM_MODEL 0 to ignore this message."
#endif//GLM_MODEL #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 # define GLM_MESSAGE_MODEL_DISPLAYED
# if(GLM_MODEL == GLM_MODEL_64) # if(GLM_MODEL == GLM_MODEL_64)
# pragma message("GLM: 64 bits model") # pragma message("GLM: 64 bits model")
@ -85,7 +91,7 @@
# endif//GLM_MODEL # endif//GLM_MODEL
#endif//GLM_MESSAGES #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 # define GLM_MESSAGE_ARCH_DISPLAYED
# if(GLM_ARCH == GLM_ARCH_PURE) # if(GLM_ARCH == GLM_ARCH_PURE)
# pragma message("GLM: Platform independent code") # pragma message("GLM: Platform independent code")
@ -158,14 +164,14 @@
#endif #endif
#if defined(GLM_FORCE_CXX2A) #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 # define GLM_MESSAGE_FORCE_CXX2A_DISPLAYED
# pragma message("GLM: Force the use of C++2a only") # pragma message("GLM: Force the use of C++2a only")
# endif//GLM_MESSAGES # endif//GLM_MESSAGES
# define GLM_LANG (GLM_LANG_CXX2A | GLM_MSC_EXT) # define GLM_LANG (GLM_LANG_CXX2A | GLM_MSC_EXT)
# define GLM_LANG_STL11_FORCED # define GLM_LANG_STL11_FORCED
#elif defined(GLM_FORCE_CXX17) #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 # 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)) # 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") # 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 (GLM_LANG_CXX17 | GLM_MSC_EXT)
# define GLM_LANG_STL11_FORCED # define GLM_LANG_STL11_FORCED
#elif defined(GLM_FORCE_CXX14) #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 # 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)) # 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") # 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 (GLM_LANG_CXX14 | GLM_MSC_EXT)
# define GLM_LANG_STL11_FORCED # define GLM_LANG_STL11_FORCED
#elif defined(GLM_FORCE_CXX11) #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 # 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)) # 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") # pragma message("GLM: Force the use of C++11 only")
@ -217,7 +223,7 @@
# endif # endif
#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 # define GLM_MESSAGE_LANG_DISPLAYED
# if GLM_LANG & GLM_LANG_CXX17_FLAG # if GLM_LANG & GLM_LANG_CXX17_FLAG
@ -237,7 +243,7 @@
# endif//GLM_LANG # endif//GLM_LANG
# if GLM_LANG & (GLM_LANG_CXXGNU_FLAG | GLM_LANG_CXXMS_FLAG) # 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_LANG
#endif//GLM_MESSAGES #endif//GLM_MESSAGES
@ -416,12 +422,6 @@
# define GLM_CONSTEXPR_CXX14 # define GLM_CONSTEXPR_CXX14
#endif #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 #if GLM_LANG & GLM_LANG_CXX11_FLAG
# define GLM_HAS_ASSIGNABLE 1 # define GLM_HAS_ASSIGNABLE 1
@ -555,18 +555,15 @@
// User defines: GLM_FORCE_SWIZZLE // User defines: GLM_FORCE_SWIZZLE
#define GLM_SWIZZLE_ENABLED 1 #if defined(GLM_FORCE_SWIZZLE)
#define GLM_SWIZZLE_DISABLE 0 # define GLM_SWIZZLE GLM_ENABLE
#if defined(GLM_FORCE_SWIZZLE) && (GLM_LANG & GLM_LANG_CXXMS_FLAG)
# define GLM_SWIZZLE GLM_SWIZZLE_ENABLED
#else #else
# define GLM_SWIZZLE GLM_SWIZZLE_DISABLE # define GLM_SWIZZLE GLM_DISABLE
#endif #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 # define GLM_MESSAGE_SWIZZLE_DISPLAYED
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_SWIZZLE == GLM_ENABLE
# pragma message("GLM: Swizzling operators enabled") # pragma message("GLM: Swizzling operators enabled")
# else # else
# pragma message("GLM: Swizzling operators disabled, #define GLM_FORCE_SWIZZLE to enable swizzle operators") # pragma message("GLM: Swizzling operators disabled, #define GLM_FORCE_SWIZZLE to enable swizzle operators")
@ -584,7 +581,7 @@
# define GLM_UNRESTRICTED_GENTYPE 0 # define GLM_UNRESTRICTED_GENTYPE 0
#endif #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 # define GLM_MESSAGE_UNRESTRICTED_GENTYPE_DISPLAYED
# ifdef GLM_FORCE_UNRESTRICTED_GENTYPE # ifdef GLM_FORCE_UNRESTRICTED_GENTYPE
# pragma message("GLM: Use unrestricted genType") # pragma message("GLM: Use unrestricted genType")
@ -594,7 +591,7 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
// Force single only (remove explicit float64 types) // 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 # define GLM_MESSAGE_SINGLE_ONLY_DISPLAYED
# ifdef GLM_FORCE_SINGLE_ONLY # ifdef GLM_FORCE_SINGLE_ONLY
# pragma message("GLM: Using only single precision floating-point types") # 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 # define GLM_DEPTH_CLIP_SPACE GLM_DEPTH_NEGATIVE_ONE_TO_ONE
#endif #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 # define GLM_MESSAGE_DEPTH_DISPLAYED
# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE # if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE
# pragma message("GLM: Depth clip space: Zero to one") # pragma message("GLM: Depth clip space: Zero to one")
@ -635,7 +632,7 @@
# define GLM_COORDINATE_SYSTEM GLM_RIGHT_HANDED # define GLM_COORDINATE_SYSTEM GLM_RIGHT_HANDED
#endif #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 # define GLM_MESSAGE_HANDED_DISPLAYED
# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED # if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED
# pragma message("GLM: Coordinate system: left handed") # pragma message("GLM: Coordinate system: left handed")
@ -739,7 +736,7 @@ namespace glm
# endif # endif
}//namespace glm }//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 # define GLM_MESSAGE_FORCE_SIZE_T_LENGTH
# if defined GLM_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") # pragma message("GLM: .length() returns glm::length_t, a typedef of std::size_t")

View File

@ -4,8 +4,8 @@
#pragma once #pragma once
#include "type_vec.hpp" #include "type_vec.hpp"
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #if GLM_SWIZZLE == GLM_ENABLE
# if GLM_LANG & GLM_LANG_CXXMS_FLAG # if GLM_HAS_ANONYMOUS_STRUCT
# include "_swizzle.hpp" # include "_swizzle.hpp"
# else # else
# include "_swizzle_func.hpp" # include "_swizzle_func.hpp"
@ -26,10 +26,7 @@ namespace glm
// -- Data -- // -- Data --
# if GLM_HAS_ONLY_XYZW # if GLM_HAS_ANONYMOUS_STRUCT
T x, y;
# elif GLM_LANG & GLM_LANG_CXXMS_FLAG
union union
{ {
struct{ T x, y; }; struct{ T x, y; };
@ -38,7 +35,7 @@ namespace glm
typename detail::storage<2, T, detail::is_aligned<Q>::value>::type data; 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, x, y)
GLM_SWIZZLE2_2_MEMBERS(T, Q, r, g) GLM_SWIZZLE2_2_MEMBERS(T, Q, r, g)
GLM_SWIZZLE2_2_MEMBERS(T, Q, s, t) GLM_SWIZZLE2_2_MEMBERS(T, Q, s, t)
@ -54,9 +51,9 @@ namespace glm
union {T x, r, s;}; union {T x, r, s;};
union {T y, g, t;}; union {T y, g, t;};
//# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_SWIZZLE == GLM_ENABLE
// GLM_SWIZZLE_GEN_VEC_FROM_VEC2(T, Q) GLM_SWIZZLE_GEN_VEC_FROM_VEC2(T, Q)
//# endif//GLM_SWIZZLE # endif//GLM_SWIZZLE
# endif # endif
// -- Component accesses -- // -- Component accesses --
@ -109,13 +106,13 @@ namespace glm
GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 GLM_EXPLICIT vec(vec<2, U, P> const& v); GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 GLM_EXPLICIT vec(vec<2, U, P> const& v);
// -- Swizzle constructors -- // -- Swizzle constructors --
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_HAS_ANONYMOUS_STRUCT && GLM_SWIZZLE == GLM_ENABLE
template<int E0, int E1> template<int E0, int E1>
GLM_FUNC_DECL vec(detail::_swizzle<2, T, Q, E0, E1,-1,-2> const& that) GLM_FUNC_DECL vec(detail::_swizzle<2, T, Q, E0, E1,-1,-2> const& that)
{ {
*this = that(); *this = that();
} }
# endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # endif//GLM_SWIZZLE == GLM_ENABLE
// -- Unary arithmetic operators -- // -- Unary arithmetic operators --

View File

@ -4,13 +4,13 @@
#pragma once #pragma once
#include "type_vec.hpp" #include "type_vec.hpp"
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #if GLM_SWIZZLE == GLM_ENABLE
# if GLM_LANG & GLM_LANG_CXXMS_FLAG # if GLM_HAS_ANONYMOUS_STRUCT
# include "_swizzle.hpp" # include "_swizzle.hpp"
# else # else
# include "_swizzle_func.hpp" # include "_swizzle_func.hpp"
# endif # endif
#endif //GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #endif //GLM_SWIZZLE == GLM_ENABLE
#include <cstddef> #include <cstddef>
namespace glm namespace glm
@ -26,10 +26,7 @@ namespace glm
// -- Data -- // -- Data --
# if GLM_HAS_ONLY_XYZW # if GLM_HAS_ANONYMOUS_STRUCT
T x, y, z;
# elif GLM_LANG & GLM_LANG_CXXMS_FLAG
union union
{ {
struct{ T x, y, z; }; struct{ T x, y, z; };
@ -38,7 +35,7 @@ namespace glm
typename detail::storage<3, T, detail::is_aligned<Q>::value>::type data; 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, x, y, z)
GLM_SWIZZLE3_2_MEMBERS(T, Q, r, g, b) GLM_SWIZZLE3_2_MEMBERS(T, Q, r, g, b)
GLM_SWIZZLE3_2_MEMBERS(T, Q, s, t, p) GLM_SWIZZLE3_2_MEMBERS(T, Q, s, t, p)
@ -55,9 +52,9 @@ namespace glm
union { T y, g, t; }; union { T y, g, t; };
union { T z, b, p; }; union { T z, b, p; };
//# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_SWIZZLE == GLM_ENABLE
// GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, Q) GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, Q)
//# endif//GLM_SWIZZLE # endif//GLM_SWIZZLE
# endif//GLM_LANG # endif//GLM_LANG
// -- Component accesses -- // -- Component accesses --
@ -127,7 +124,7 @@ namespace glm
GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 GLM_EXPLICIT vec(vec<3, U, P> const& v); GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 GLM_EXPLICIT vec(vec<3, U, P> const& v);
// -- Swizzle constructors -- // -- Swizzle constructors --
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_HAS_ANONYMOUS_STRUCT && GLM_SWIZZLE == GLM_ENABLE
template<int E0, int E1, int E2> template<int E0, int E1, int E2>
GLM_FUNC_DECL vec(detail::_swizzle<3, T, Q, E0, E1, E2, -1> const& that) 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()); *this = vec(scalar, v());
} }
# endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # endif//GLM_HAS_ANONYMOUS_STRUCT && GLM_SWIZZLE == GLM_ENABLE
// -- Unary arithmetic operators -- // -- Unary arithmetic operators --

View File

@ -4,8 +4,8 @@
#pragma once #pragma once
#include "type_vec.hpp" #include "type_vec.hpp"
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #if GLM_SWIZZLE == GLM_ENABLE
# if GLM_LANG & GLM_LANG_CXXMS_FLAG # if GLM_HAS_ANONYMOUS_STRUCT
# include "_swizzle.hpp" # include "_swizzle.hpp"
# else # else
# include "_swizzle_func.hpp" # include "_swizzle_func.hpp"
@ -26,10 +26,7 @@ namespace glm
// -- Data -- // -- Data --
# if GLM_HAS_ONLY_XYZW # if GLM_HAS_ANONYMOUS_STRUCT
T x, y, z, w;
# elif GLM_HAS_ANONYMOUS_STRUCT
union union
{ {
struct { T x, y, z, w; }; struct { T x, y, z, w; };
@ -38,7 +35,7 @@ namespace glm
typename detail::storage<4, T, detail::is_aligned<Q>::value>::type data; 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, x, y, z, w)
GLM_SWIZZLE4_2_MEMBERS(T, Q, r, g, b, a) GLM_SWIZZLE4_2_MEMBERS(T, Q, r, g, b, a)
GLM_SWIZZLE4_2_MEMBERS(T, Q, s, t, p, q) GLM_SWIZZLE4_2_MEMBERS(T, Q, s, t, p, q)
@ -56,9 +53,9 @@ namespace glm
union { T z, b, p; }; union { T z, b, p; };
union { T w, a, q; }; union { T w, a, q; };
//# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_SWIZZLE == GLM_ENABLE
// GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, Q) GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, Q)
//# endif//GLM_SWIZZLE # endif//GLM_SWIZZLE
# endif # endif
// -- Component accesses -- // -- Component accesses --
@ -178,7 +175,7 @@ namespace glm
GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 GLM_EXPLICIT vec(vec<4, U, P> const& v); GLM_FUNC_DECL GLM_CONSTEXPR_CXX11 GLM_EXPLICIT vec(vec<4, U, P> const& v);
// -- Swizzle constructors -- // -- 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> template<int E0, int E1, int E2, int E3>
GLM_FUNC_DECL vec(detail::_swizzle<4, T, Q, E0, E1, E2, E3> const& that) 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()); *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 -- // -- Unary arithmetic operators --

View File

@ -6,7 +6,7 @@
namespace glm{ namespace glm{
namespace detail namespace detail
{ {
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_SWIZZLE == GLM_ENABLE
template<qualifier Q, int E0, int E1, int E2, int E3> 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> struct _swizzle_base1<4, float, Q, E0,E1,E2,E3, true> : public _swizzle_base0<float, 4>
{ {
@ -49,7 +49,7 @@ namespace detail
return Result; return Result;
} }
}; };
# endif// GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # endif// GLM_SWIZZLE == GLM_ENABLE
template<qualifier Q> template<qualifier Q>
struct compute_vec4_add<float, Q, true> struct compute_vec4_add<float, Q, true>

View File

@ -14,8 +14,8 @@
#include "../fwd.hpp" #include "../fwd.hpp"
#include "../detail/type_vec.hpp" #include "../detail/type_vec.hpp"
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #if GLM_SWIZZLE == GLM_ENABLE
# if GLM_LANG & GLM_LANG_CXXMS_FLAG # if GLM_HAS_ANONYMOUS_STRUCT
# include "../detail/_swizzle.hpp" # include "../detail/_swizzle.hpp"
# else # else
# include "../detail/_swizzle_func.hpp" # include "../detail/_swizzle_func.hpp"
@ -43,10 +43,7 @@ namespace glm
// -- Data -- // -- Data --
# if GLM_HAS_ONLY_XYZW # if GLM_HAS_ANONYMOUS_STRUCT
T x;
# elif GLM_LANG & GLM_LANG_CXXMS_FLAG
union union
{ {
T x; T x;
@ -55,7 +52,7 @@ namespace glm
typename detail::storage<1, T, detail::is_aligned<Q>::value>::type data; 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, x)
_GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, r) _GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, r)
_GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, s) _GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, s)
@ -70,7 +67,7 @@ namespace glm
# else # else
union {T x, r, s;}; 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) GLM_SWIZZLE_GEN_VEC_FROM_VEC1(T, Q, tvec2, tvec2, tvec3, tvec4)
# endif//GLM_SWIZZLE*/ # endif//GLM_SWIZZLE*/
# endif # endif
@ -113,13 +110,13 @@ namespace glm
// -- Swizzle constructors -- // -- Swizzle constructors --
/* /*
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_HAS_ANONYMOUS_STRUCT && GLM_SWIZZLE == GLM_ENABLE
template<int E0> template<int E0>
GLM_FUNC_DECL tvec(detail::_swizzle<1, T, Q, tvec1, E0, -1,-2,-3> const& that) GLM_FUNC_DECL tvec(detail::_swizzle<1, T, Q, tvec1, E0, -1,-2,-3> const& that)
{ {
*this = that(); *this = that();
} }
# endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # endif//GLM_SWIZZLE == GLM_ENABLE
*/ */
// -- Unary arithmetic operators -- // -- Unary arithmetic operators --

View File

@ -50,7 +50,7 @@ int test_vec4_ctor()
} }
#endif #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 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = A.xyzw; 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, L)) ? 0 : 1;
Error += glm::all(glm::equal(A, M)) ? 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); glm::vec4 A(1);
@ -311,7 +340,7 @@ int test_vec4_swizzle_partial()
glm::vec4 A(1, 2, 3, 4); 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); glm::vec4 B(A.xy, A.zw);
Error += A == B ? 0 : 1; Error += A == B ? 0 : 1;

View File

@ -2,20 +2,18 @@
#define GLM_FORCE_SWIZZLE #define GLM_FORCE_SWIZZLE
#include <glm/glm.hpp> #include <glm/glm.hpp>
#if !GLM_HAS_ONLY_XYZW
static int test_ivec2_swizzle() static int test_ivec2_swizzle()
{ {
int Error = 0; int Error = 0;
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #if GLM_SWIZZLE == GLM_ENABLE
glm::ivec2 A(1, 2); glm::ivec2 A(1, 2);
glm::ivec2 B = A.yx(); glm::ivec2 B = A.yx();
glm::ivec2 C = B.yx(); glm::ivec2 C = B.yx();
Error += A != B ? 0 : 1; Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1; Error += A == C ? 0 : 1;
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #endif//GLM_SWIZZLE == GLM_ENABLE
return Error; return Error;
} }
@ -24,14 +22,14 @@ int test_ivec3_swizzle()
{ {
int Error = 0; int Error = 0;
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #if GLM_SWIZZLE == GLM_ENABLE
glm::ivec3 A(1, 2, 3); glm::ivec3 A(1, 2, 3);
glm::ivec3 B = A.zyx(); glm::ivec3 B = A.zyx();
glm::ivec3 C = B.zyx(); glm::ivec3 C = B.zyx();
Error += A != B ? 0 : 1; Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1; Error += A == C ? 0 : 1;
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #endif//GLM_SWIZZLE == GLM_ENABLE
return Error; return Error;
} }
@ -40,14 +38,14 @@ int test_ivec4_swizzle()
{ {
int Error = 0; int Error = 0;
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #if GLM_SWIZZLE == GLM_ENABLE
glm::ivec4 A(1, 2, 3, 4); glm::ivec4 A(1, 2, 3, 4);
glm::ivec4 B = A.wzyx(); glm::ivec4 B = A.wzyx();
glm::ivec4 C = B.wzyx(); glm::ivec4 C = B.wzyx();
Error += A != B ? 0 : 1; Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1; Error += A == C ? 0 : 1;
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #endif//GLM_SWIZZLE == GLM_ENABLE
return Error; return Error;
} }
@ -56,7 +54,7 @@ int test_vec4_swizzle()
{ {
int Error = 0; int Error = 0;
#if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #if GLM_SWIZZLE == GLM_ENABLE
glm::vec4 A(1, 2, 3, 4); glm::vec4 A(1, 2, 3, 4);
glm::vec4 B = A.wzyx(); glm::vec4 B = A.wzyx();
glm::vec4 C = B.wzyx(); glm::vec4 C = B.wzyx();
@ -66,23 +64,19 @@ int test_vec4_swizzle()
float f = glm::dot(C.wzyx(), C.xyzw()); float f = glm::dot(C.wzyx(), C.xyzw());
Error += glm::abs(f - 20.f) < 0.01f ? 0 : 1; Error += glm::abs(f - 20.f) < 0.01f ? 0 : 1;
#endif//GLM_SWIZZLE == GLM_SWIZZLE_ENABLED #endif//GLM_SWIZZLE == GLM_ENABLE
return Error; return Error;
} }
#endif//!GLM_HAS_ONLY_XYZW
int main() int main()
{ {
int Error = 0; int Error = 0;
# if !GLM_HAS_ONLY_XYZW
Error += test_ivec2_swizzle(); Error += test_ivec2_swizzle();
Error += test_ivec3_swizzle(); Error += test_ivec3_swizzle();
Error += test_ivec4_swizzle(); Error += test_ivec4_swizzle();
Error += test_vec4_swizzle(); Error += test_vec4_swizzle();
# endif//!GLM_HAS_ONLY_XYZW
return Error; return Error;
} }

View File

@ -69,18 +69,6 @@ int test_vec1_ctor()
} }
#endif #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 A = glm::vec2(2.0f);
@ -137,6 +125,24 @@ static int test_vec1_operator_increment()
return Error; 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() static int test_constexpr()
{ {
#if GLM_HAS_CONSTEXPR_CXX14 #if GLM_HAS_CONSTEXPR_CXX14
@ -155,6 +161,7 @@ int main()
Error += test_vec1_ctor(); Error += test_vec1_ctor();
Error += test_vec1_operators(); Error += test_vec1_operators();
Error += test_vec1_operator_increment(); Error += test_vec1_operator_increment();
Error += test_swizzle();
Error += test_constexpr(); Error += test_constexpr();
return Error; return Error;

View File

@ -236,19 +236,6 @@ static int test_ctor()
} }
#endif #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 A = glm::vec2(2.0f);
glm::vec2 B = glm::vec2(2.0f, 3.0f); glm::vec2 B = glm::vec2(2.0f, 3.0f);
@ -357,6 +344,35 @@ static int test_constexpr()
return 0; 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 main()
{ {
int Error = 0; int Error = 0;
@ -365,6 +381,7 @@ int main()
Error += test_ctor(); Error += test_ctor();
Error += test_operators(); Error += test_operators();
Error += test_operator_increment(); Error += test_operator_increment();
Error += test_swizzle();
Error += test_constexpr(); Error += test_constexpr();
return Error; return Error;

View File

@ -27,7 +27,7 @@ int test_vec3_ctor()
Error += std::is_copy_constructible<glm::vec3>::value ? 0 : 1; Error += std::is_copy_constructible<glm::vec3>::value ? 0 : 1;
# endif # endif
#if (GLM_HAS_INITIALIZER_LISTS) # if GLM_HAS_INITIALIZER_LISTS
{ {
glm::vec3 a{ 0, 1, 2 }; glm::vec3 a{ 0, 1, 2 };
std::vector<glm::vec3> v = { std::vector<glm::vec3> v = {
@ -45,27 +45,6 @@ int test_vec3_ctor()
} }
# endif # 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))
{ {
glm::vec3 A(1); glm::vec3 A(1);
glm::vec3 B(1, 1, 1); glm::vec3 B(1, 1, 1);
@ -338,7 +317,7 @@ int test_vec3_swizzle3_2()
{ {
int Error = 0; 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 v(1, 2, 3);
glm::vec2 u; glm::vec2 u;
@ -402,7 +381,7 @@ int test_vec3_swizzle3_3()
{ {
int Error = 0; 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 v(1, 2, 3);
glm::vec3 u; glm::vec3 u;
@ -424,7 +403,6 @@ int test_vec3_swizzle3_3()
return Error; return Error;
} }
#if !GLM_HAS_ONLY_XYZW
int test_vec3_swizzle_operators() int test_vec3_swizzle_operators()
{ {
int Error = 0; int Error = 0;
@ -432,7 +410,7 @@ int test_vec3_swizzle_operators()
glm::vec3 u = glm::vec3(1, 2, 3); glm::vec3 u = glm::vec3(1, 2, 3);
glm::vec3 v = glm::vec3(10, 20, 30); 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; glm::vec3 q;
// Swizzle, swizzle binary operators // Swizzle, swizzle binary operators
@ -469,7 +447,7 @@ int test_vec3_swizzle_functions()
{ {
int Error = 0; int Error = 0;
# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED # if GLM_SWIZZLE == GLM_ENABLE
// NOTE: template functions cannot pick up the implicit conversion from // NOTE: template functions cannot pick up the implicit conversion from
// a swizzle to the unswizzled type, therefore the operator() must be // 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.xyzw(), t.xyzw()); Error += (int(r) == 300) ? 0 : 1;
r = glm::dot(s.xyz(), t.xyz()); Error += (int(r) == 140) ? 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; return Error;
} }
@ -512,9 +490,10 @@ int test_vec3_swizzle_partial()
{ {
int Error = 0; int Error = 0;
# if GLM_SWIZZLE == GLM_ENABLE && GLM_HAS_ANONYMOUS_STRUCT
glm::vec3 A(1, 2, 3); glm::vec3 A(1, 2, 3);
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
{ {
glm::vec3 B(A.xy, 3.0f); glm::vec3 B(A.xy, 3.0f);
Error += A == B ? 0 : 1; Error += A == B ? 0 : 1;
@ -529,15 +508,14 @@ int test_vec3_swizzle_partial()
glm::vec3 B(A.xyz); glm::vec3 B(A.xyz);
Error += A == B ? 0 : 1; Error += A == B ? 0 : 1;
} }
# endif//GLM_LANG # endif//GLM_SWIZZLE == GLM_ENABLE && GLM_HAS_ANONYMOUS_STRUCT
return Error; return Error;
} }
#endif//!GLM_HAS_ONLY_XYZW
static int test_operator_increment() static int test_operator_increment()
{ {
int Error(0); int Error = 0;
glm::ivec3 v0(1); glm::ivec3 v0(1);
glm::ivec3 v1(v0); glm::ivec3 v1(v0);
@ -562,6 +540,53 @@ static int test_operator_increment()
return Error; 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() static int test_constexpr()
{ {
#if GLM_HAS_CONSTEXPR_CXX14 #if GLM_HAS_CONSTEXPR_CXX14
@ -583,16 +608,15 @@ int main()
Error += test_bvec3_ctor(); Error += test_bvec3_ctor();
Error += test_vec3_operators(); Error += test_vec3_operators();
Error += test_vec3_size(); Error += test_vec3_size();
Error += test_vec3_swizzle3_2();
Error += test_vec3_swizzle3_3();
Error += test_operator_increment(); Error += test_operator_increment();
Error += test_constexpr(); Error += test_constexpr();
# if !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_partial();
Error += test_vec3_swizzle_operators(); Error += test_vec3_swizzle_operators();
Error += test_vec3_swizzle_functions(); Error += test_vec3_swizzle_functions();
# endif//!GLM_HAS_ONLY_XYZW
return Error; return Error;
} }

View File

@ -74,37 +74,6 @@ static int test_vec4_ctor()
} }
#endif #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 A(1);
glm::vec4 B(1, 1, 1, 1); glm::vec4 B(1, 1, 1, 1);
@ -516,7 +485,7 @@ static int test_swizzle_partial()
glm::vec4 A(1, 2, 3, 4); 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); glm::vec4 B(A.xy, A.zw);
Error += A == B ? 0 : 1; Error += A == B ? 0 : 1;
@ -542,7 +511,74 @@ static int test_swizzle_partial()
glm::vec4 B(1.0f, A.yzw); glm::vec4 B(1.0f, A.yzw);
Error += A == B ? 0 : 1; 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; return Error;
} }
@ -782,6 +818,7 @@ int main()
Error += test_size(); Error += test_size();
Error += test_operators(); Error += test_operators();
Error += test_equal(); Error += test_equal();
Error += test_swizzle();
Error += test_swizzle_partial(); Error += test_swizzle_partial();
Error += test_simd(); Error += test_simd();
Error += test_operator_increment(); Error += test_operator_increment();

View File

@ -1,4 +1,6 @@
#define GLM_ENABLE_EXPERIMENTAL #define GLM_ENABLE_EXPERIMENTAL
#include <glm/glm.hpp>
#if GLM_LANG & GLM_LANG_CXXMS_FLAG
#include <glm/gtc/type_precision.hpp> #include <glm/gtc/type_precision.hpp>
#include <glm/gtx/io.hpp> #include <glm/gtx/io.hpp>
#include <iostream> #include <iostream>
@ -174,3 +176,11 @@ int main()
return Error; return Error;
} }
#else
int main()
{
return 0;
}
#endif// GLM_LANG & GLM_LANG_CXXMS_FLAG