is uniform scaled func for mat4

This commit is contained in:
Recep Aslantas
2017-01-11 16:31:07 +02:00
parent 16107c4ba1
commit b1989bf3c9
2 changed files with 29 additions and 0 deletions

View File

@@ -295,6 +295,23 @@ glm_decompose_scalev(mat4 m, vec3 s) {
s[2] = glm_vec_norm(m[2]);
}
/*!
* @brief returns true if matrix is uniform scaled. This is helpful for
* creating normal matrix.
*
* @param m[in] m
*
* @return boolean
*/
CGLM_INLINE
bool
glm_uniscaled(mat4 m) {
vec3 s;
glm_decompose_scalev(m, s);
return glm_vec_eq_all(s);
}
/*!
* @brief decompose rotation matrix (mat4) and scale vector [Sx, Sy, Sz]
*

View File

@@ -73,10 +73,22 @@ glm_vec_eq(vec3 v, float val) {
return v[0] == val && v[0] == v[1] && v[0] == v[2];
}
CGLM_INLINE
bool
glm_vec_eq_all(vec3 v) {
return v[0] == v[1] && v[0] == v[2];
}
CGLM_INLINE
bool
glm_vec4_eq(vec4 v, float val) {
return v[0] == val && v[0] == v[1] && v[0] == v[2] && v[0] == v[3];
}
CGLM_INLINE
bool
glm_vec4_eq_all(vec4 v) {
return v[0] == v[1] && v[0] == v[2] && v[0] == v[3];
}
#endif /* cglm_vec_ext_h */