added glm_vec_fill() (#100)

* alternative name for _broadcast(): _fill()
This commit is contained in:
Luigi Castelli
2019-08-26 08:19:26 +02:00
committed by Recep Aslantas
parent 4639f3184a
commit 144624962a
8 changed files with 80 additions and 0 deletions

View File

@@ -233,6 +233,10 @@ glmc_vec3_mulv(vec3 a, vec3 b, vec3 d);
CGLM_EXPORT
void
glmc_vec3_broadcast(float val, vec3 d);
CGLM_EXPORT
void
glmc_vec3_fill(vec3 v, float val);
CGLM_EXPORT
bool

View File

@@ -210,6 +210,10 @@ glmc_vec4_mulv(vec4 a, vec4 b, vec4 d);
CGLM_EXPORT
void
glmc_vec4_broadcast(float val, vec4 d);
CGLM_EXPORT
void
glmc_vec4_fill(vec4 v, float val);
CGLM_EXPORT
bool

View File

@@ -12,6 +12,7 @@
/*
Functions:
CGLM_INLINE vec3s glms_vec3_broadcast(float val);
CGLM_INLINE vec3s glms_vec3_fill(float val);
CGLM_INLINE bool glms_vec3_eq(vec3s v, float val);
CGLM_INLINE bool glms_vec3_eq_eps(vec3s v, float val);
CGLM_INLINE bool glms_vec3_eq_all(vec3s v);
@@ -48,6 +49,20 @@ glms_vec3_broadcast(float val) {
return r;
}
/*!
* @brief fill a vector with specified value
*
* @param[in] val value
* @returns dest
*/
CGLM_INLINE
vec3s
glms_vec3_fill(float val) {
vec3s r;
glm_vec3_fill(r.raw, val);
return r;
}
/*!
* @brief check if vector is equal to value (without epsilon)
*

View File

@@ -12,6 +12,7 @@
/*
Functions:
CGLM_INLINE vec4s glms_vec4_broadcast(float val);
CGLM_INLINE vec4s glms_vec4_fill(float val);
CGLM_INLINE bool glms_vec4_eq(vec4s v, float val);
CGLM_INLINE bool glms_vec4_eq_eps(vec4s v, float val);
CGLM_INLINE bool glms_vec4_eq_all(vec4s v);
@@ -48,6 +49,20 @@ glms_vec4_broadcast(float val) {
return r;
}
/*!
* @brief fill a vector with specified value
*
* @param val value
* @returns dest
*/
CGLM_INLINE
vec4s
glms_vec4_fill(float val) {
vec4s r;
glm_vec4_fill(r.raw, val);
return r;
}
/*!
* @brief check if vector is equal to value (without epsilon)
*

View File

@@ -12,6 +12,7 @@
/*
Functions:
CGLM_INLINE void glm_vec3_broadcast(float val, vec3 d);
CGLM_INLINE void glm_vec3_fill(vec3 v, float val);
CGLM_INLINE bool glm_vec3_eq(vec3 v, float val);
CGLM_INLINE bool glm_vec3_eq_eps(vec3 v, float val);
CGLM_INLINE bool glm_vec3_eq_all(vec3 v);
@@ -44,6 +45,18 @@ glm_vec3_broadcast(float val, vec3 d) {
d[0] = d[1] = d[2] = val;
}
/*!
* @brief fill a vector with specified value
*
* @param[out] v dest
* @param[in] val value
*/
CGLM_INLINE
void
glm_vec3_fill(vec3 v, float val) {
v[0] = v[1] = v[2] = val;
}
/*!
* @brief check if vector is equal to value (without epsilon)
*

View File

@@ -12,6 +12,7 @@
/*
Functions:
CGLM_INLINE void glm_vec4_broadcast(float val, vec4 d);
CGLM_INLINE void glm_vec4_fill(vec4 v, float val);
CGLM_INLINE bool glm_vec4_eq(vec4 v, float val);
CGLM_INLINE bool glm_vec4_eq_eps(vec4 v, float val);
CGLM_INLINE bool glm_vec4_eq_all(vec4 v);
@@ -48,6 +49,22 @@ glm_vec4_broadcast(float val, vec4 d) {
#endif
}
/*!
* @brief fill a vector with specified value
*
* @param v dest
* @param val value
*/
CGLM_INLINE
void
glm_vec4_fill(vec4 v, float val) {
#if defined( __SSE__ ) || defined( __SSE2__ )
glmm_store(v, _mm_set1_ps(val));
#else
v[0] = v[1] = v[2] = v[3] = val;
#endif
}
/*!
* @brief check if vector is equal to value (without epsilon)
*

View File

@@ -310,6 +310,12 @@ glmc_vec3_broadcast(float val, vec3 d) {
glm_vec3_broadcast(val, d);
}
CGLM_EXPORT
void
glmc_vec3_fill(vec3 v, float val) {
glm_vec3_fill(v, val);
}
CGLM_EXPORT
bool
glmc_vec3_eq(vec3 v, float val) {

View File

@@ -274,6 +274,12 @@ glmc_vec4_broadcast(float val, vec4 d) {
glm_vec4_broadcast(val, d);
}
CGLM_EXPORT
void
glmc_vec4_fill(vec4 v, float val) {
glm_vec4_fill(v, val);
}
CGLM_EXPORT
bool
glmc_vec4_eq(vec4 v, float val) {