vec2: add new function glm_vec2_make

Just a copy of glm_vec2, but with the
word _make suffixed at the end.

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

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
Vincent Davis Jr
2023-07-02 11:59:39 -05:00
parent 49dd24eaf2
commit b3de85a14e
7 changed files with 72 additions and 0 deletions

View File

@@ -165,6 +165,10 @@ CGLM_EXPORT
void
glmc_vec2_complex_conjugate(vec2 a, vec2 dest);
CGLM_EXPORT
void
glmc_vec2_make(float * __restrict src, vec2 dest);
#ifdef __cplusplus
}
#endif

View File

@@ -46,6 +46,7 @@
CGLM_INLINE vec2s glms_vec2_minv(vec2s a, vec2s b)
CGLM_INLINE vec2s glms_vec2_clamp(vec2s v, float minVal, float maxVal)
CGLM_INLINE vec2s glms_vec2_lerp(vec2s from, vec2s to, float t)
CGLM_INLINE vec2s glms_vec2_make(float * restrict src)
*/
#ifndef cglms_vec2s_h
@@ -558,4 +559,18 @@ glms_vec2_(lerp)(vec2s from, vec2s to, float t) {
return r;
}
/*!
* @brief Create two dimensional vector from pointer
*
* @param[in] src pointer to an array of floats
* @returns constructed 2D vector from raw pointer
*/
CGLM_INLINE
vec2s
glms_vec2_(make)(float * __restrict src) {
vec2s dest;
glm_vec2_make(src, dest.raw);
return dest;
}
#endif /* cglms_vec2s_h */

View File

@@ -47,6 +47,7 @@
CGLM_INLINE void glm_vec2_minv(vec2 v1, vec2 v2, vec2 dest)
CGLM_INLINE void glm_vec2_clamp(vec2 v, float minVal, float maxVal)
CGLM_INLINE void glm_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest)
CGLM_INLINE void glm_vec2_make(float * restrict src, vec2 dest)
*/
@@ -582,4 +583,16 @@ glm_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest) {
glm_vec2_add(from, v, dest);
}
/*!
* @brief Create two dimensional vector from pointer
*
* @param[in] src pointer to an array of floats
* @param[out] dest destination vector
*/
CGLM_INLINE
void
glm_vec2_make(float * __restrict src, vec2 dest) {
dest[0] = src[0]; dest[1] = src[1];
}
#endif /* cglm_vec2_h */