Simplify code removing GLM_FORCE_SIZE_FUNC, GLM_META_PROG_HELPERS, GLM_STATIC_CONST_MEMBERS and 'type' type trait. Added experiments for GTX_type_trait
parent
d245268c2e
commit
234d7d4ba9
57 changed files with 424 additions and 1359 deletions
@ -0,0 +1,224 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// OpenGL Mathematics (glm.g-truc.net)
|
||||||
|
///
|
||||||
|
/// Copyright (c) 2005 - 2016 G-Truc Creation (www.g-truc.net)
|
||||||
|
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
/// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
/// in the Software without restriction, including without limitation the rights
|
||||||
|
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
/// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
/// furnished to do so, subject to the following conditions:
|
||||||
|
///
|
||||||
|
/// The above copyright notice and this permission notice shall be included in
|
||||||
|
/// all copies or substantial portions of the Software.
|
||||||
|
///
|
||||||
|
/// Restrictions:
|
||||||
|
/// By making use of the Software for military purposes, you choose to make
|
||||||
|
/// a Bunny unhappy.
|
||||||
|
///
|
||||||
|
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
/// THE SOFTWARE.
|
||||||
|
///
|
||||||
|
/// @ref gtx_type_info
|
||||||
|
/// @file glm/gtx/type_info.hpp
|
||||||
|
/// @date 2016-03-12 / 2016-03-12
|
||||||
|
/// @author Christophe Riccio
|
||||||
|
///
|
||||||
|
/// @see core (dependence)
|
||||||
|
///
|
||||||
|
/// @defgroup gtx_type_info GLM_GTX_type_info
|
||||||
|
/// @ingroup gtx
|
||||||
|
///
|
||||||
|
/// @brief Defines aligned types.
|
||||||
|
///
|
||||||
|
/// <glm/gtx/type_aligned.hpp> need to be included to use these functionalities.
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once |
||||||
|
|
||||||
|
// Dependency:
|
||||||
|
#include "../detail/precision.hpp" |
||||||
|
#include "../detail/setup.hpp" |
||||||
|
|
||||||
|
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) |
||||||
|
# pragma message("GLM: GLM_GTX_type_info extension included") |
||||||
|
#endif |
||||||
|
|
||||||
|
namespace glm |
||||||
|
{ |
||||||
|
/// @addtogroup gtx_type_info
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
template <typename T, precision P> struct tvec1; |
||||||
|
template <typename T, precision P> struct tvec2; |
||||||
|
template <typename T, precision P> struct tvec3; |
||||||
|
template <typename T, precision P> struct tvec4; |
||||||
|
|
||||||
|
template <typename T, precision P> struct tmat2x2; |
||||||
|
template <typename T, precision P> struct tmat2x3; |
||||||
|
template <typename T, precision P> struct tmat2x4; |
||||||
|
template <typename T, precision P> struct tmat3x2; |
||||||
|
template <typename T, precision P> struct tmat3x3; |
||||||
|
template <typename T, precision P> struct tmat3x4; |
||||||
|
template <typename T, precision P> struct tmat4x2; |
||||||
|
template <typename T, precision P> struct tmat4x3; |
||||||
|
template <typename T, precision P> struct tmat4x4; |
||||||
|
|
||||||
|
template <typename T, precision P> struct tquat; |
||||||
|
template <typename T, precision P> struct tdualquat; |
||||||
|
|
||||||
|
template <template <typename, precision> class genType> |
||||||
|
struct type |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
static bool const is_mat = false; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 0; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tvec1> |
||||||
|
{ |
||||||
|
static bool const is_vec = true; |
||||||
|
static bool const is_mat = false; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 1; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tvec2> |
||||||
|
{ |
||||||
|
static bool const is_vec = true; |
||||||
|
static bool const is_mat = false; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 2; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tvec3> |
||||||
|
{ |
||||||
|
static bool const is_vec = true; |
||||||
|
static bool const is_mat = false; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 3; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tvec4> |
||||||
|
{ |
||||||
|
static bool const is_vec = true; |
||||||
|
static bool const is_mat = false; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 4; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tmat2x2> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
static bool const is_mat = true; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 2; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tmat2x3> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
static bool const is_mat = true; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 2; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tmat2x4> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
static bool const is_mat = true; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 2; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tmat3x2> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
static bool const is_mat = true; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 3; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t cols = 3; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t rows = 2; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tmat3x3> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
static bool const is_mat = true; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 3; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tmat3x4> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
static bool const is_mat = true; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 3; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tmat4x2> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
static bool const is_mat = true; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 4; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tmat4x3> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
static bool const is_mat = true; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 4; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tmat4x4> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
static bool const is_mat = true; |
||||||
|
static bool const is_quat = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 4; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tquat> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
static bool const is_mat = false; |
||||||
|
static bool const is_quat = true; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 4; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct type<tdualquat> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
static bool const is_mat = false; |
||||||
|
static bool const is_quat = true; |
||||||
|
static GLM_RELAXED_CONSTEXPR length_t components = 8; |
||||||
|
}; |
||||||
|
|
||||||
|
/// @}
|
||||||
|
}//namespace glm
|
||||||
|
|
||||||
|
#include "type_trait.inl" |
@ -1,116 +0,0 @@ |
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// OpenGL Mathematics (glm.g-truc.net)
|
|
||||||
///
|
|
||||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
|
||||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
/// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
/// in the Software without restriction, including without limitation the rights
|
|
||||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
/// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
/// furnished to do so, subject to the following conditions:
|
|
||||||
///
|
|
||||||
/// The above copyright notice and this permission notice shall be included in
|
|
||||||
/// all copies or substantial portions of the Software.
|
|
||||||
///
|
|
||||||
/// Restrictions:
|
|
||||||
/// By making use of the Software for military purposes, you choose to make
|
|
||||||
/// a Bunny unhappy.
|
|
||||||
///
|
|
||||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
/// THE SOFTWARE.
|
|
||||||
///
|
|
||||||
/// @file test/core/core_type_length_size.cpp
|
|
||||||
/// @date 2011-05-25 / 2014-11-25
|
|
||||||
/// @author Christophe Riccio
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define GLM_FORCE_SIZE_FUNC |
|
||||||
#include <glm/glm.hpp> |
|
||||||
#include <glm/gtc/vec1.hpp> |
|
||||||
|
|
||||||
int test_length_mat_non_squared() |
|
||||||
{ |
|
||||||
int Error = 0; |
|
||||||
|
|
||||||
Error += glm::mat2x3().size() == 2 ? 0 : 1; |
|
||||||
Error += glm::mat2x4().size() == 2 ? 0 : 1; |
|
||||||
Error += glm::mat3x2().size() == 3 ? 0 : 1; |
|
||||||
Error += glm::mat3x4().size() == 3 ? 0 : 1; |
|
||||||
Error += glm::mat4x2().size() == 4 ? 0 : 1; |
|
||||||
Error += glm::mat4x3().size() == 4 ? 0 : 1; |
|
||||||
|
|
||||||
Error += glm::dmat2x3().size() == 2 ? 0 : 1; |
|
||||||
Error += glm::dmat2x4().size() == 2 ? 0 : 1; |
|
||||||
Error += glm::dmat3x2().size() == 3 ? 0 : 1; |
|
||||||
Error += glm::dmat3x4().size() == 3 ? 0 : 1; |
|
||||||
Error += glm::dmat4x2().size() == 4 ? 0 : 1; |
|
||||||
Error += glm::dmat4x3().size() == 4 ? 0 : 1; |
|
||||||
|
|
||||||
return Error; |
|
||||||
} |
|
||||||
|
|
||||||
int test_length_mat() |
|
||||||
{ |
|
||||||
int Error = 0; |
|
||||||
|
|
||||||
Error += glm::mat2().size() == 2 ? 0 : 1; |
|
||||||
Error += glm::mat3().size() == 3 ? 0 : 1; |
|
||||||
Error += glm::mat4().size() == 4 ? 0 : 1; |
|
||||||
Error += glm::mat2x2().size() == 2 ? 0 : 1; |
|
||||||
Error += glm::mat3x3().size() == 3 ? 0 : 1; |
|
||||||
Error += glm::mat4x4().size() == 4 ? 0 : 1; |
|
||||||
|
|
||||||
Error += glm::dmat2().size() == 2 ? 0 : 1; |
|
||||||
Error += glm::dmat3().size() == 3 ? 0 : 1; |
|
||||||
Error += glm::dmat4().size() == 4 ? 0 : 1; |
|
||||||
Error += glm::dmat2x2().size() == 2 ? 0 : 1; |
|
||||||
Error += glm::dmat3x3().size() == 3 ? 0 : 1; |
|
||||||
Error += glm::dmat4x4().size() == 4 ? 0 : 1; |
|
||||||
|
|
||||||
return Error; |
|
||||||
} |
|
||||||
|
|
||||||
int test_length_vec() |
|
||||||
{ |
|
||||||
|
|
||||||
int Error = 0; |
|
||||||
|
|
||||||
Error += glm::vec1().size() == 1 ? 0 : 1; |
|
||||||
Error += glm::vec2().size() == 2 ? 0 : 1; |
|
||||||
Error += glm::vec3().size() == 3 ? 0 : 1; |
|
||||||
Error += glm::vec4().size() == 4 ? 0 : 1; |
|
||||||
|
|
||||||
Error += glm::ivec1().size() == 1 ? 0 : 1; |
|
||||||
Error += glm::ivec2().size() == 2 ? 0 : 1; |
|
||||||
Error += glm::ivec3().size() == 3 ? 0 : 1; |
|
||||||
Error += glm::ivec4().size() == 4 ? 0 : 1; |
|
||||||
|
|
||||||
Error += glm::uvec1().size() == 1 ? 0 : 1; |
|
||||||
Error += glm::uvec2().size() == 2 ? 0 : 1; |
|
||||||
Error += glm::uvec3().size() == 3 ? 0 : 1; |
|
||||||
Error += glm::uvec4().size() == 4 ? 0 : 1; |
|
||||||
|
|
||||||
Error += glm::dvec1().size() == 1 ? 0 : 1; |
|
||||||
Error += glm::dvec2().size() == 2 ? 0 : 1; |
|
||||||
Error += glm::dvec3().size() == 3 ? 0 : 1; |
|
||||||
Error += glm::dvec4().size() == 4 ? 0 : 1; |
|
||||||
|
|
||||||
return Error; |
|
||||||
} |
|
||||||
|
|
||||||
int main() |
|
||||||
{ |
|
||||||
int Error = 0; |
|
||||||
|
|
||||||
Error += test_length_vec(); |
|
||||||
Error += test_length_mat(); |
|
||||||
Error += test_length_mat_non_squared(); |
|
||||||
|
|
||||||
return Error; |
|
||||||
} |
|
||||||
|
|
@ -0,0 +1,79 @@ |
|||||||
|
#include <glm/vec4.hpp> |
||||||
|
#include <glm/gtx/type_trait.hpp> |
||||||
|
|
||||||
|
template <typename genType> |
||||||
|
struct type_gni |
||||||
|
{ |
||||||
|
static bool const is_vec = true; |
||||||
|
static bool const is_mat = false; |
||||||
|
static bool const is_quat = false; |
||||||
|
}; |
||||||
|
/*
|
||||||
|
template <template <class, glm::precision> class vecType, typename T, glm::precision P> |
||||||
|
struct type_gni<vecType, T, P> |
||||||
|
{ |
||||||
|
static bool const is_vec = true; |
||||||
|
static bool const is_mat = false; |
||||||
|
static bool const is_quat = false; |
||||||
|
}; |
||||||
|
*/ |
||||||
|
|
||||||
|
namespace detail |
||||||
|
{ |
||||||
|
template <template <typename, glm::precision> class vec_type> |
||||||
|
struct compute_vec_type |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
static GLM_RELAXED_CONSTEXPR glm::length_t components = 0; |
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct compute_vec_type<glm::tvec1> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
//static GLM_RELAXED_CONSTEXPR glm::length_t components = 1;
|
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct compute_vec_type<glm::tvec2> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
//static GLM_RELAXED_CONSTEXPR glm::length_t components = 2;
|
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct compute_vec_type<glm::tvec3> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
//static GLM_RELAXED_CONSTEXPR glm::length_t components = 3;
|
||||||
|
}; |
||||||
|
|
||||||
|
template <> |
||||||
|
struct compute_vec_type<glm::tvec4> |
||||||
|
{ |
||||||
|
static bool const is_vec = false; |
||||||
|
//static GLM_RELAXED_CONSTEXPR glm::length_t components = 4;
|
||||||
|
}; |
||||||
|
}//namespace detail
|
||||||
|
/*
|
||||||
|
template <class gen_type> |
||||||
|
struct vec_type |
||||||
|
{ |
||||||
|
static bool const is_vec = detail::compute_vec_type<typename gen_type::vec_type>::is_vec; |
||||||
|
//static GLM_RELAXED_CONSTEXPR glm::length_t const components = detail::compute_vec_type<typename gen_type::vec_type>::components;
|
||||||
|
}; |
||||||
|
*/ |
||||||
|
|
||||||
|
int main() |
||||||
|
{ |
||||||
|
int Error = 0; |
||||||
|
|
||||||
|
//typedef vec_type;
|
||||||
|
//bool const is_vec = detail::compute_vec_type<>::is_vec;
|
||||||
|
|
||||||
|
//Error += vec_type<glm::vec4>::is_vec ? 0 : 1;
|
||||||
|
//Error += vec_type<glm::vec4>::components == 4 ? 0 : 1;
|
||||||
|
|
||||||
|
return Error; |
||||||
|
} |
||||||
|
|
Loading…
Reference in New Issue