vec4: add new function glm_vec4_make

Function takes in a float array. Array must be
at least of size 4 and converts it into
a 4D vector.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
Vincent Davis Jr
2023-07-02 13:54:10 -05:00
parent 49dd24eaf2
commit 5833d1bf44
7 changed files with 75 additions and 0 deletions

View File

@@ -283,6 +283,10 @@ CGLM_EXPORT
void
glmc_vec4_sqrt(vec4 v, vec4 dest);
CGLM_EXPORT
void
glmc_vec4_make(float * __restrict src, vec4 dest);
#ifdef __cplusplus
}
#endif

View File

@@ -61,6 +61,7 @@
CGLM_INLINE vec4s glms_vec4_smoothinterpc(vec4s from, vec4s to, float t);
CGLM_INLINE vec4s glms_vec4_cubic(float s);
CGLM_INLINE vec4s glms_vec4_swizzle(vec4s v, int mask);
CGLM_INLINE vec4s glms_vec4_make(float * restrict src);
*/
#ifndef cglms_vec4s_h
@@ -811,4 +812,18 @@ glms_vec4_(swizzle)(vec4s v, int mask) {
return dest;
}
/*!
* @brief Create four dimensional vector from pointer
*
* @param[in] src pointer to an array of floats
* @returns constructed 4D vector from raw pointer
*/
CGLM_INLINE
vec4s
glms_vec4_(make)(float * __restrict src) {
vec4s dest;
glm_vec4_make(src, dest.raw);
return dest;
}
#endif /* cglms_vec4s_h */

View File

@@ -58,6 +58,7 @@
CGLM_INLINE void glm_vec4_smoothinterp(vec4 from, vec4 to, float t, vec4 dest);
CGLM_INLINE void glm_vec4_smoothinterpc(vec4 from, vec4 to, float t, vec4 dest);
CGLM_INLINE void glm_vec4_swizzle(vec4 v, int mask, vec4 dest);
CGLM_INLINE void glm_vec4_make(float * restrict src, vec4 dest);
DEPRECATED:
glm_vec4_dup
@@ -1133,4 +1134,17 @@ glm_vec4_swizzle(vec4 v, int mask, vec4 dest) {
glm_vec4_copy(t, dest);
}
/*!
* @brief Create four dimensional vector from pointer
*
* @param[in] src pointer to an array of floats
* @param[out] dest destination vector
*/
CGLM_INLINE
void
glm_vec4_make(float * __restrict src, vec4 dest) {
dest[0] = src[0]; dest[1] = src[1];
dest[2] = src[2]; dest[3] = src[3];
}
#endif /* cglm_vec4_h */