add glm_vecx_swap functions

This commit is contained in:
tayoky
2025-11-15 10:39:14 +01:00
parent da957fa421
commit 3aad5823ca
9 changed files with 69 additions and 0 deletions

View File

@@ -245,6 +245,10 @@ CGLM_EXPORT
bool
glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest);
CGLM_EXPORT
void
glmc_vec2_swap(vec2 a, vec2 b);
#ifdef __cplusplus
}
#endif

View File

@@ -363,6 +363,10 @@ CGLM_EXPORT
bool
glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest);
CGLM_EXPORT
void
glmc_vec3_swap(vec3 a, vec3 b);
#ifdef __cplusplus
}
#endif

View File

@@ -336,6 +336,10 @@ CGLM_EXPORT
bool
glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest);
CGLM_EXPORT
void
glmc_vec4_swap(vec4 a, vec4 b);
#ifdef __cplusplus
}
#endif

View File

@@ -59,6 +59,7 @@
CGLM_INLINE void glm_vec2_make(float * restrict src, vec2 dest)
CGLM_INLINE void glm_vec2_reflect(vec2 v, vec2 n, vec2 dest)
CGLM_INLINE void glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest)
CGLM_INLINE void glm_vec2_swap(vec2 a, vec2 b)
*/
#ifndef cglm_vec2_h
@@ -795,4 +796,16 @@ glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) {
return true;
}
/*!
* @brief swap two vectors
* @param a the first vector to swap
* @param b the second vector to swap
*/
CGLM_INLINE void glm_vec2_swap(vec2 a, vec2 b) {
vec2 tmp;
glm_vec2_copy(a, tmp);
glm_vec2_copy(b, a);
glm_vec2_copy(tmp, b);
}
#endif /* cglm_vec2_h */

View File

@@ -82,6 +82,7 @@
CGLM_INLINE void glm_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest);
CGLM_INLINE void glm_vec3_reflect(vec3 v, vec3 n, vec3 dest);
CGLM_INLINE void glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest);
CGLM_INLINE void glm_vec3_swap(vec3 a, vec3 b)
Convenient:
CGLM_INLINE void glm_cross(vec3 a, vec3 b, vec3 d);
@@ -1261,4 +1262,16 @@ glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) {
return true;
}
/*!
* @brief swap two vectors
* @param a the first vector to swap
* @param b the second vector to swap
*/
CGLM_INLINE void glm_vec3_swap(vec3 a, vec3 b) {
vec3 tmp;
glm_vec3_copy(a, tmp);
glm_vec3_copy(b, a);
glm_vec3_copy(tmp, b);
}
#endif /* cglm_vec3_h */

View File

@@ -66,6 +66,7 @@
CGLM_INLINE void glm_vec4_make(float * restrict src, vec4 dest);
CGLM_INLINE void glm_vec4_reflect(vec4 v, vec4 n, vec4 dest);
CGLM_INLINE void glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest);
CGLM_INLINE void glm_vec4_swap(vec4 a, vec4 b)
DEPRECATED:
glm_vec4_dup
@@ -1345,4 +1346,16 @@ glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) {
return true;
}
/*!
* @brief swap two vectors
* @param a the first vector to swap
* @param b the second vector to swap
*/
CGLM_INLINE void glm_vec4_swap(vec4 a, vec4 b) {
vec4 tmp;
glm_vec4_copy(a, tmp);
glm_vec4_copy(b, a);
glm_vec4_copy(tmp, b);
}
#endif /* cglm_vec4_h */