struct: struct vesion of swizzle funcs

This commit is contained in:
Recep Aslantas
2019-06-06 13:18:31 +03:00
parent 1fdd459733
commit 2025b35757
2 changed files with 36 additions and 0 deletions

View File

@@ -58,6 +58,7 @@
CGLM_INLINE vec3s glms_vec3_ortho(vec3s v);
CGLM_INLINE vec3s glms_vec3_clamp(vec3s v, float minVal, float maxVal);
CGLM_INLINE vec3s glms_vec3_lerp(vec3s from, vec3s to, float t);
CGLM_INLINE vec3s glms_vec3_swizzle(vec3s v, int mask);
Convenient:
CGLM_INLINE vec3s glms_cross(vec3s a, vec3s b);
@@ -747,4 +748,21 @@ glms_normalize(vec3s v) {
return v;
}
/*!
* @brief swizzle vector components
*
* you can use existin masks e.g. GLM_XXX, GLM_ZYX
*
* @param[in] v source
* @param[in] mask mask
* @returns swizzled vector
*/
CGLM_INLINE
vec3s
glms_vec3_swizzle(vec3s v, int mask) {
vec3s dest;
glm_vec3_swizzle(v.raw, mask, dest.raw);
return dest;
}
#endif /* cglms_vec3s_h */

View File

@@ -48,6 +48,7 @@
CGLM_INLINE vec4s glms_vec4_clamp(vec4s v, float minVal, float maxVal);
CGLM_INLINE vec4s glms_vec4_lerp(vec4s from, vec4s to, float t);
CGLM_INLINE vec4s glms_vec4_cubic(float s);
CGLM_INLINE vec4s glms_vec4_swizzle(vec4s v, int mask);
*/
#ifndef cglms_vec4s_h
@@ -577,4 +578,21 @@ glms_vec4_cubic(float s) {
return r;
}
/*!
* @brief swizzle vector components
*
* you can use existin masks e.g. GLM_XXXX, GLM_WZYX
*
* @param[in] v source
* @param[in] mask mask
* @returns swizzled vector
*/
CGLM_INLINE
vec4s
glms_vec4_swizzle(vec4s v, int mask) {
vec4s dest;
glm_vec4_swizzle(v.raw, mask, dest.raw);
return dest;
}
#endif /* cglms_vec4s_h */