reflect missing stuff

This commit is contained in:
Recep Aslantas
2024-03-21 02:21:07 +03:00
parent 8c81443f24
commit 8ea2fd1cd1
10 changed files with 85 additions and 0 deletions

View File

@@ -197,6 +197,10 @@ CGLM_EXPORT
void void
glmc_vec2_make(const float * __restrict src, vec2 dest); glmc_vec2_make(const float * __restrict src, vec2 dest);
CGLM_EXPORT
void
glmc_vec2_reflect(vec2 I, vec2 N, vec2 dest);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -334,6 +334,10 @@ CGLM_EXPORT
void void
glmc_vec3_make(const float * __restrict src, vec3 dest); glmc_vec3_make(const float * __restrict src, vec3 dest);
CGLM_EXPORT
void
glmc_vec3_reflect(vec3 I, vec3 N, vec3 dest);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -311,6 +311,10 @@ CGLM_EXPORT
void void
glmc_vec4_make(const float * __restrict src, vec4 dest); glmc_vec4_make(const float * __restrict src, vec4 dest);
CGLM_EXPORT
void
glmc_vec4_reflect(vec4 I, vec4 N, vec4 dest);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -54,6 +54,7 @@
CGLM_INLINE vec2s glms_vec2_clamp(vec2s v, float minVal, float maxVal) 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_lerp(vec2s from, vec2s to, float t)
CGLM_INLINE vec2s glms_vec2_make(float * restrict src) CGLM_INLINE vec2s glms_vec2_make(float * restrict src)
CGLM_INLINE vec2s glms_vec2_reflect(vec2s I, vec2s N)
*/ */
#ifndef cglms_vec2s_h #ifndef cglms_vec2s_h
@@ -691,4 +692,19 @@ glms_vec2_(make)(const float * __restrict src) {
return dest; return dest;
} }
/*!
* @brief reflection vector using an incident ray and a surface normal
*
* @param[in] I incident vector
* @param[in] N normalized normal vector
* @returns reflection result
*/
CGLM_INLINE
vec2s
glms_vec2_(reflect)(vec2s I, vec2s N) {
vec2s dest;
glm_vec2_reflect(I.raw, N.raw, dest.raw);
return dest;
}
#endif /* cglms_vec2s_h */ #endif /* cglms_vec2s_h */

View File

@@ -76,6 +76,7 @@
CGLM_INLINE vec3s glms_vec3_smoothinterpc(vec3s from, vec3s to, float t); CGLM_INLINE vec3s glms_vec3_smoothinterpc(vec3s from, vec3s to, float t);
CGLM_INLINE vec3s glms_vec3_swizzle(vec3s v, int mask); CGLM_INLINE vec3s glms_vec3_swizzle(vec3s v, int mask);
CGLM_INLINE vec3s glms_vec3_make(float * restrict src); CGLM_INLINE vec3s glms_vec3_make(float * restrict src);
CGLM_INLINE vec3s glms_vec3_reflect(vec3s I, vec3s N);
Convenient: Convenient:
CGLM_INLINE vec3s glms_cross(vec3s a, vec3s b); CGLM_INLINE vec3s glms_cross(vec3s a, vec3s b);
@@ -1083,4 +1084,19 @@ glms_vec3_(make)(const float * __restrict src) {
return dest; return dest;
} }
/*!
* @brief reflection vector using an incident ray and a surface normal
*
* @param[in] I incident vector
* @param[in] N normalized normal vector
* @returns reflection result
*/
CGLM_INLINE
vec3s
glms_vec3_(reflect)(vec3s I, vec3s N) {
vec3s dest;
glm_vec3_reflect(I.raw, N.raw, dest.raw);
return dest;
}
#endif /* cglms_vec3s_h */ #endif /* cglms_vec3s_h */

View File

@@ -67,6 +67,7 @@
CGLM_INLINE vec4s glms_vec4_cubic(float s); CGLM_INLINE vec4s glms_vec4_cubic(float s);
CGLM_INLINE vec4s glms_vec4_swizzle(vec4s v, int mask); CGLM_INLINE vec4s glms_vec4_swizzle(vec4s v, int mask);
CGLM_INLINE vec4s glms_vec4_make(float * restrict src); CGLM_INLINE vec4s glms_vec4_make(float * restrict src);
CGLM_INLINE vec4s glms_vec4_reflect(vec4s I, vec4s N);
*/ */
#ifndef cglms_vec4s_h #ifndef cglms_vec4s_h
@@ -927,4 +928,19 @@ glms_vec4_(make)(const float * __restrict src) {
return dest; return dest;
} }
/*!
* @brief reflection vector using an incident ray and a surface normal
*
* @param[in] I incident vector
* @param[in] N normalized normal vector
* @returns reflection result
*/
CGLM_INLINE
vec4s
glms_vec4_(reflect)(vec4s I, vec4s N) {
vec4s dest;
glm_vec4_reflect(I.raw, N.raw, dest.raw);
return dest;
}
#endif /* cglms_vec4s_h */ #endif /* cglms_vec4s_h */

View File

@@ -81,6 +81,7 @@
CGLM_INLINE void glm_vec3_swizzle(vec3 v, int mask, vec3 dest); CGLM_INLINE void glm_vec3_swizzle(vec3 v, int mask, vec3 dest);
CGLM_INLINE void glm_vec3_make(float * restrict src, vec3 dest); CGLM_INLINE void glm_vec3_make(float * restrict src, vec3 dest);
CGLM_INLINE void glm_vec3_reflect(vec3 I, vec3 N, vec3 dest); CGLM_INLINE void glm_vec3_reflect(vec3 I, vec3 N, vec3 dest);
CGLM_INLINE void glm_vec3_refract(vec3 I, vec3 N, float ior, vec3 dest);
Convenient: Convenient:
CGLM_INLINE void glm_cross(vec3 a, vec3 b, vec3 d); CGLM_INLINE void glm_cross(vec3 a, vec3 b, vec3 d);

View File

@@ -302,3 +302,9 @@ void
glmc_vec2_make(const float * __restrict src, vec2 dest) { glmc_vec2_make(const float * __restrict src, vec2 dest) {
glm_vec2_make(src, dest); glm_vec2_make(src, dest);
} }
CGLM_EXPORT
void
glmc_vec2_reflect(vec2 I, vec2 N, vec2 dest) {
glm_vec2_reflect(I, N, dest);
}

View File

@@ -459,3 +459,15 @@ void
glmc_vec3_make(const float * __restrict src, vec3 dest) { glmc_vec3_make(const float * __restrict src, vec3 dest) {
glm_vec3_make(src, dest); glm_vec3_make(src, dest);
} }
CGLM_EXPORT
void
glmc_vec3_reflect(vec3 I, vec3 N, vec3 dest) {
glm_vec3_reflect(I, N, dest);
}
CGLM_EXPORT
void
glmc_vec3_faceforward(vec3 N, vec3 I, vec3 Nref, vec3 dest) {
glm_vec3_faceforward(N, I, Nref, dest);
}

View File

@@ -423,3 +423,9 @@ void
glmc_vec4_make(const float * __restrict src, vec4 dest) { glmc_vec4_make(const float * __restrict src, vec4 dest) {
glm_vec4_make(src, dest); glm_vec4_make(src, dest);
} }
CGLM_EXPORT
void
glmc_vec4_reflect(vec4 I, vec4 N, vec4 dest) {
glm_vec4_reflect(I, N, dest);
}