Merge branch '0.9.3' of ssh://ogl-math.git.sourceforge.net/gitroot/ogl-math/ogl-math into 0.9.3

This commit is contained in:
Christophe Riccio
2012-01-09 11:21:48 +00:00
8969 changed files with 1732536 additions and 66 deletions

View File

@@ -87,29 +87,32 @@ namespace glm
VECTORIZE_VEC(exp2)
namespace detail
namespace _detail
{
template <int PATH = float_or_int_value::GLM_ERROR>
struct compute_log2
template <int _PATH = detail::float_or_int_value::GLM_ERROR>
struct _compute_log2
{
template <typename T>
T operator() (T const & Value) const
T operator() (T const & Value) const;
/*
{
GLM_STATIC_ASSERT(0, "'log2' parameter has an invalid template parameter type. GLM core features only supports floating-point types, include <glm/gtx/integer.hpp> for integer types support. Others types are not supported.");
return Value;
}
*/
};
template <>
struct compute_log2<float_or_int_value::GLM_FLOAT>
struct _compute_log2<detail::float_or_int_value::GLM_FLOAT>
{
template <typename T>
T operator() (T const & Value) const
{
return ::std::log(Value) / T(0.69314718055994530941723212145818);
return T(::std::log(Value)) / T(0.69314718055994530941723212145818);
}
};
}//namespace detail
}//namespace _detail
// log2, ln2 = 0.69314718055994530941723212145818f
template <typename genType>
@@ -119,7 +122,7 @@ namespace detail
)
{
assert(x > genType(0)); // log2 is only defined on the range (0, inf]
return detail::compute_log2<detail::float_or_int_trait<genType>::ID>()(x);
return _detail::_compute_log2<detail::float_or_int_trait<genType>::ID>()(x);
}
VECTORIZE_VEC(log2)

View File

@@ -146,13 +146,33 @@ namespace glm
GLM_FUNC_QUALIFIER uint packHalf2x16(detail::tvec2<float> const & v)
{
detail::tvec2<detail::hdata> Pack(detail::toFloat16(v.x), detail::toFloat16(v.y));
union helper
{
uint other;
struct
{
detail::hdata a, b;
} orig;
} Pack;
Pack.orig.a = detail::toFloat16(v.x);
Pack.orig.b = detail::toFloat16(v.y);
return *(uint*)&Pack;
}
GLM_FUNC_QUALIFIER vec2 unpackHalf2x16(uint const & v)
{
detail::tvec2<detail::hdata> Unpack = *(detail::tvec2<detail::hdata>*)&v;
return vec2(detail::toFloat32(Unpack.x), detail::toFloat32(Unpack.y));
union helper
{
uint other;
struct
{
detail::hdata a, b;
} orig;
} Unpack;
Unpack.other = v;
return vec2(detail::toFloat32(Unpack.orig.a), detail::toFloat32(Unpack.orig.b));
}
}//namespace glm

View File

@@ -261,8 +261,8 @@ namespace glm
Result[0][0] = w;
Result[1][1] = h;
Result[2][2] = (zFar + zNear) / (zFar - zNear);
Result[2][3] = valType(1);
Result[3][2] = -(valType(2) * zFar * zNear) / (zFar - zNear);
Result[2][3] = -valType(1);
Result[3][2] = (valType(2) * zFar * zNear) / (zFar - zNear);
return Result;
}

View File

@@ -17,13 +17,15 @@ namespace detail
struct compute_linearRand
{
template <typename T>
GLM_FUNC_QUALIFIER T operator() (T const & Min, T const & Max) const
GLM_FUNC_QUALIFIER T operator() (T const & Min, T const & Max) const;
/*
{
GLM_STATIC_ASSERT(0, "'linearRand' invalid template parameter type. GLM_GTC_random only supports floating-point template types.");
return Min;
}
*/
};
template <>
GLM_FUNC_QUALIFIER half compute_linearRand::operator()<half> (half const & Min, half const & Max) const
{
@@ -41,6 +43,12 @@ namespace detail
{
return double(std::rand()) / double(RAND_MAX) * (Max - Min) + Min;
}
template <>
GLM_FUNC_QUALIFIER long double compute_linearRand::operator()<long double> (long double const & Min, long double const & Max) const
{
return (long double)(std::rand()) / (long double)(RAND_MAX) * (Max - Min) + Min;
}
}//namespace detail
template <typename genType>

View File

@@ -38,7 +38,7 @@ namespace glm
}
// Henry Gordon Dietz: http://aggregate.org/MAGIC/
namespace detail
namespace _detail
{
GLM_FUNC_QUALIFIER unsigned int ones32(unsigned int x)
{
@@ -55,19 +55,22 @@ namespace detail
}
template <>
struct compute_log2<float_or_int_value::GLM_INT>
struct _compute_log2<detail::float_or_int_value::GLM_INT>
{
template <typename T>
T operator() (T const & Value) const
{
#if(GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_GCC))
#if(GLM_COMPILER & GLM_COMPILER_VC)
return Value <= T(1) ? T(0) : T(32) - nlz(Value - T(1));
#elif(GLM_COMPILER & GLM_COMPILER_GCC)
return Value <= T(1) ? T(0) : nlz(Value - T(1)) + 1;
#else
return T(32) - nlz(Value - T(1));
#endif
}
};
}//namespace detail
}//namespace _detail
// Henry Gordon Dietz: http://aggregate.org/MAGIC/
unsigned int floor_log2(unsigned int x)
@@ -78,7 +81,7 @@ namespace detail
x |= (x >> 8);
x |= (x >> 16);
return(detail::ones32(x) - 1);
return(_detail::ones32(x) - 1);
}
// mod