Closed EasyIP2023 closed 1 year ago
Hi @EasyIP2023,
Thanks for the proposal,
Feedback on whether this would be accepted as PR.
sure, a PR would be awesome :)
Hi @EasyIP2023,
Similar: https://stackoverflow.com/questions/74844204/how-to-create-a-cglm-mat4-from-a-float16-array
Any progress?
it could be:
CGLM_INLINE
void
glm_mat4_make(float * __restrict src, mat4 dest) {
dest[0][0] = src[0]; dest[1][0] = src[4];
dest[0][1] = src[1]; dest[1][1] = src[5];
dest[0][2] = src[2]; dest[1][2] = src[6];
dest[0][3] = src[3]; dest[1][3] = src[7];
dest[2][0] = src[8]; dest[3][0] = src[12];
dest[2][1] = src[9]; dest[3][1] = src[13];
dest[2][2] = src[10]; dest[3][2] = src[14];
dest[2][3] = src[11]; dest[3][3] = src[15];
}
or maybe:
CGLM_INLINE
void
glm_mat4_from_cols(float * __restrict src, mat4 dest) {
dest[0][0] = src[0]; dest[1][0] = src[4];
dest[0][1] = src[1]; dest[1][1] = src[5];
dest[0][2] = src[2]; dest[1][2] = src[6];
dest[0][3] = src[3]; dest[1][3] = src[7];
dest[2][0] = src[8]; dest[3][0] = src[12];
dest[2][1] = src[9]; dest[3][1] = src[13];
dest[2][2] = src[10]; dest[3][2] = src[14];
dest[2][3] = src[11]; dest[3][3] = src[15];
}
CGLM_INLINE
void
glm_mat4_from_rows(float * __restrict src, mat4 dest) {
dest[0][0] = src[0]; dest[0][1] = src[4];
dest[1][0] = src[1]; dest[1][1] = src[5];
dest[2][0] = src[2]; dest[2][1] = src[6];
dest[3][0] = src[3]; dest[3][1] = src[7];
dest[0][2] = src[8]; dest[0][3] = src[12];
dest[1][2] = src[9]; dest[1][3] = src[13];
dest[2][2] = src[10]; dest[2][3] = src[14];
dest[3][2] = src[11]; dest[3][3] = src[15];
}
the second one allows to copy from ro-major layout to cglm, the first one is also cool. These are just suggestions maybe we get better name alternatives and impl
Hey, @recp Thanks! Yeah personally I prefer the first function call name.
Transpose can be called after glm_mat4_make
to simulate glm_mat4_from_rows
👍 thanks for the PR, let's continue in there 🚀
PR to follow: https://github.com/recp/cglm/pull/299
@EasyIP2023 I'm going to close this, thanks for your contributions.
Similar to
glm::make_mat4x4(float *)
https://glm.g-truc.net/0.9.4/api/a00158.html#gaa287485a3978d319e60a1cadd8a1c139
Make 4x4 matrix given a float array of size 16.
Would probably be good to add the whole suite of
glm::make_mat#x#(float *)
functions.https://glm.g-truc.net/0.9.4/api/a00158.html#func-members
Feedback on whether this would be accepted as PR. I can implement.