I've a problem using glm math lib with simd. I've encounter a problem during the calculation of the lookat matrix.
Follow my lookAt functions:
FORCE_INLINE_ALWAYSINLINE const glm::detail::fmat4x4SIMD LookAt( const glm::detail::fvec4SIMD &eyePos, const glm::detail::fvec4SIMD &lookAtPos, const glm::detail::fvec4SIMD &upVec )
{
glm::detail::fvec4SIMD v3X, v3Y, v3Z;
v3Y = glm::normalize(upVec);
v3Z = glm::normalize(eyePos - lookAtPos);
v3X = glm::normalize(glm::cross(v3Y, v3Z));
v3Y = glm::cross(v3Z, v3X);
glm::detail::fmat4x4SIMD m4EyeFrame = glm::detail::fmat4x4SIMD(v3X, v3Y, v3Z, eyePos);
return m4EyeFrame;
}
Unfortunately doesn't work well, for example: If the eyePos (the camera position) is in 0,0,-10 and lookAtPos (target position) is in 0,0,0 and the object is at that position, the view work well. But if I move eyePos on X or Y axis, the model seems deformed (like stretched) or disappears as if it had gone outside of the frustum, but in real it is still within. NOTE: every fourth element of fvec4SIMD is set to 1.0f
I've also read this post: My SSE implementation of lookAt doesn't work but I cannot use within fmat4x4SIMD because of rows to columns translation, maybe I need to shuffle all elements to convert from row to column, but I don't know how to do it in a fast way. This is just my impression, but maybe the problem lies elsewhere.
Any suggestion?