vec3: add new function glm_vec3_make

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

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

View File

@@ -306,6 +306,10 @@ CGLM_EXPORT
void
glmc_vec3_sqrt(vec3 v, vec3 dest);
CGLM_EXPORT
void
glmc_vec3_make(float * __restrict src, vec3 dest);
#ifdef __cplusplus
}
#endif

View File

@@ -70,6 +70,7 @@
CGLM_INLINE vec3s glms_vec3_smoothinterp(vec3s from, vec3s to, float t);
CGLM_INLINE vec3s glms_vec3_smoothinterpc(vec3s from, vec3s to, float t);
CGLM_INLINE vec3s glms_vec3_swizzle(vec3s v, int mask);
CGLM_INLINE vec3s glms_vec3_make(float * restrict src);
Convenient:
CGLM_INLINE vec3s glms_cross(vec3s a, vec3s b);
@@ -967,4 +968,18 @@ glms_vec3_(swizzle)(vec3s v, int mask) {
return dest;
}
/*!
* @brief Create three dimensional vector from pointer
*
* @param[in] src pointer to an array of floats
* @returns constructed 3D vector from raw pointer
*/
CGLM_INLINE
vec3s
glms_vec3_(make)(float * __restrict src) {
vec3s dest;
glm_vec3_make(src, dest.raw);
return dest;
}
#endif /* cglms_vec3s_h */

View File

@@ -73,6 +73,7 @@
CGLM_INLINE void glm_vec3_smoothinterp(vec3 from, vec3 to, float t, vec3 dest);
CGLM_INLINE void glm_vec3_smoothinterpc(vec3 from, vec3 to, float t, vec3 dest);
CGLM_INLINE void glm_vec3_swizzle(vec3 v, int mask, vec3 dest);
CGLM_INLINE void glm_vec3_make(float * restrict src, vec3 dest);
Convenient:
CGLM_INLINE void glm_cross(vec3 a, vec3 b, vec3 d);
@@ -1079,4 +1080,18 @@ glm_normalize_to(vec3 v, vec3 dest) {
glm_vec3_normalize_to(v, dest);
}
/*!
* @brief Create three dimensional vector from pointer
*
* @param[in] src pointer to an array of floats
* @param[out] dest destination vector
*/
CGLM_INLINE
void
glm_vec3_make(float * __restrict src, vec3 dest) {
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
}
#endif /* cglm_vec3_h */