Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functions can not consume a swizzled vector directly #1325

Open
fknfilewalker opened this issue Nov 28, 2024 · 1 comment
Open

functions can not consume a swizzled vector directly #1325

fknfilewalker opened this issue Nov 28, 2024 · 1 comment

Comments

@fknfilewalker
Copy link

It would be nice to allow some implicite conversions for _swizzle types so that functions like normalize can consume them directly.

The following does not work:

glm::vec4 vector = { 1.0f, 2.0f, 3.0f, 4.0f };
glm::normalize(vector.xxx);

This works:

glm::vec4 vector = { 1.0f, 2.0f, 3.0f, 4.0f };
glm::vec3 vector2 = vector.xxx;
glm::normalize(vector2);
@fknfilewalker fknfilewalker changed the title some function do not take a swizzled vector directly functions can not consume a swizzled vector directly Nov 28, 2024
@fknfilewalker
Copy link
Author

one way would be to add additional functions like

template<glm::length_t L, typename T, glm::qualifier Q, int E0, int E1, int E2, int E3>
glm::vec<L, T, Q> normalize(glm::detail::_swizzle<L, T, Q, E0, E1, E2, E3> const& x)
{
    return glm::detail::compute_normalize<L, T, Q, glm::detail::is_aligned<Q>::value>::call(x);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant