Fixed merge
This commit is contained in:
@@ -258,7 +258,7 @@ inline __m128 sse_inf_ps(__m128 x)
|
||||
}
|
||||
|
||||
// SSE scalar reciprocal sqrt using rsqrt op, plus one Newton-Rhaphson iteration
|
||||
// By Elan Ruskin,
|
||||
// By Elan Ruskin, http://assemblyrequired.crashworks.org/
|
||||
inline __m128 sse_sqrt_wip_ss(__m128 const & x)
|
||||
{
|
||||
__m128 recip = _mm_rsqrt_ss(x); // "estimate" opcode
|
||||
|
||||
@@ -136,6 +136,14 @@ namespace glm
|
||||
detail::tmat4x4<T> const & proj,
|
||||
detail::tvec4<U> const & viewport);
|
||||
|
||||
//! Define a picking region
|
||||
//! From GLM_GTC_matrix_transform extension.
|
||||
template <typename T, typename U>
|
||||
detail::tmat4x4<T> pickMatrix(
|
||||
detail::tvec2<T> const & center,
|
||||
detail::tvec2<T> const & delta,
|
||||
detail::tvec4<U> const & viewport);
|
||||
|
||||
//! Build a look at view matrix.
|
||||
//! From GLM_GTC_matrix_transform extension.
|
||||
template <typename T>
|
||||
|
||||
@@ -324,6 +324,25 @@ namespace matrix_transform
|
||||
return detail::tvec3<T>(obj);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
detail::tmat4x4<T> pickMatrix
|
||||
(
|
||||
detail::tvec2<T> const & center,
|
||||
detail::tvec2<T> const & delta,
|
||||
detail::tvec4<U> const & viewport
|
||||
)
|
||||
{
|
||||
assert(delta.x > 0.0f && delta.y > 0.0f)
|
||||
detail::tmat4x4<T> Result(1.0f);
|
||||
|
||||
if(!(delta.x > 0.0f && delta.y > 0.0f))
|
||||
return Result; // Error
|
||||
|
||||
// Translate and scale the picked region to the entire window
|
||||
Result = translate(Result, (T(viewport[2]) - T(2) * (x - T(viewport[0]))) / delta.x, (T(viewport[3]) - T(2) * (y - T(viewport[1]))) / delta.y, T(0));
|
||||
return scale(Result, T(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline detail::tmat4x4<T> lookAt(
|
||||
const detail::tvec3<T>& eye,
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace glm
|
||||
detail::tquat<T> const & q1,
|
||||
detail::tquat<T> const & q2);
|
||||
|
||||
//! Returns a LERP interpolated quaternion of x and y according a.
|
||||
//! Returns a SLERP interpolated quaternion of x and y according a.
|
||||
//! From GLM_GTC_quaternion extension.
|
||||
template <typename T>
|
||||
detail::tquat<T> mix(
|
||||
|
||||
@@ -369,6 +369,43 @@ namespace quaternion{
|
||||
k0 * x.z + k1 * y2.z);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline detail::tquat<T> mix2
|
||||
(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
bool flip = false;
|
||||
if(a <= T(0)) return x;
|
||||
if(a >= T(1)) return y;
|
||||
|
||||
T cos_t = dot(x, y);
|
||||
if(cos_t < T(0))
|
||||
{
|
||||
cos_t = -cos_t;
|
||||
flip = true;
|
||||
}
|
||||
|
||||
T alpha(0), beta(0);
|
||||
|
||||
if(T(1) - cos_t < 1e-7)
|
||||
beta = T(1) - alpha;
|
||||
else
|
||||
{
|
||||
T theta = acos(cos_t);
|
||||
T sin_t = sin(theta);
|
||||
beta = sin(theta * (T(1) - alpha)) / sin_t;
|
||||
alpha = sin(alpha * theta) / sin_t;
|
||||
}
|
||||
|
||||
if(flip)
|
||||
alpha = -alpha;
|
||||
|
||||
return normalize(beta * x + alpha * y2);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline detail::tquat<T> conjugate
|
||||
(
|
||||
|
||||
@@ -407,6 +407,27 @@ namespace glm
|
||||
detail::fvec4SIMD const & N,
|
||||
float const & eta);
|
||||
|
||||
//! Returns the positive square root of x.
|
||||
//! (From GLM_GTX_simd_vec4 extension, exponential function)
|
||||
detail::fvec4SIMD simdSqrt(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns the positive square root of x with an accuracy slight lower or equal than simdSqrt but much faster.
|
||||
//! (From GLM_GTX_simd_vec4 extension, exponential function)
|
||||
detail::fvec4SIMD simdFastSqrt(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns the reciprocal of the positive square root of x.
|
||||
//! (From GLM_GTX_simd_vec4 extension, exponential function)
|
||||
detail::fvec4SIMD simdInversesqrt(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns the reciprocal of the positive square root of x,
|
||||
//! faster than simdInversesqrt but less accurate.
|
||||
//! (From GLM_GTX_simd_vec4 extension, exponential function)
|
||||
detail::fvec4SIMD simdFastInversesqrt(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
///@}
|
||||
}//namespace simd_vec4
|
||||
}//namespace gtx
|
||||
|
||||
@@ -634,6 +634,34 @@ namespace glm
|
||||
return detail::sse_rfa_ps(I.Data, N.Data, _mm_set1_ps(eta));
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD simdSqrt(detail::fvec4SIMD const & x)
|
||||
{
|
||||
return _mm_sqrt_ps(x.Data);
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD simdFastSqrt(detail::fvec4SIMD const & x)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// SSE scalar reciprocal sqrt using rsqrt op, plus one Newton-Rhaphson iteration
|
||||
// By Elan Ruskin, http://assemblyrequired.crashworks.org/
|
||||
inline detail::fvec4SIMD simdInversesqrt(detail::fvec4SIMD const & x)
|
||||
{
|
||||
GLM_ALIGN(4) static const __m128 three = {3, 3, 3, 3}; // aligned consts for fast load
|
||||
GLM_ALIGN(4) static const __m128 half = {0.5,0.5,0.5,0.5};
|
||||
|
||||
__m128 recip = _mm_rsqrt_ps(x.Data); // "estimate" opcode
|
||||
__m128 halfrecip = _mm_mul_ps(half, recip);
|
||||
__m128 threeminus_xrr = _mm_sub_ps(three, _mm_mul_ps(x.Data, _mm_mul_ps(recip, recip)));
|
||||
return _mm_mul_ps(halfrecip, threeminus_xrr);
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD simdFastInversesqrt(detail::fvec4SIMD const & x)
|
||||
{
|
||||
return _mm_rsqrt_ps(x.Data);
|
||||
}
|
||||
|
||||
}//namespace simd_vec4
|
||||
}//namespace gtx
|
||||
}//namespace glm
|
||||
|
||||
Reference in New Issue
Block a user