Fixed GLM_FORCE_SIZE_FUNC support overlook #245. Added uninitiallized constructor to quaternion. Fixed lack of conscistency or quaternion constructors with other types. Various uninitilized constructor optimizations

This commit is contained in:
Christophe Riccio
2014-10-12 01:24:28 +02:00
parent 2df7addc05
commit c2d542562e
27 changed files with 289 additions and 238 deletions

View File

@@ -82,7 +82,7 @@ namespace detail
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & x, vecType<T, P> const & y, vecType<bool, P> const & a)
{
vecType<T, P> Result;
for(length_t i = 0; i < x.length(); ++i)
for(length_t i = 0; i < detail::component_count(x); ++i)
Result[i] = a[i] ? y[i] : x[i];
return Result;
}

View File

@@ -60,7 +60,7 @@ namespace detail
GLM_FUNC_QUALIFIER static typename detail::outerProduct_trait<T, P, tvec3, tvec3>::type call(tvec3<T, P> const & c, tvec3<T, P> const & r)
{
tmat3x3<T, P> m(tmat3x3<T, P>::_null);
for(length_t i(0); i < m.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(m); ++i)
m[i] = c * r[i];
return m;
}
@@ -72,7 +72,7 @@ namespace detail
GLM_FUNC_QUALIFIER static typename detail::outerProduct_trait<T, P, tvec4, tvec4>::type call(tvec4<T, P> const & c, tvec4<T, P> const & r)
{
tmat4x4<T, P> m(tmat4x4<T, P>::_null);
for(length_t i(0); i < m.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(m); ++i)
m[i] = c * r[i];
return m;
}
@@ -424,7 +424,7 @@ namespace detail
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'matrixCompMult' only accept floating-point inputs");
matType<T, P> result(matType<T, P>::_null);
for(length_t i = 0; i < result.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(result); ++i)
result[i] = x[i] * y[i];
return result;
}

View File

@@ -39,10 +39,10 @@ namespace glm
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
"Invalid template instantiation of 'lessThan', GLM vector types required floating-point or integer value types vectors");
assert(x.length() == y.length());
assert(detail::component_count(x) == detail::component_count(y));
typename vecType<bool, P>::bool_type Result(vecType<bool, P>::_null);
for(int i = 0; i < x.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
Result[i] = x[i] < y[i];
return Result;
@@ -57,10 +57,10 @@ namespace glm
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
"Invalid template instantiation of 'lessThanEqual', GLM vector types required floating-point or integer value types vectors");
assert(x.length() == y.length());
assert(detail::component_count(x) == detail::component_count(y));
typename vecType<bool, P>::bool_type Result(vecType<bool, P>::_null);
for(int i = 0; i < x.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
Result[i] = x[i] <= y[i];
return Result;
}
@@ -74,10 +74,10 @@ namespace glm
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
"Invalid template instantiation of 'greaterThan', GLM vector types required floating-point or integer value types vectors");
assert(x.length() == y.length());
assert(detail::component_count(x) == detail::component_count(y));
typename vecType<bool, P>::bool_type Result(vecType<bool, P>::_null);
for(int i = 0; i < x.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
Result[i] = x[i] > y[i];
return Result;
}
@@ -91,10 +91,10 @@ namespace glm
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
"Invalid template instantiation of 'greaterThanEqual', GLM vector types required floating-point or integer value types vectors");
assert(x.length() == y.length());
assert(detail::component_count(x) == detail::component_count(y));
typename vecType<bool, P>::bool_type Result(vecType<bool, P>::_null);
for(int i = 0; i < x.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
Result[i] = x[i] >= y[i];
return Result;
}
@@ -106,10 +106,10 @@ namespace glm
vecType<T, P> const & y
)
{
assert(x.length() == y.length());
assert(detail::component_count(x) == detail::component_count(y));
typename vecType<bool, P>::bool_type Result(vecType<bool, P>::_null);
for(int i = 0; i < x.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
Result[i] = x[i] == y[i];
return Result;
}
@@ -121,10 +121,10 @@ namespace glm
vecType<T, P> const & y
)
{
assert(x.length() == y.length());
assert(detail::component_count(x) == detail::component_count(y));
typename vecType<bool, P>::bool_type Result(vecType<bool, P>::_null);
for(int i = 0; i < x.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
Result[i] = x[i] != y[i];
return Result;
}
@@ -133,7 +133,7 @@ namespace glm
GLM_FUNC_QUALIFIER bool any(vecType<bool, P> const & v)
{
bool Result = false;
for(int i = 0; i < v.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(v); ++i)
Result = Result || v[i];
return Result;
}
@@ -142,7 +142,7 @@ namespace glm
GLM_FUNC_QUALIFIER bool all(vecType<bool, P> const & v)
{
bool Result = true;
for(int i = 0; i < v.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(v); ++i)
Result = Result && v[i];
return Result;
}
@@ -151,7 +151,7 @@ namespace glm
GLM_FUNC_QUALIFIER vecType<bool, P> not_(vecType<bool, P> const & v)
{
typename vecType<bool, P>::bool_type Result(vecType<bool, P>::_null);
for(int i = 0; i < v.length(); ++i)
for(detail::component_count_t i = 0; i < detail::component_count(v); ++i)
Result[i] = !v[i];
return Result;
}

View File

@@ -757,31 +757,6 @@
# endif
#endif//GLM_MESSAGE
///////////////////////////////////////////////////////////////////////////////////////////////////
// Length type
// User defines: GLM_FORCE_SIZE_T_LENGTH GLM_FORCE_SIZE_FUNC
namespace glm
{
typedef std::size_t size_t;
#if defined(GLM_FORCE_SIZE_T_LENGTH) || defined(GLM_FORCE_SIZE_FUNC)
typedef std::size_t length_t;
#else
typedef int length_t;
#endif
}//namespace glm
#if(defined(GLM_MESSAGES) && !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")
# else
# pragma message("GLM: .length() returns glm::length_t, a typedef of int following the GLSL specification")
# pragma message("GLM: #define GLM_FORCE_SIZE_T_LENGTH for .length() to return a std::size_t")
# endif
#endif//GLM_MESSAGE
///////////////////////////////////////////////////////////////////////////////////////////////////
// Qualifiers
@@ -816,3 +791,47 @@ namespace glm
#else
# define GLM_CONSTEXPR
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
// Length type
// User defines: GLM_FORCE_SIZE_T_LENGTH GLM_FORCE_SIZE_FUNC
namespace glm
{
typedef std::size_t size_t;
#if defined(GLM_FORCE_SIZE_T_LENGTH) || defined(GLM_FORCE_SIZE_FUNC)
typedef size_t length_t;
#else
typedef int length_t;
#endif
namespace detail
{
template <typename genType>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t component_count(genType const & m)
{
# if GLM_FORCE_SIZE_FUNC
return m.size();
# else
return m.length();
# endif
}
# if GLM_FORCE_SIZE_FUNC
typedef size_t component_count_t;
# else
typedef length_t component_count_t;
# endif
}//namespace detail
}//namespace glm
#if(defined(GLM_MESSAGES) && !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")
# else
# pragma message("GLM: .length() returns glm::length_t, a typedef of int following the GLSL specification")
# pragma message("GLM: #define GLM_FORCE_SIZE_T_LENGTH for .length() to return a size_t")
# endif
#endif//GLM_MESSAGE

View File

@@ -25,3 +25,4 @@
/// @date 2011-06-15 / 2011-06-15
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////