mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 12:41:54 +00:00
Merge branch '0.9.1' of ssh://ogl-math.git.sourceforge.net/gitroot/ogl-math/ogl-math into 0.9.1
This commit is contained in:
commit
dd07c3cb5b
@ -6,7 +6,7 @@ project(glm)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
#add_definitions(-S)
|
||||
#add_definitions(-s)
|
||||
add_definitions(-msse2)
|
||||
#add_definitions(-msse2)
|
||||
#add_definitions(-m32)
|
||||
#add_definitions(-mfpmath=387)
|
||||
#add_definitions(-ffast-math)
|
||||
|
@ -1,10 +1,12 @@
|
||||
set(NAME glm-doc)
|
||||
|
||||
file(GLOB ROOT_TXT doxyfile ../*.txt)
|
||||
file(GLOB ROOT_CPP src/*.cpp)
|
||||
file(GLOB ROOT_XML src/*.xml)
|
||||
file(GLOB ROOT_XSL src/*.xsl)
|
||||
|
||||
source_group("TXT Files" FILES ${ROOT_TXT})
|
||||
source_group("XML Files" FILES ${ROOT_XML})
|
||||
source_group("XSL Files" FILES ${ROOT_XSL})
|
||||
|
||||
add_executable(${NAME} ${ROOT_CPP} ${ROOT_XML} ${ROOT_XSL})
|
||||
add_executable(${NAME} ${ROOT_CPP} ${ROOT_XML} ${ROOT_XSL} ${ROOT_TXT})
|
||||
|
@ -327,7 +327,7 @@ namespace detail
|
||||
# define GLM_RESTRICT_VAR __restrict
|
||||
#elif((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC31))
|
||||
# define GLM_DEPRECATED __attribute__((__deprecated__))
|
||||
# define GLM_ALIGN(x) __attribute__(aligned(x))
|
||||
# define GLM_ALIGN(x) __attribute__((aligned(x)))
|
||||
# if(GLM_COMPILER >= GLM_COMPILER_GCC33)
|
||||
# define GLM_RESTRICT __restrict__
|
||||
# define GLM_RESTRICT_VAR __restrict__
|
||||
|
@ -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
|
||||
|
@ -133,6 +133,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,
|
||||
|
@ -150,7 +150,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(
|
||||
|
@ -370,6 +370,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
|
||||
(
|
||||
|
@ -142,7 +142,7 @@ namespace glm
|
||||
//! Multiply matrix x by matrix y component-wise, i.e.,
|
||||
//! result[i][j] is the scalar product of x[i][j] and y[i][j].
|
||||
//! (From GLM_GTX_simd_mat4 extension).
|
||||
detail::fmat4x4SIMD simdMatrixCompMult(
|
||||
detail::fmat4x4SIMD matrixCompMult(
|
||||
detail::fmat4x4SIMD const & x,
|
||||
detail::fmat4x4SIMD const & y);
|
||||
|
||||
@ -150,23 +150,23 @@ namespace glm
|
||||
//! and the second parameter r as a row vector
|
||||
//! and does a linear algebraic matrix multiply c * r.
|
||||
//! (From GLM_GTX_simd_mat4 extension).
|
||||
detail::fmat4x4SIMD simdOuterProduct(
|
||||
detail::fmat4x4SIMD outerProduct(
|
||||
detail::fvec4SIMD const & c,
|
||||
detail::fvec4SIMD const & r);
|
||||
|
||||
//! Returns the transposed matrix of x
|
||||
//! (From GLM_GTX_simd_mat4 extension).
|
||||
detail::fmat4x4SIMD simdTranspose(
|
||||
detail::fmat4x4SIMD transpose(
|
||||
detail::fmat4x4SIMD const & x);
|
||||
|
||||
//! Return the determinant of a mat4 matrix.
|
||||
//! (From GLM_GTX_simd_mat4 extension).
|
||||
float simdDeterminant(
|
||||
float determinant(
|
||||
detail::fmat4x4SIMD const & m);
|
||||
|
||||
//! Return the inverse of a mat4 matrix.
|
||||
//! (From GLM_GTX_simd_mat4 extension).
|
||||
detail::fmat4x4SIMD simdInverse(
|
||||
detail::fmat4x4SIMD inverse(
|
||||
detail::fmat4x4SIMD const & m);
|
||||
|
||||
}//namespace simd_mat4
|
||||
|
@ -242,7 +242,7 @@ namespace simd_mat4
|
||||
detail::fmat4x4SIMD const & x
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<float> Result;
|
||||
GLM_ALIGN(16) detail::tmat4x4<float> Result;
|
||||
_mm_store_ps(&Result[0][0], x.Data[0].Data);
|
||||
_mm_store_ps(&Result[1][0], x.Data[1].Data);
|
||||
_mm_store_ps(&Result[2][0], x.Data[2].Data);
|
||||
@ -250,7 +250,7 @@ namespace simd_mat4
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline detail::fmat4x4SIMD simdMatrixCompMult
|
||||
inline detail::fmat4x4SIMD matrixCompMult
|
||||
(
|
||||
detail::fmat4x4SIMD const & x,
|
||||
detail::fmat4x4SIMD const & y
|
||||
@ -264,30 +264,40 @@ namespace simd_mat4
|
||||
return result;
|
||||
}
|
||||
|
||||
inline detail::fmat4x4SIMD simdOuterProduct
|
||||
inline detail::fmat4x4SIMD outerProduct
|
||||
(
|
||||
detail::fvec4SIMD const & c,
|
||||
detail::fvec4SIMD const & r
|
||||
)
|
||||
{
|
||||
__m128 Shu0 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(0, 0, 0, 0));
|
||||
__m128 Shu1 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(1, 1, 1, 1));
|
||||
__m128 Shu2 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(2, 2, 2, 2));
|
||||
__m128 Shu3 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(3, 3, 3, 3));
|
||||
|
||||
detail::fmat4x4SIMD result(detail::fmat4x4SIMD::null);
|
||||
result[0].Data = _mm_mul_ps(c.Data, Shu0);
|
||||
result[1].Data = _mm_mul_ps(c.Data, Shu1);
|
||||
result[2].Data = _mm_mul_ps(c.Data, Shu2);
|
||||
result[3].Data = _mm_mul_ps(c.Data, Shu3);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline detail::fmat4x4SIMD simdTranspose(detail::fmat4x4SIMD const & m)
|
||||
inline detail::fmat4x4SIMD transpose(detail::fmat4x4SIMD const & m)
|
||||
{
|
||||
detail::fmat4x4SIMD result;
|
||||
detail::sse_transpose_ps(&m[0].Data, &result[0].Data);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline float simdDeterminant(detail::fmat4x4SIMD const & m)
|
||||
inline float determinant(detail::fmat4x4SIMD const & m)
|
||||
{
|
||||
float Result;
|
||||
_mm_store_ss(&Result, detail::sse_det_ps(&m[0].Data));
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline detail::fmat4x4SIMD simdInverse(detail::fmat4x4SIMD const & m)
|
||||
inline detail::fmat4x4SIMD inverse(detail::fmat4x4SIMD const & m)
|
||||
{
|
||||
detail::fmat4x4SIMD result;
|
||||
detail::sse_inverse_ps(&m[0].Data, &result[0].Data);
|
||||
|
@ -336,23 +336,47 @@ namespace glm
|
||||
|
||||
//! Returns the length of x, i.e., sqrt(x * x).
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
float simdLength(
|
||||
float length(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns the length of x, i.e., sqrt(x * x).
|
||||
//! Less accurate but much faster than simdLength.
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
float fastLength(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns the length of x, i.e., sqrt(x * x).
|
||||
//! Slightly more accurate but much slower than simdLength.
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
float niceLength(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns the length of x, i.e., sqrt(x * x).
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
detail::fvec4SIMD simdLength4(
|
||||
detail::fvec4SIMD length4(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns the length of x, i.e., sqrt(x * x).
|
||||
//! Less accurate but much faster than simdLength4.
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
detail::fvec4SIMD fastLength4(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns the length of x, i.e., sqrt(x * x).
|
||||
//! Slightly more accurate but much slower than simdLength4.
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
detail::fvec4SIMD niceLength4(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
float simdDistance(
|
||||
float distance(
|
||||
detail::fvec4SIMD const & p0,
|
||||
detail::fvec4SIMD const & p1);
|
||||
|
||||
//! Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
detail::fvec4SIMD simdDistance4(
|
||||
detail::fvec4SIMD distance4(
|
||||
detail::fvec4SIMD const & p0,
|
||||
detail::fvec4SIMD const & p1);
|
||||
|
||||
@ -364,19 +388,25 @@ namespace glm
|
||||
|
||||
//! Returns the dot product of x and y, i.e., result = x * y.
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
detail::fvec4SIMD simdDot4(
|
||||
detail::fvec4SIMD dot4(
|
||||
detail::fvec4SIMD const & x,
|
||||
detail::fvec4SIMD const & y);
|
||||
|
||||
//! Returns the cross product of x and y.
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
detail::fvec4SIMD simdCross(
|
||||
detail::fvec4SIMD cross(
|
||||
detail::fvec4SIMD const & x,
|
||||
detail::fvec4SIMD const & y);
|
||||
|
||||
//! Returns a vector in the same direction as x but with length of 1.
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
detail::fvec4SIMD simdNormalize(
|
||||
detail::fvec4SIMD normalize(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns a vector in the same direction as x but with length of 1.
|
||||
//! Less accurate but much faster than simdNormalize.
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
detail::fvec4SIMD fastNormalize(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! If dot(Nref, I) < 0.0, return N, otherwise, return -N.
|
||||
@ -389,7 +419,7 @@ namespace glm
|
||||
//! For the incident vector I and surface orientation N,
|
||||
//! returns the reflection direction : result = I - 2.0 * dot(N, I) * N.
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
detail::fvec4SIMD simdReflect(
|
||||
detail::fvec4SIMD reflect(
|
||||
detail::fvec4SIMD const & I,
|
||||
detail::fvec4SIMD const & N);
|
||||
|
||||
@ -397,10 +427,39 @@ namespace glm
|
||||
//! and the ratio of indices of refraction eta,
|
||||
//! return the refraction vector.
|
||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||
detail::fvec4SIMD simdRefract(
|
||||
detail::fvec4SIMD refract(
|
||||
detail::fvec4SIMD const & I,
|
||||
detail::fvec4SIMD const & N,
|
||||
float const & eta);
|
||||
|
||||
//! Returns the positive square root of x.
|
||||
//! (From GLM_GTX_simd_vec4 extension, exponential function)
|
||||
detail::fvec4SIMD sqrt(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns the positive square root of x with the nicest quality but very slow.
|
||||
//! Slightly more accurate but much slower than simdSqrt.
|
||||
//! (From GLM_GTX_simd_vec4 extension, exponential function)
|
||||
detail::fvec4SIMD niceSqrt(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns the positive square root of x
|
||||
//! Less accurate but much faster than sqrt.
|
||||
//! (From GLM_GTX_simd_vec4 extension, exponential function)
|
||||
detail::fvec4SIMD fastSqrt(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns the reciprocal of the positive square root of x.
|
||||
//! (From GLM_GTX_simd_vec4 extension, exponential function)
|
||||
detail::fvec4SIMD inversesqrt(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
//! Returns the reciprocal of the positive square root of x.
|
||||
//! Faster than inversesqrt but less accurate.
|
||||
//! (From GLM_GTX_simd_vec4 extension, exponential function)
|
||||
detail::fvec4SIMD fastInversesqrt(
|
||||
detail::fvec4SIMD const & x);
|
||||
|
||||
}//namespace simd_vec4
|
||||
}//namespace gtx
|
||||
}//namespace glm
|
||||
|
@ -275,7 +275,7 @@ namespace glm
|
||||
detail::fvec4SIMD const & x
|
||||
)
|
||||
{
|
||||
detail::tvec4<float> Result;
|
||||
GLM_ALIGN(4) detail::tvec4<float> Result;
|
||||
_mm_store_ps(&Result[0], x.Data);
|
||||
return Result;
|
||||
}
|
||||
@ -530,25 +530,67 @@ namespace glm
|
||||
return _mm_add_ps(_mm_mul_ps(a.Data, b.Data), c.Data);
|
||||
}
|
||||
|
||||
inline float simdLength
|
||||
inline float length
|
||||
(
|
||||
detail::fvec4SIMD const & x
|
||||
)
|
||||
{
|
||||
detail::fvec4SIMD dot0 = detail::sse_dot_ss(x.Data, x.Data);
|
||||
detail::fvec4SIMD sqt0 = sqrt(dot0);
|
||||
float Result = 0;
|
||||
_mm_store_ss(&Result, detail::sse_len_ps(x.Data));
|
||||
_mm_store_ss(&Result, sqt0.Data);
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD simdLength4
|
||||
inline float fastLength
|
||||
(
|
||||
detail::fvec4SIMD const & x
|
||||
)
|
||||
{
|
||||
return detail::sse_len_ps(x.Data);
|
||||
detail::fvec4SIMD dot0 = detail::sse_dot_ss(x.Data, x.Data);
|
||||
detail::fvec4SIMD sqt0 = fastSqrt(dot0);
|
||||
float Result = 0;
|
||||
_mm_store_ss(&Result, sqt0.Data);
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline float simdDistance
|
||||
inline float niceLength
|
||||
(
|
||||
detail::fvec4SIMD const & x
|
||||
)
|
||||
{
|
||||
detail::fvec4SIMD dot0 = detail::sse_dot_ss(x.Data, x.Data);
|
||||
detail::fvec4SIMD sqt0 = niceSqrt(dot0);
|
||||
float Result = 0;
|
||||
_mm_store_ss(&Result, sqt0.Data);
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD length4
|
||||
(
|
||||
detail::fvec4SIMD const & x
|
||||
)
|
||||
{
|
||||
return sqrt(dot4(x, x));
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD fastLength4
|
||||
(
|
||||
detail::fvec4SIMD const & x
|
||||
)
|
||||
{
|
||||
return fastSqrt(dot4(x, x));
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD niceLength4
|
||||
(
|
||||
detail::fvec4SIMD const & x
|
||||
)
|
||||
{
|
||||
return niceSqrt(dot4(x, x));
|
||||
}
|
||||
|
||||
inline float distance
|
||||
(
|
||||
detail::fvec4SIMD const & p0,
|
||||
detail::fvec4SIMD const & p1
|
||||
@ -559,7 +601,7 @@ namespace glm
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD simdDistance4
|
||||
inline detail::fvec4SIMD distance4
|
||||
(
|
||||
detail::fvec4SIMD const & p0,
|
||||
detail::fvec4SIMD const & p1
|
||||
@ -568,7 +610,7 @@ namespace glm
|
||||
return detail::sse_dst_ps(p0.Data, p1.Data);
|
||||
}
|
||||
|
||||
inline float simdDot
|
||||
inline float dot
|
||||
(
|
||||
detail::fvec4SIMD const & x,
|
||||
detail::fvec4SIMD const & y
|
||||
@ -579,16 +621,16 @@ namespace glm
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD simdDot4
|
||||
inline detail::fvec4SIMD dot4
|
||||
(
|
||||
detail::fvec4SIMD const & x,
|
||||
detail::fvec4SIMD const & y
|
||||
)
|
||||
{
|
||||
return detail::sse_dot_ss(x.Data, y.Data);
|
||||
return detail::sse_dot_ps(x.Data, y.Data);
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD simdCross
|
||||
inline detail::fvec4SIMD cross
|
||||
(
|
||||
detail::fvec4SIMD const & x,
|
||||
detail::fvec4SIMD const & y
|
||||
@ -597,15 +639,29 @@ namespace glm
|
||||
return detail::sse_xpd_ps(x.Data, y.Data);
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD simdNormalize
|
||||
inline detail::fvec4SIMD normalize
|
||||
(
|
||||
detail::fvec4SIMD const & x
|
||||
)
|
||||
{
|
||||
return detail::sse_nrm_ps(x.Data);
|
||||
__m128 dot0 = detail::sse_dot_ps(x.Data, x.Data);
|
||||
__m128 isr0 = inversesqrt(dot0).Data;
|
||||
__m128 mul0 = _mm_mul_ps(x.Data, isr0);
|
||||
return mul0;
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD simdFaceforward
|
||||
inline detail::fvec4SIMD fastNormalize
|
||||
(
|
||||
detail::fvec4SIMD const & x
|
||||
)
|
||||
{
|
||||
__m128 dot0 = detail::sse_dot_ps(x.Data, x.Data);
|
||||
__m128 isr0 = fastInversesqrt(dot0).Data;
|
||||
__m128 mul0 = _mm_mul_ps(x.Data, isr0);
|
||||
return mul0;
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD faceforward
|
||||
(
|
||||
detail::fvec4SIMD const & N,
|
||||
detail::fvec4SIMD const & I,
|
||||
@ -615,7 +671,7 @@ namespace glm
|
||||
return detail::sse_ffd_ps(N.Data, I.Data, Nref.Data);
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD simdReflect
|
||||
inline detail::fvec4SIMD reflect
|
||||
(
|
||||
detail::fvec4SIMD const & I,
|
||||
detail::fvec4SIMD const & N
|
||||
@ -624,7 +680,7 @@ namespace glm
|
||||
return detail::sse_rfe_ps(I.Data, N.Data);
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD simdRefract
|
||||
inline detail::fvec4SIMD refract
|
||||
(
|
||||
detail::fvec4SIMD const & I,
|
||||
detail::fvec4SIMD const & N,
|
||||
@ -634,6 +690,39 @@ namespace glm
|
||||
return detail::sse_rfa_ps(I.Data, N.Data, _mm_set1_ps(eta));
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD sqrt(detail::fvec4SIMD const & x)
|
||||
{
|
||||
return _mm_mul_ps(inversesqrt(x.Data).Data, x.Data);
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD niceSqrt(detail::fvec4SIMD const & x)
|
||||
{
|
||||
return _mm_sqrt_ps(x.Data);
|
||||
}
|
||||
|
||||
inline detail::fvec4SIMD fastSqrt(detail::fvec4SIMD const & x)
|
||||
{
|
||||
return _mm_mul_ps(fastInversesqrt(x.Data).Data, x.Data);
|
||||
}
|
||||
|
||||
// SSE scalar reciprocal sqrt using rsqrt op, plus one Newton-Rhaphson iteration
|
||||
// By Elan Ruskin, http://assemblyrequired.crashworks.org/
|
||||
inline detail::fvec4SIMD inversesqrt(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 fastInversesqrt(detail::fvec4SIMD const & x)
|
||||
{
|
||||
return _mm_rsqrt_ps(x.Data);
|
||||
}
|
||||
|
||||
}//namespace simd_vec4
|
||||
}//namespace gtx
|
||||
}//namespace glm
|
||||
|
234
readme.txt
234
readme.txt
@ -1,12 +1,21 @@
|
||||
=============================
|
||||
================================================================================
|
||||
G-Truc Creation
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
www.g-truc.net
|
||||
glm@g-truc.net
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM Usage
|
||||
--------------------------------------------------------------------------------
|
||||
GLM is a header only library, there is nothing to build, just include it.
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
More informations in GLM manual:
|
||||
http://glm.g-truc.net/glm-manual.pdf
|
||||
|
||||
================================================================================
|
||||
GLM 0.9.1.A: 2010-01-31
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Added SIMD support
|
||||
- Added new swizzle functions
|
||||
- Improved static assert error message with C++0x static_assert
|
||||
@ -14,314 +23,315 @@ GLM 0.9.1.A: 2010-01-31
|
||||
- Reduced branching
|
||||
- Fixed trunc implementation
|
||||
|
||||
=============================
|
||||
GLM 0.9.0.7: 2010-01-30
|
||||
-----------------------------
|
||||
- Added == and != operator for *mat* and *vec*
|
||||
================================================================================
|
||||
GLM 0.9.0.7: 2011-01-30
|
||||
--------------------------------------------------------------------------------
|
||||
- Added GLSL 4.10 packing functions
|
||||
- Added == and != operators for every types.
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.9.0.6: 2010-12-21
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Many matrices bugs fixed
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.9.0.5: 2010-11-01
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Improved Clang support
|
||||
- Fixed bugs
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.9.0.4: 2010-10-04
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Added autoexp for GLM
|
||||
- Fixed bugs
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.9.0.3: 2010-08-26
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed non-squared matrix operators
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.9.0.2: 2010-07-08
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Added GLM_GTX_int_10_10_10_2
|
||||
- Fixed bugs
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.9.0.1: 2010-06-21
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed extensions errors
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.9.0.0: 2010-05-25
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Objective-C support
|
||||
- Fixed warnings
|
||||
- Updated documentation
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.9.B.2: 2010-04-30
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Git transition
|
||||
- Removed experimental code from releases
|
||||
- Fixed bugs
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.9.B.1: 2010-04-03
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Based on GLSL 4.00 specification
|
||||
- Added the new core functions
|
||||
- Added some implicit conversion support
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.9.A.2: 2010-02-20
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Improved some possible errors messages
|
||||
- Improved declarations and definitions match
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.9.A.1: 2010-02-09
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Removed deprecated features
|
||||
- Internal redesign
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.4.4 final: 2010-01-25
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed warnings
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.4.3 final: 2009-11-16
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed Half float arithmetic
|
||||
- Fixed setup defines
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.4.2 final: 2009-10-19
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed Half float adds
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.4.1 final: 2009-10-05
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Updated documentation
|
||||
- Fixed MacOS X build
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.4.0 final: 2009-09-16
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Added GCC 4.4 and VC2010 support
|
||||
- Added matrix optimizations
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.3.5 final: 2009-08-11
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed bugs
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.3.4 final: 2009-08-10
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Updated GLM according GLSL 1.5 spec
|
||||
- Fixed bugs
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.3.3 final: 2009-06-25
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed bugs
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.3.2 final: 2009-06-04
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Added GLM_GTC_quaternion
|
||||
- Added GLM_GTC_type_precision
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.3.1 final: 2009-05-21
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed old extension system.
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.3.0 final: 2009-05-06
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Added stable extensions.
|
||||
- Added new extension system.
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.2.3 final: 2009-04-01
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed bugs.
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.2.2 final: 2009-02-24
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed bugs.
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.2.1 final: 2009-02-13
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed bugs.
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.2 final: 2009-01-21
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed bugs.
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.1 final: 2008-10-30
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed bugs.
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.0 final: 2008-10-23
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- New method to use extension.
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.0 beta3: 2008-10-10
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Added CMake support for GLM tests.
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.0 beta2: 2008-10-04
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Improved half scalars and vectors support.
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.8.0 beta1: 2008-09-26
|
||||
-----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Improved GLSL conformance
|
||||
- Added GLSL 1.30 support
|
||||
- Improved API documentation
|
||||
|
||||
=============================
|
||||
================================================================================
|
||||
GLM 0.7.6 final: 2008-08-08
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Improved C++ standard comformance
|
||||
- Added Static assert for types checking
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.7.5 final: 2008-07-05
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Added build message system with Visual Studio
|
||||
- Pedantic build with GCC
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.7.4 final: 2008-06-01
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Added external dependencies system.
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.7.3 final: 2008-05-24
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed bugs
|
||||
- Added new extension group
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.7.2 final: 2008-04-27
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Updated documentation
|
||||
- Added preprocessor options
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.7.1 final: 2008-03-24
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Disabled half on GCC
|
||||
- Fixed extensions
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.7.0 final: 2008-03-22
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Changed to MIT license
|
||||
- Added new documentation
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.6.4 : 2007-12-10
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed swizzle operators
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.6.3 : 2007-11-05
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed type data accesses
|
||||
- Fixed 3DSMax sdk conflict
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.6.2 : 2007-10-08
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed extension
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.6.1 : 2007-10-07
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed a namespace error
|
||||
- Added extensions
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.6.0 : 2007-09-16
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Added new extension namespace mecanium
|
||||
- Added Automatic compiler detection
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.5.1 : 2007-02-19
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed swizzle operators
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.5.0 : 2007-01-06
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Upgrated to GLSL 1.2
|
||||
- Added swizzle operators
|
||||
- Added setup settings
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.4.1 : 2006-05-22
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Added OpenGL examples
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.4.0 : 2006-05-17
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Added missing operators to vec* and mat*
|
||||
- Added first GLSL 1.2 features
|
||||
- Fixed windows.h before glm.h when windows.h required
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.3.2 : 2006-04-21
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Fixed texcoord components access.
|
||||
- Fixed mat4 and imat4 division operators.
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.3.1 : 2006-03-28
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Added GCC 4.0 support under MacOS X.
|
||||
- Added GCC 4.0 and 4.1 support under Linux.
|
||||
- Added code optimisations.
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.3 : 2006-02-19
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Improved GLSL type conversion and construction compliance.
|
||||
- Added experimental extensions.
|
||||
- Added Doxygen Documentation.
|
||||
- Added code optimisations.
|
||||
- Fixed bugs.
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.2: 2005-05-05
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Improve adaptative from GLSL.
|
||||
- Add experimental extensions based on OpenGL extension process.
|
||||
- Fixe bugs.
|
||||
|
||||
===========================
|
||||
================================================================================
|
||||
GLM 0.1: 2005-02-21
|
||||
---------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
- Add vec2, vec3, vec4 GLSL types
|
||||
- Add ivec2, ivec3, ivec4 GLSL types
|
||||
- Add bvec2, bvec3, bvec4 GLSL types
|
||||
- Add mat2, mat3, mat4 GLSL types
|
||||
- Add almost all functions
|
||||
|
||||
================================================================================
|
||||
|
@ -28,7 +28,7 @@ std::vector<float> test_detA(std::vector<glm::mat4> const & Data)
|
||||
Test[i] = glm::determinant(Data[i]);
|
||||
|
||||
std::clock_t TimeEnd = clock();
|
||||
printf("Det A: %d\n", TimeEnd - TimeStart);
|
||||
printf("Det A: %ld\n", TimeEnd - TimeStart);
|
||||
|
||||
return Test;
|
||||
}
|
||||
@ -49,7 +49,7 @@ std::vector<float> test_detB(std::vector<glm::mat4> const & Data)
|
||||
}
|
||||
|
||||
std::clock_t TimeEnd = clock();
|
||||
printf("Det B: %d\n", TimeEnd - TimeStart);
|
||||
printf("Det B: %ld\n", TimeEnd - TimeStart);
|
||||
|
||||
return Test;
|
||||
}
|
||||
@ -70,7 +70,7 @@ std::vector<float> test_detC(std::vector<glm::mat4> const & Data)
|
||||
}
|
||||
|
||||
std::clock_t TimeEnd = clock();
|
||||
printf("Det C: %d\n", TimeEnd - TimeStart);
|
||||
printf("Det C: %ld\n", TimeEnd - TimeStart);
|
||||
|
||||
return Test;
|
||||
}
|
||||
@ -91,7 +91,7 @@ std::vector<float> test_detD(std::vector<glm::mat4> const & Data)
|
||||
}
|
||||
|
||||
std::clock_t TimeEnd = clock();
|
||||
printf("Det D: %d\n", TimeEnd - TimeStart);
|
||||
printf("Det D: %ld\n", TimeEnd - TimeStart);
|
||||
|
||||
return Test;
|
||||
}
|
||||
@ -109,7 +109,7 @@ void test_invA(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out
|
||||
}
|
||||
|
||||
std::clock_t TimeEnd = clock();
|
||||
printf("Inv A: %d\n", TimeEnd - TimeStart);
|
||||
printf("Inv A: %ld\n", TimeEnd - TimeStart);
|
||||
}
|
||||
|
||||
void test_invC(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out)
|
||||
@ -129,7 +129,7 @@ void test_invC(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out
|
||||
}
|
||||
|
||||
std::clock_t TimeEnd = clock();
|
||||
printf("Inv C: %d\n", TimeEnd - TimeStart);
|
||||
printf("Inv C: %ld\n", TimeEnd - TimeStart);
|
||||
}
|
||||
|
||||
void test_invD(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out)
|
||||
@ -149,7 +149,7 @@ void test_invD(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out
|
||||
}
|
||||
|
||||
std::clock_t TimeEnd = clock();
|
||||
printf("Inv D: %d\n", TimeEnd - TimeStart);
|
||||
printf("Inv D: %ld\n", TimeEnd - TimeStart);
|
||||
}
|
||||
|
||||
void test_mulA(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out)
|
||||
@ -165,7 +165,7 @@ void test_mulA(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out
|
||||
}
|
||||
|
||||
std::clock_t TimeEnd = clock();
|
||||
printf("Mul A: %d\n", TimeEnd - TimeStart);
|
||||
printf("Mul A: %ld\n", TimeEnd - TimeStart);
|
||||
}
|
||||
|
||||
void test_mulD(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out)
|
||||
@ -183,7 +183,7 @@ void test_mulD(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out
|
||||
}
|
||||
|
||||
std::clock_t TimeEnd = clock();
|
||||
printf("Mul D: %d\n", TimeEnd - TimeStart);
|
||||
printf("Mul D: %ld\n", TimeEnd - TimeStart);
|
||||
}
|
||||
|
||||
int test_compute_glm()
|
||||
@ -222,7 +222,7 @@ int test_compute_gtx()
|
||||
}
|
||||
|
||||
std::clock_t TimeEnd = clock();
|
||||
printf("test_compute_gtx: %d\n", TimeEnd - TimeStart);
|
||||
printf("test_compute_gtx: %ld\n", TimeEnd - TimeStart);
|
||||
|
||||
return Output.size() != 0;
|
||||
}
|
||||
@ -280,8 +280,8 @@ int main()
|
||||
Failed += test_compute_glm();
|
||||
Failed += test_compute_gtx();
|
||||
|
||||
float Det = glm::simdDeterminant(glm::simdMat4(1.0));
|
||||
glm::simdMat4 D = glm::simdMatrixCompMult(glm::simdMat4(1.0), glm::simdMat4(1.0));
|
||||
float Det = glm::determinant(glm::simdMat4(1.0));
|
||||
glm::simdMat4 D = glm::matrixCompMult(glm::simdMat4(1.0), glm::simdMat4(1.0));
|
||||
|
||||
system("pause");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user