mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Added rect SIMD optimization
This commit is contained in:
parent
f6810a9c0e
commit
c8c298fef4
@ -87,6 +87,15 @@ namespace detail
|
||||
return dot(Nref, I) < static_cast<T>(0) ? N : -N;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
struct compute_reflect
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & I, vecType<T, P> const & N)
|
||||
{
|
||||
return I - N * dot(N, I) * static_cast<T>(2);
|
||||
}
|
||||
};
|
||||
}//namespace detail
|
||||
|
||||
// length
|
||||
@ -174,10 +183,10 @@ namespace detail
|
||||
}
|
||||
|
||||
// reflect
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType reflect(genType const & I, genType const & N)
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T, P> reflect(vecType<T, P> const & I, vecType<T, P> const & N)
|
||||
{
|
||||
return I - N * dot(N, I) * static_cast<genType>(2);
|
||||
return detail::compute_reflect<T, P, vecType>::call(I, N);
|
||||
}
|
||||
|
||||
// refract
|
||||
|
@ -48,12 +48,24 @@ namespace detail
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & N, tvec4<float, P> const & I, tvec4<float, P> const & Nref)
|
||||
{
|
||||
__m128 const ffd0 = glm_f32v4_ffd(v.data);
|
||||
__m128 const ffd0 = glm_f32v4_ffd(N.data. I.data, Nref.data);
|
||||
tvec4<float, P> result(uninitialize);
|
||||
result.data = ffd0;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <precision P>
|
||||
struct compute_reflect<float, P, tvec4>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & I, tvec4<float, P> const & N)
|
||||
{
|
||||
__m128 const rfe0 = glm_f32v4_rfe(I.data, N.data);
|
||||
tvec4<float, P> result(uninitialize);
|
||||
result.data = rfe0;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}//namespace detail
|
||||
}//namespace glm
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user