cglm icon indicating copy to clipboard operation
cglm copied to clipboard

Request: Functions for building vectors from floats

Open Nairou opened this issue 4 years ago • 1 comments
trafficstars

Currently the only way to build, say, a vec3s is manually:

vec3s value = {{ 1.0f, 0.0f, 0.5f }};
value = (vec3s) {{ 0.0f, 0.5f, 2.5f }};

This is very verbose, and the double braces required for the struct versions seem to confuse vim's syntax highlighting. It would be nice if there was a function to clean this up. (Something like glms_vec3(), but that's already taken for converting from vec4s.)

For example:

CGLM_INLINE vec3s glms_vec3_fromfloat(float a, float b, float c)
{
  return (vec3s){{a, b, c}};
}

vec3s value = glms_vec3_fromfloat(1.0f, 0.0f, 3.5f);

I don't know what an appropriate name would be in this case (glms_vec3_float? glms_vec3f? The shorter, the better.).

Nairou avatar Jun 28 '21 21:06 Nairou

Hi @Nairou

Thanks for your feedbacks 🤗, let's get more feedbacks for what to do

It would be nice to use glm_vec3 for this purpose :/ but maybe we can find alternative or better names...

recp avatar Jun 29 '21 19:06 recp