Merge pull request #487 from tayoky/master

add glm_vecx_swap functions
This commit is contained in:
Recep Aslantas
2025-11-19 23:44:21 +03:00
committed by GitHub
9 changed files with 69 additions and 0 deletions

View File

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

View File

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

View File

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

View File

@@ -59,6 +59,7 @@
CGLM_INLINE void glm_vec2_make(float * restrict src, vec2 dest) 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_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_refract(vec2 v, vec2 n, float eta, vec2 dest)
CGLM_INLINE void glm_vec2_swap(vec2 a, vec2 b)
*/ */
#ifndef cglm_vec2_h #ifndef cglm_vec2_h
@@ -795,4 +796,16 @@ glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) {
return true; 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 */ #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_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_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_refract(vec3 v, vec3 n, float eta, vec3 dest);
CGLM_INLINE void glm_vec3_swap(vec3 a, vec3 b)
Convenient: Convenient:
CGLM_INLINE void glm_cross(vec3 a, vec3 b, vec3 d); 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; 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 */ #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_make(float * restrict src, vec4 dest);
CGLM_INLINE void glm_vec4_reflect(vec4 v, vec4 n, 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_refract(vec4 v, vec4 n, float eta, vec4 dest);
CGLM_INLINE void glm_vec4_swap(vec4 a, vec4 b)
DEPRECATED: DEPRECATED:
glm_vec4_dup glm_vec4_dup
@@ -1345,4 +1346,16 @@ glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) {
return true; 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 */ #endif /* cglm_vec4_h */

View File

@@ -356,3 +356,9 @@ bool
glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) { glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) {
return glm_vec2_refract(v, n, eta, dest); return glm_vec2_refract(v, n, eta, dest);
} }
CGLM_EXPORT
void
glmc_vec2_swap(vec2 a, vec2 b) {
glm_vec2_swap(a, b);
}

View File

@@ -501,3 +501,9 @@ bool
glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) { glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) {
return glm_vec3_refract(v, n, eta, dest); return glm_vec3_refract(v, n, eta, dest);
} }
CGLM_EXPORT
void
glmc_vec3_swap(vec3 a, vec3 b) {
glm_vec3_swap(a, b);
}

View File

@@ -459,3 +459,9 @@ bool
glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) { glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) {
return glm_vec4_refract(v, n, eta, dest); return glm_vec4_refract(v, n, eta, dest);
} }
CGLM_EXPORT
void
glmc_vec4_swap(vec4 a, vec4 b) {
glm_vec4_swap(a, b);
}