functions for vec to ivec conversion
duarm opened this issue · comments
I work hexagon maps, and I store everything with ivec3 because most operations are cheaper with integers. It's common for when calculating from hexagon space to world/screen space, convert the ivec3 to vec3, so there's no rounding issues. It would be nice to have ivec types to vec type conversions. Something like:
void vec3_ivec3(vec3 const a, ivec3 dest)
{
dest[0] = a[0];
dest[1] = a[1];
dest[2] = a[2];
}
void vec2_ivec2(vec2 const a, ivec2 dest)
{
dest[0] = a[0];
dest[1] = a[1];
}
Maybe a macro?
#define vec3_ivec3(a) ((ivec3) { a[0], a[1], a[2] })
ivec3 dest = vec3_ivec3(a);
any better ideas? feedback welcome.
Hi @duarm,
Sorry for the late response,
We can have float <-> int vector conversion as you proposed. I think we can continue with functions for now.
FWIW, in the future we may need additional functions for rounding numbers e.g. vec3_ivec3_round()
, vec3_ivec3_rounded()
, vec3_round_ivec3()
...