recp / cglm

📽 Highly Optimized 2D / 3D Graphics Math (glm) for C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use glm_{vec2,vec3,vec4} to fill vector by individual items

EasyIP2023 opened this issue · comments

Multiple PR's are merge to allow creating matrices and vectors given a pointer to an array of floats. All suffixed with name _make

  • glm_vec2_make
  • glm_vec3_make
  • glm_vec4_make
  • glm_mat2_make
  • glm_mat3_make
  • glm_mat4_make
    Later PR's
  • glm_mat2x3_make
  • glm_mat2x4_make
  • glm_mat3x2_make
  • glm_mat3x4_make
  • glm_mat4x2_make
  • glm_mat4x3_make

Full set

// Matrix 2x2, 2x3, 2x4
glm_vec2_make(float * __restrict src, vec2 dest);
glm_mat2_make(float * __restrict src, mat2 dest);
glm_mat2x3_make(float * __restrict src, mat2x3 dest);
glm_mat2x4_make(float * __restrict src, mat2x4 dest);

// Matrix 3x2, 3x3, 3x4
glm_vec3_make(float * __restrict src, vec3 dest);
glm_mat3x2_make(float * __restrict src, mat3x2 dest);
glm_mat3_make(float * __restrict src, mat3 dest);
glm_mat3x4_make(float * __restrict src, mat3x4 dest);

// Matrix 4x2, 4x3, 4x4
glm_vec4_make(float * __restrict src, vec4 dest);
glm_mat4x2_make(float * __restrict src, mat4x2 dest);
glm_mat4x3_make(float * __restrict src, mat4x3 dest);
glm_mat4_make(float * __restrict src, mat4 dest);

However one function glm_vec2 does exactly that.
Issue created to discuss if we should utilize functions
with no _make suffix to fill in vector by individual items.

glm_vec2(x, y, dest);
glm_vec3(x, y, z, dest);
glm_vec4(x, y, z, w, dest);

Hi @EasyIP2023,

I like the proposal but let wait a little bit to get more feedbacks,

Currently glm_vec3() creates vec3 from vec4 or pointer, glm_vec2() creates vec2 from pointer. glm_vec4(vec3, 1.0, dest) promotes vec3 to vec4 by adding last element.

We must DEPRECATE these or select alternative names for:

glm_vec2(x, y, dest);
glm_vec3(x, y, z, dest);
glm_vec4(x, y, z, w, dest);

e.g.

glm_vec2_from(x, y, dest);
glm_vec3_from(x, y, z, dest);
glm_vec4_from(x, y, z, w, dest);
glm_vec2_makes(x, y, dest);
glm_vec3_make_s(x, y, z, dest);
glm_vec4_make_s(x, y, z, w, dest);
glm_vec2_init(x, y, dest);
glm_vec3_init(x, y, z, dest);
glm_vec4_init(x, y, z, w, dest);

or any better names ... if we chose this direction