From 7274cee15309d572f70cda31202b2dbdea1f02fd Mon Sep 17 00:00:00 2001 From: Harry Godden Date: Thu, 2 Jul 2020 23:29:10 +0100 Subject: [PATCH] mat3_mulv: function behaviour to match with mat4 Using mat3_mulv with the same input/output vector creates undesired results. Respective mat4_mulv function provides temporary vec3 'res'. Updated this function to match behaviour of mat4. --- include/cglm/mat3.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/cglm/mat3.h b/include/cglm/mat3.h index 3126064..0b29f97 100644 --- a/include/cglm/mat3.h +++ b/include/cglm/mat3.h @@ -228,9 +228,11 @@ glm_mat3_transpose(mat3 m) { CGLM_INLINE void glm_mat3_mulv(mat3 m, vec3 v, vec3 dest) { - dest[0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2]; - dest[1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2]; - dest[2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2]; + vec3 res; + res[0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2]; + res[1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2]; + res[2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2]; + glm_vec3_copy(res, dest); } /*!