change steps -> stepr and move to ext

This commit is contained in:
Marcin
2025-01-18 19:05:24 +00:00
parent 0e0eff71ce
commit c2ebef3867
4 changed files with 104 additions and 33 deletions

View File

@@ -28,6 +28,8 @@
CGLM_INLINE void glm_vec3_fract(vec3 v, vec3 dest);
CGLM_INLINE void glm_vec3_floor(vec3 v, vec3 dest);
CGLM_INLINE float glm_vec3_mods(vec3 v, float s, vec3 dest);
CGLM_INLINE float glm_vec3_steps(float edge, vec3 v, vec3 dest);
CGLM_INLINE void glm_vec3_stepr(vec3 edge, float v, vec3 dest);
CGLM_INLINE float glm_vec3_hadd(vec3 v);
CGLM_INLINE void glm_vec3_sqrt(vec3 v, vec3 dest);
*/
@@ -281,6 +283,38 @@ glm_vec3_mods(vec3 x, float y, vec3 dest) {
dest[2] = fmodf(x[2], y);
}
/*!
* @brief threshold each vector item with scalar
* condition is: (x[i] < edge) ? 0.0 : 1.0
*
* @param[in] edge threshold
* @param[in] x vector to test against threshold
* @param[out] dest destination
*/
CGLM_INLINE
void
glm_vec3_steps(float edge, vec3 x, vec3 dest) {
dest[0] = glm_step(edge, x[0]);
dest[1] = glm_step(edge, x[1]);
dest[2] = glm_step(edge, x[2]);
}
/*!
* @brief threshold a value with *vector* as the threshold
* condition is: (x < edge[i]) ? 0.0 : 1.0
*
* @param[in] edge threshold vector
* @param[in] x value to test against threshold
* @param[out] dest destination
*/
CGLM_INLINE
void
glm_vec3_stepr(vec3 edge, float x, vec3 dest) {
dest[0] = glm_step(edge[0], x);
dest[1] = glm_step(edge[1], x);
dest[2] = glm_step(edge[2], x);
}
/*!
* @brief vector reduction by summation
* @warning could overflow