Merge branch '0.9.2' into noise
This commit is contained in:
@@ -269,13 +269,13 @@ namespace glm
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'bitfieldExtract' only accept integer values");
|
||||
assert(Offset + Bits <= sizeof(genIUType));
|
||||
|
||||
genIUType Result = 0;
|
||||
genIUType Result(0);
|
||||
if(std::numeric_limits<genIUType>::is_signed)
|
||||
Result |= (1 << (sizeof(genIUType) * 8 - 1)) & (1 << (Offset + Bits - 1));
|
||||
Result |= (genIUType(1) << (sizeof(genIUType) * genIUType(8) - genIUType(1))) & (genIUType(1) << (Offset + Bits - genIUType(1)));
|
||||
|
||||
genIUType Mask = 0;
|
||||
genIUType Mask(0);
|
||||
for(int Bit = Offset; Bit < Bits; ++Bit)
|
||||
Mask |= (1 << Bit);
|
||||
Mask |= (genIUType(1) << Bit);
|
||||
|
||||
return Result | ((Mask & Value) >> Offset);
|
||||
}
|
||||
@@ -340,7 +340,7 @@ namespace glm
|
||||
|
||||
genIUType Mask = 0;
|
||||
for(int Bit = Offset; Bit < Offset + Bits; ++Bit)
|
||||
Mask |= (1 << Bit);
|
||||
Mask |= (genIUType(1) << Bit);
|
||||
|
||||
return (Base & ~Mask) | (Insert & Mask);
|
||||
}
|
||||
@@ -398,8 +398,8 @@ namespace glm
|
||||
|
||||
genIUType Result = 0;
|
||||
for(std::size_t i = 0; i < sizeof(genIUType) * std::size_t(8); ++i)
|
||||
if(Value & (1 << i))
|
||||
Result |= (genIUType(1) << (sizeof(genIUType) * std::size_t(8)) - genIUType(1) - i);
|
||||
if(Value & (genIUType(1) << genIUType(i)))
|
||||
Result |= (genIUType(1) << (genIUType(sizeof(genIUType)) * genIUType(8)) - genIUType(1) - genIUType(i));
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ namespace glm
|
||||
int Count = 0;
|
||||
for(std::size_t i = 0; i < sizeof(genIUType) * std::size_t(8); ++i)
|
||||
{
|
||||
if(Value & (1 << i))
|
||||
if(Value & (genIUType(1) << i))
|
||||
++Count;
|
||||
}
|
||||
return Count;
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace quaternion{
|
||||
q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z,
|
||||
q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x);
|
||||
}
|
||||
|
||||
/*
|
||||
// (x * sin(1 - a) * angle / sin(angle)) + (y * sin(a) * angle / sin(angle))
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> mix
|
||||
@@ -406,6 +406,18 @@ namespace quaternion{
|
||||
|
||||
return normalize(beta * x + alpha * y);
|
||||
}
|
||||
*/
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> mix
|
||||
(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
T angle = acos(dot(x, y));
|
||||
return (sin((1 - a) * angle) * x + sin(a * angle) * y) / sin(angle);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> conjugate
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace glm
|
||||
detail::tquat<valType> const & q,
|
||||
detail::tvec4<valType> const & v);
|
||||
|
||||
//! Returns the q rotation angle.
|
||||
//! Returns the quaternion rotation angle.
|
||||
//! From GLM_GTX_quaternion extension.
|
||||
template <typename valType>
|
||||
valType angle(
|
||||
@@ -191,6 +191,22 @@ namespace glm
|
||||
detail::tquat<valType> toQuat(
|
||||
detail::tmat4x4<valType> const & x){return gtc::quaternion::quat_cast(x);}
|
||||
|
||||
//! Quaternion interpolation using the rotation short path.
|
||||
//! From GLM_GTX_quaternion extension.
|
||||
template <typename T>
|
||||
detail::tquat<T> shortMix(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a);
|
||||
|
||||
//! Quaternion normalized linear interpolation.
|
||||
//! From GLM_GTX_quaternion extension.
|
||||
template <typename T>
|
||||
detail::tquat<T> fastMix(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a);
|
||||
|
||||
///@}
|
||||
|
||||
}//namespace quaternion
|
||||
|
||||
@@ -245,6 +245,59 @@ namespace quaternion
|
||||
return detail::tvec3<valType>(pitch(x), yaw(x), roll(x));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> shortMix
|
||||
(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
if(a <= typename detail::tquat<T>::value_type(0)) return x;
|
||||
if(a >= typename detail::tquat<T>::value_type(1)) return y;
|
||||
|
||||
float fCos = dot(x, y);
|
||||
detail::tquat<T> y2(y); //BUG!!! tquat<T> y2;
|
||||
if(fCos < typename detail::tquat<T>::value_type(0))
|
||||
{
|
||||
y2 = -y;
|
||||
fCos = -fCos;
|
||||
}
|
||||
|
||||
//if(fCos > 1.0f) // problem
|
||||
float k0, k1;
|
||||
if(fCos > typename detail::tquat<T>::value_type(0.9999))
|
||||
{
|
||||
k0 = typename detail::tquat<T>::value_type(1) - a;
|
||||
k1 = typename detail::tquat<T>::value_type(0) + a; //BUG!!! 1.0f + a;
|
||||
}
|
||||
else
|
||||
{
|
||||
typename detail::tquat<T>::value_type fSin = sqrt(T(1) - fCos * fCos);
|
||||
typename detail::tquat<T>::value_type fAngle = atan(fSin, fCos);
|
||||
typename detail::tquat<T>::value_type fOneOverSin = T(1) / fSin;
|
||||
k0 = sin((typename detail::tquat<T>::value_type(1) - a) * fAngle) * fOneOverSin;
|
||||
k1 = sin((typename detail::tquat<T>::value_type(0) + a) * fAngle) * fOneOverSin;
|
||||
}
|
||||
|
||||
return detail::tquat<T>(
|
||||
k0 * x.w + k1 * y2.w,
|
||||
k0 * x.x + k1 * y2.x,
|
||||
k0 * x.y + k1 * y2.y,
|
||||
k0 * x.z + k1 * y2.z);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> fastMix
|
||||
(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
return glm::normalize(x * (1 - a) + (y * a));
|
||||
}
|
||||
|
||||
}//namespace quaternion
|
||||
}//namespace gtx
|
||||
}//namespace glm
|
||||
|
||||
Reference in New Issue
Block a user