mirror of
https://github.com/recp/cglm.git
synced 2025-12-24 12:32:40 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user