Closed Philip-Trettner closed 9 years ago
That indeed looks very suspicious, let me check against the C++ version.
Good eyes @Philip-Trettner, the original is:
template <typename T, typename U, precision P>
GLM_FUNC_QUALIFIER detail::tvec3<T, P> project
(
detail::tvec3<T, P> const & obj,
detail::tmat4x4<T, P> const & model,
detail::tmat4x4<T, P> const & proj,
detail::tvec4<U, P> const & viewport
)
{
detail::tvec4<T, P> tmp = detail::tvec4<T, P>(obj, T(1));
tmp = model * tmp;
tmp = proj * tmp;
tmp /= tmp.w;
tmp = tmp * T(0.5) + T(0.5);
tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]);
tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]);
return detail::tvec3<T, P>(tmp);
}
so indeed it is a bug. This function should be covered by a test ideally. I'm making the fix now.
Fixed in 0.5.1, cheers @Philip-Trettner!
Hi, I stumbled upon a strange line of code in
public static vec3 project(vec3 obj, mat4 model, mat4 proj, vec4 viewport)
the line in question is:tmp = tmp*((0.5f) + (0.5f));
( https://github.com/dwmkerr/glmnet/blob/master/source/GlmNet/GlmNet/matrix_transform.cs#L223 )This is either a bug or could be simplified.