dont use I macro defined in standard

This commit is contained in:
Recep Aslantas
2024-03-31 04:22:42 +03:00
parent edfb5e3984
commit 4c872238d9
15 changed files with 115 additions and 115 deletions

View File

@@ -397,16 +397,16 @@ Functions documentation
| *[in]* **src** pointer to an array of floats | *[in]* **src** pointer to an array of floats
| *[out]* **dest** destination vector | *[out]* **dest** destination vector
.. c:function:: void glm_vec2_reflect(vec2 I, vec2 N, vec2 dest) .. c:function:: void glm_vec2_reflect(vec2 v, vec2 n, vec2 dest)
Reflection vector using an incident ray and a surface normal Reflection vector using an incident ray and a surface normal
Parameters: Parameters:
| *[in]* **I** incident vector | *[in]* **v** incident vector
| *[in]* **N** *❗️ normalized ❗️* normal vector | *[in]* **n** *❗️ normalized ❗️* normal vector
| *[out]* **dest** destination: reflection result | *[out]* **dest** destination: reflection result
.. c:function:: bool glm_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest) .. c:function:: bool glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest)
Computes refraction vector for an incident vector and a surface normal. Computes refraction vector for an incident vector and a surface normal.
@@ -415,8 +415,8 @@ Functions documentation
Otherwise, computes refraction vector, stores it in dest, and returns true. Otherwise, computes refraction vector, stores it in dest, and returns true.
Parameters: Parameters:
| *[in]* **I** *❗️ normalized ❗️* incident vector | *[in]* **v** *❗️ normalized ❗️* incident vector
| *[in]* **N** *❗️ normalized ❗️* normal vector | *[in]* **n** *❗️ normalized ❗️* normal vector
| *[in]* **eta** ratio of indices of refraction (incident/transmitted) | *[in]* **eta** ratio of indices of refraction (incident/transmitted)
| *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise | *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise

View File

@@ -516,26 +516,26 @@ Functions documentation
| *[in]* **src** pointer to an array of floats | *[in]* **src** pointer to an array of floats
| *[out]* **dest** destination vector | *[out]* **dest** destination vector
.. c:function:: void glm_vec3_faceforward(vec3 N, vec3 I, vec3 Nref, vec3 dest) .. c:function:: void glm_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest)
A vector pointing in the same direction as another A vector pointing in the same direction as another
Parameters: Parameters:
| *[in]* **N** vector to orient | *[in]* **n** vector to orient
| *[in]* **I** incident vector | *[in]* **v** incident vector
| *[in]* **Nref** reference vector | *[in]* **nref** reference vector
| *[out]* **dest** destination: oriented vector, pointing away from the surface. | *[out]* **dest** destination: oriented vector, pointing away from the surface.
.. c:function:: void glm_vec3_reflect(vec3 I, vec3 N, vec3 dest) .. c:function:: void glm_vec3_reflect(vec3 v, vec3 n, vec3 dest)
Reflection vector using an incident ray and a surface normal Reflection vector using an incident ray and a surface normal
Parameters: Parameters:
| *[in]* **I** incident vector | *[in]* **v** incident vector
| *[in]* **N** *❗️ normalized ❗️* normal vector | *[in]* **n** *❗️ normalized ❗️* normal vector
| *[out]* **dest** destination: reflection result | *[out]* **dest** destination: reflection result
.. c:function:: bool glm_vec3_refract(vec3 I, vec3 N, float eta, vec3 dest) .. c:function:: bool glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest)
Computes refraction vector for an incident vector and a surface normal. Computes refraction vector for an incident vector and a surface normal.
@@ -545,10 +545,10 @@ Functions documentation
Otherwise, computes refraction vector, stores it in dest, and returns true. Otherwise, computes refraction vector, stores it in dest, and returns true.
Parameters: Parameters:
| *[in]* **I** *❗️ normalized ❗️* incident vector | *[in]* **v** *❗️ normalized ❗️* incident vector
| *[in]* **N** *❗️ normalized ❗️* normal vector | *[in]* **n** *❗️ normalized ❗️* normal vector
| *[in]* **eta** ratio of indices of refraction (incident/transmitted) | *[in]* **eta** ratio of indices of refraction (incident/transmitted)
| *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise | *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise
Returns: Returns:
returns true if refraction occurs; false if total internal reflection occurs. returns true if refraction occurs; false if total internal reflection occurs.

View File

@@ -427,16 +427,16 @@ Functions documentation
| *[in]* **src** pointer to an array of floats | *[in]* **src** pointer to an array of floats
| *[out]* **dest** destination vector | *[out]* **dest** destination vector
.. c:function:: bool glm_vec4_reflect(vec4 I, vec4 N, vec4 dest) .. c:function:: bool glm_vec4_reflect(vec4 v, vec4 n, vec4 dest)
Reflection vector using an incident ray and a surface normal Reflection vector using an incident ray and a surface normal
Parameters: Parameters:
| *[in]* **I** incident vector | *[in]* **v** incident vector
| *[in]* **N** *❗️ normalized ❗️* normal vector | *[in]* **n** *❗️ normalized ❗️* normal vector
| *[out]* **dest** destination: reflection result | *[out]* **dest** destination: reflection result
.. c:function:: bool glm_vec4_refract(vec4 I, vec4 N, float eta, vec4 dest) .. c:function:: bool glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest)
computes refraction vector for an incident vector and a surface normal. computes refraction vector for an incident vector and a surface normal.
@@ -449,10 +449,10 @@ Functions documentation
the 'w' component should manually adjust 'dest' after calling this function. the 'w' component should manually adjust 'dest' after calling this function.
Parameters: Parameters:
| *[in]* **I** *❗️ normalized ❗️* incident vector | *[in]* **v** *❗️ normalized ❗️* incident vector
| *[in]* **N** *❗️ normalized ❗️* normal vector | *[in]* **n** *❗️ normalized ❗️* normal vector
| *[in]* **eta** ratio of indices of refraction (incident/transmitted) | *[in]* **eta** ratio of indices of refraction (incident/transmitted)
| *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise | *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise
Returns: Returns:
returns true if refraction occurs; false if total internal reflection occurs. returns true if refraction occurs; false if total internal reflection occurs.

View File

@@ -199,11 +199,11 @@ glmc_vec2_make(const float * __restrict src, vec2 dest);
CGLM_EXPORT CGLM_EXPORT
void void
glmc_vec2_reflect(vec2 I, vec2 N, vec2 dest); glmc_vec2_reflect(vec2 v, vec2 n, vec2 dest);
CGLM_EXPORT CGLM_EXPORT
bool bool
glmc_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest); glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -336,15 +336,15 @@ glmc_vec3_make(const float * __restrict src, vec3 dest);
CGLM_EXPORT CGLM_EXPORT
void void
glmc_vec3_faceforward(vec3 N, vec3 I, vec3 Nref, vec3 dest); glmc_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest);
CGLM_EXPORT CGLM_EXPORT
void void
glmc_vec3_reflect(vec3 I, vec3 N, vec3 dest); glmc_vec3_reflect(vec3 v, vec3 n, vec3 dest);
CGLM_EXPORT CGLM_EXPORT
bool bool
glmc_vec3_refract(vec3 I, vec3 N, float eta, vec3 dest); glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -313,11 +313,11 @@ glmc_vec4_make(const float * __restrict src, vec4 dest);
CGLM_EXPORT CGLM_EXPORT
void void
glmc_vec4_reflect(vec4 I, vec4 N, vec4 dest); glmc_vec4_reflect(vec4 v, vec4 n, vec4 dest);
CGLM_EXPORT CGLM_EXPORT
bool bool
glmc_vec4_refract(vec4 I, vec4 N, float eta, vec4 dest); glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -54,8 +54,8 @@
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) CGLM_INLINE vec2s glms_vec2_reflect(vec2s v, vec2s n)
CGLM_INLINE bool glms_vec2_refract(vec2s I, vec2s N, float eta, vec2s *dest) CGLM_INLINE bool glms_vec2_refract(vec2s v, vec2s n, float eta, vec2s *dest)
*/ */
#ifndef cglms_vec2s_h #ifndef cglms_vec2s_h
@@ -702,9 +702,9 @@ glms_vec2_(make)(const float * __restrict src) {
*/ */
CGLM_INLINE CGLM_INLINE
vec2s vec2s
glms_vec2_(reflect)(vec2s I, vec2s N) { glms_vec2_(reflect)(vec2s v, vec2s n) {
vec2s dest; vec2s dest;
glm_vec2_reflect(I.raw, N.raw, dest.raw); glm_vec2_reflect(v.raw, n.raw, dest.raw);
return dest; return dest;
} }
@@ -715,8 +715,8 @@ glms_vec2_(reflect)(vec2s I, vec2s N) {
* occurs (angle too great given eta), dest is set to zero and returns false. * occurs (angle too great given eta), dest is set to zero and returns false.
* Otherwise, computes refraction vector, stores it in dest, and returns true. * Otherwise, computes refraction vector, stores it in dest, and returns true.
* *
* @param[in] I normalized incident vector * @param[in] v normalized incident vector
* @param[in] N normalized normal vector * @param[in] n normalized normal vector
* @param[in] eta ratio of indices of refraction (incident/transmitted) * @param[in] eta ratio of indices of refraction (incident/transmitted)
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise * @param[out] dest refraction vector if refraction occurs; zero vector otherwise
* *
@@ -724,8 +724,8 @@ glms_vec2_(reflect)(vec2s I, vec2s N) {
*/ */
CGLM_INLINE CGLM_INLINE
bool bool
glms_vec2_(refract)(vec2s I, vec2s N, float eta, vec2s * __restrict dest) { glms_vec2_(refract)(vec2s v, vec2s n, float eta, vec2s * __restrict dest) {
return glm_vec2_refract(I.raw, N.raw, eta, dest->raw); return glm_vec2_refract(v.raw, n.raw, eta, dest->raw);
} }
#endif /* cglms_vec2s_h */ #endif /* cglms_vec2s_h */

View File

@@ -76,9 +76,9 @@
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_faceforward(vec3s N, vec3s I, vec3s Nref); CGLM_INLINE vec3s glms_vec3_faceforward(vec3s n, vec3s v, vec3s nref);
CGLM_INLINE vec3s glms_vec3_reflect(vec3s I, vec3s N); CGLM_INLINE vec3s glms_vec3_reflect(vec3s v, vec3s n);
CGLM_INLINE bool glms_vec3_refract(vec3s I, vec3s N, float eta, vec3s *dest) CGLM_INLINE bool glms_vec3_refract(vec3s v, vec3s n, float eta, vec3s *dest)
Convenient: Convenient:
CGLM_INLINE vec3s glms_cross(vec3s a, vec3s b); CGLM_INLINE vec3s glms_cross(vec3s a, vec3s b);
@@ -1113,9 +1113,9 @@ glms_vec3_(faceforward)(vec3s N, vec3s I, vec3s Nref) {
*/ */
CGLM_INLINE CGLM_INLINE
vec3s vec3s
glms_vec3_(reflect)(vec3s I, vec3s N) { glms_vec3_(reflect)(vec3s v, vec3s n) {
vec3s dest; vec3s dest;
glm_vec3_reflect(I.raw, N.raw, dest.raw); glm_vec3_reflect(v.raw, n.raw, dest.raw);
return dest; return dest;
} }

View File

@@ -67,8 +67,8 @@
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); CGLM_INLINE vec4s glms_vec4_reflect(vec4s v, vec4s n);
CGLM_INLINE bool glms_vec4_refract(vec4s I, vec4s N, float eta, vec4s *dest) CGLM_INLINE bool glms_vec4_refract(vec4s v, vec4s n, float eta, vec4s *dest)
*/ */
#ifndef cglms_vec4s_h #ifndef cglms_vec4s_h
@@ -932,15 +932,15 @@ glms_vec4_(make)(const float * __restrict src) {
/*! /*!
* @brief reflection vector using an incident ray and a surface normal * @brief reflection vector using an incident ray and a surface normal
* *
* @param[in] I incident vector * @param[in] v incident vector
* @param[in] N normalized normal vector * @param[in] n normalized normal vector
* @returns reflection result * @returns reflection result
*/ */
CGLM_INLINE CGLM_INLINE
vec4s vec4s
glms_vec4_(reflect)(vec4s I, vec4s N) { glms_vec4_(reflect)(vec4s v, vec4s n) {
vec4s dest; vec4s dest;
glm_vec4_reflect(I.raw, N.raw, dest.raw); glm_vec4_reflect(v.raw, n.raw, dest.raw);
return dest; return dest;
} }
@@ -955,8 +955,8 @@ glms_vec4_(reflect)(vec4s I, vec4s N) {
* incident vector 'I' in the output 'dest', users requiring the preservation of * incident vector 'I' in the output 'dest', users requiring the preservation of
* the 'w' component should manually adjust 'dest' after calling this function. * the 'w' component should manually adjust 'dest' after calling this function.
* *
* @param[in] I normalized incident vector * @param[in] v normalized incident vector
* @param[in] N normalized normal vector * @param[in] n normalized normal vector
* @param[in] eta ratio of indices of refraction (incident/transmitted) * @param[in] eta ratio of indices of refraction (incident/transmitted)
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise * @param[out] dest refraction vector if refraction occurs; zero vector otherwise
* *
@@ -964,8 +964,8 @@ glms_vec4_(reflect)(vec4s I, vec4s N) {
*/ */
CGLM_INLINE CGLM_INLINE
bool bool
glms_vec4_(refract)(vec4s I, vec4s N, float eta, vec4s * __restrict dest) { glms_vec4_(refract)(vec4s v, vec4s n, float eta, vec4s * __restrict dest) {
return glm_vec4_refract(I.raw, N.raw, eta, dest->raw); return glm_vec4_refract(v.raw, n.raw, eta, dest->raw);
} }
#endif /* cglms_vec4s_h */ #endif /* cglms_vec4s_h */

View File

@@ -55,8 +55,8 @@
CGLM_INLINE void glm_vec2_clamp(vec2 v, float minVal, float maxVal) CGLM_INLINE void glm_vec2_clamp(vec2 v, float minVal, float maxVal)
CGLM_INLINE void glm_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest) CGLM_INLINE void glm_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest)
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 I, vec2 N, vec2 dest) CGLM_INLINE void glm_vec2_reflect(vec2 v, vec2 n, vec2 dest)
CGLM_INLINE void glm_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest) CGLM_INLINE void glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest)
*/ */
#ifndef cglm_vec2_h #ifndef cglm_vec2_h
@@ -716,16 +716,16 @@ glm_vec2_make(const float * __restrict src, vec2 dest) {
/*! /*!
* @brief reflection vector using an incident ray and a surface normal * @brief reflection vector using an incident ray and a surface normal
* *
* @param[in] I incident vector * @param[in] v incident vector
* @param[in] N normalized normal vector * @param[in] n normalized normal vector
* @param[out] dest destination vector for the reflection result * @param[out] dest destination vector for the reflection result
*/ */
CGLM_INLINE CGLM_INLINE
void void
glm_vec2_reflect(vec2 I, vec2 N, vec2 dest) { glm_vec2_reflect(vec2 v, vec2 n, vec2 dest) {
vec2 temp; vec2 temp;
glm_vec2_scale(N, 2.0f * glm_vec2_dot(I, N), temp); glm_vec2_scale(n, 2.0f * glm_vec2_dot(v, n), temp);
glm_vec2_sub(I, temp, dest); glm_vec2_sub(v, temp, dest);
} }
/*! /*!
@@ -735,8 +735,8 @@ glm_vec2_reflect(vec2 I, vec2 N, vec2 dest) {
* occurs (angle too great given eta), dest is set to zero and returns false. * occurs (angle too great given eta), dest is set to zero and returns false.
* Otherwise, computes refraction vector, stores it in dest, and returns true. * Otherwise, computes refraction vector, stores it in dest, and returns true.
* *
* @param[in] I normalized incident vector * @param[in] v normalized incident vector
* @param[in] N normalized normal vector * @param[in] n normalized normal vector
* @param[in] eta ratio of indices of refraction (incident/transmitted) * @param[in] eta ratio of indices of refraction (incident/transmitted)
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise * @param[out] dest refraction vector if refraction occurs; zero vector otherwise
* *
@@ -744,10 +744,10 @@ glm_vec2_reflect(vec2 I, vec2 N, vec2 dest) {
*/ */
CGLM_INLINE CGLM_INLINE
bool bool
glm_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest) { glm_vec2_refract(vec2 v, vec2 v, float eta, vec2 dest) {
float ndi, eni, k; float ndi, eni, k;
ndi = glm_vec2_dot(N, I); ndi = glm_vec2_dot(n, v);
eni = eta * ndi; eni = eta * ndi;
k = 1.0f + eta * eta - eni * eni; k = 1.0f + eta * eta - eni * eni;
@@ -756,8 +756,8 @@ glm_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest) {
return false; return false;
} }
glm_vec2_scale(I, eta, dest); glm_vec2_scale(v, eta, dest);
glm_vec2_mulsubs(N, eni + sqrtf(k), dest); glm_vec2_mulsubs(n, eni + sqrtf(k), dest);
return true; return true;
} }

View File

@@ -80,9 +80,9 @@
CGLM_INLINE void glm_vec3_smoothinterpc(vec3 from, vec3 to, float t, vec3 dest); CGLM_INLINE void glm_vec3_smoothinterpc(vec3 from, vec3 to, float t, vec3 dest);
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_faceforward(vec3 N, vec3 I, 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 I, vec3 N, vec3 dest); CGLM_INLINE void glm_vec3_reflect(vec3 v, vec3 n, vec3 dest);
CGLM_INLINE void glm_vec3_refract(vec3 I, vec3 N, float eta, vec3 dest); CGLM_INLINE void glm_vec3_refract(vec3 v, vec3 n, float eta, 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);
@@ -1210,36 +1210,36 @@ glm_vec3_make(const float * __restrict src, vec3 dest) {
* *
* orients a vector to point away from a surface as defined by its normal * orients a vector to point away from a surface as defined by its normal
* *
* @param[in] N vector to orient * @param[in] n vector to orient
* @param[in] I incident vector * @param[in] v incident vector
* @param[in] Nref reference vector * @param[in] nref reference vector
* @param[out] dest oriented vector, pointing away from the surface * @param[out] dest oriented vector, pointing away from the surface
*/ */
CGLM_INLINE CGLM_INLINE
void void
glm_vec3_faceforward(vec3 N, vec3 I, vec3 Nref, vec3 dest) { glm_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest) {
if (glm_vec3_dot(I, Nref) < 0.0f) { if (glm_vec3_dot(v, nref) < 0.0f) {
/* N is facing away from I */ /* N is facing away from I */
glm_vec3_copy(N, dest); glm_vec3_copy(n, dest);
} else { } else {
/* N is facing towards I, negate it */ /* N is facing towards I, negate it */
glm_vec3_negate_to(N, dest); glm_vec3_negate_to(n, dest);
} }
} }
/*! /*!
* @brief reflection vector using an incident ray and a surface normal * @brief reflection vector using an incident ray and a surface normal
* *
* @param[in] I incident vector * @param[in] v incident vector
* @param[in] N normalized normal vector * @param[in] n normalized normal vector
* @param[out] dest reflection result * @param[out] dest reflection result
*/ */
CGLM_INLINE CGLM_INLINE
void void
glm_vec3_reflect(vec3 I, vec3 N, vec3 dest) { glm_vec3_reflect(vec3 v, vec3 n, vec3 dest) {
vec3 temp; vec3 temp;
glm_vec3_scale(N, 2.0f * glm_vec3_dot(I, N), temp); glm_vec3_scale(n, 2.0f * glm_vec3_dot(v, n), temp);
glm_vec3_sub(I, temp, dest); glm_vec3_sub(v, temp, dest);
} }
/*! /*!
@@ -1249,8 +1249,8 @@ glm_vec3_reflect(vec3 I, vec3 N, vec3 dest) {
* occurs (angle too great given eta), dest is set to zero and returns false. * occurs (angle too great given eta), dest is set to zero and returns false.
* Otherwise, computes refraction vector, stores it in dest, and returns true. * Otherwise, computes refraction vector, stores it in dest, and returns true.
* *
* @param[in] I normalized incident vector * @param[in] v normalized incident vector
* @param[in] N normalized normal vector * @param[in] n normalized normal vector
* @param[in] eta ratio of indices of refraction (incident/transmitted) * @param[in] eta ratio of indices of refraction (incident/transmitted)
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise * @param[out] dest refraction vector if refraction occurs; zero vector otherwise
* *
@@ -1258,10 +1258,10 @@ glm_vec3_reflect(vec3 I, vec3 N, vec3 dest) {
*/ */
CGLM_INLINE CGLM_INLINE
bool bool
glm_vec3_refract(vec3 I, vec3 N, float eta, vec3 dest) { glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) {
float ndi, eni, k; float ndi, eni, k;
ndi = glm_vec3_dot(N, I); ndi = glm_vec3_dot(n, v);
eni = eta * ndi; eni = eta * ndi;
k = 1.0f + eta * eta - eni * eni; k = 1.0f + eta * eta - eni * eni;
@@ -1270,8 +1270,8 @@ glm_vec3_refract(vec3 I, vec3 N, float eta, vec3 dest) {
return false; return false;
} }
glm_vec3_scale(I, eta, dest); glm_vec3_scale(v, eta, dest);
glm_vec3_mulsubs(N, eni + sqrtf(k), dest); glm_vec3_mulsubs(n, eni + sqrtf(k), dest);
return true; return true;
} }

View File

@@ -65,8 +65,8 @@
CGLM_INLINE void glm_vec4_smoothinterpc(vec4 from, vec4 to, float t, vec4 dest); CGLM_INLINE void glm_vec4_smoothinterpc(vec4 from, vec4 to, float t, vec4 dest);
CGLM_INLINE void glm_vec4_swizzle(vec4 v, int mask, vec4 dest); CGLM_INLINE void glm_vec4_swizzle(vec4 v, int mask, vec4 dest);
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 I, vec4 N, vec4 dest); CGLM_INLINE void glm_vec4_reflect(vec4 v, vec4 n, vec4 dest);
CGLM_INLINE void glm_vec4_refract(vec4 I, vec4 N, float eta, vec4 dest); CGLM_INLINE void glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest);
DEPRECATED: DEPRECATED:
glm_vec4_dup glm_vec4_dup
@@ -1309,20 +1309,20 @@ glm_vec4_make(const float * __restrict src, vec4 dest) {
/*! /*!
* @brief reflection vector using an incident ray and a surface normal * @brief reflection vector using an incident ray and a surface normal
* *
* @param[in] I incident vector * @param[in] v incident vector
* @param[in] N normalized normal vector * @param[in] n normalized normal vector
* @param[out] dest destination vector for the reflection result * @param[out] dest destination vector for the reflection result
*/ */
CGLM_INLINE CGLM_INLINE
void void
glm_vec4_reflect(vec4 I, vec4 N, vec4 dest) { glm_vec4_reflect(vec4 v, vec4 n, vec4 dest) {
vec4 temp; vec4 temp;
/* TODO: direct simd touch */ /* TODO: direct simd touch */
glm_vec4_scale(N, 2.0f * glm_vec4_dot(I, N), temp); glm_vec4_scale(n, 2.0f * glm_vec4_dot(v, n), temp);
glm_vec4_sub(I, temp, dest); glm_vec4_sub(v, temp, dest);
dest[3] = I[3]; dest[3] = v[3];
} }
/*! /*!
@@ -1336,8 +1336,8 @@ glm_vec4_reflect(vec4 I, vec4 N, vec4 dest) {
* incident vector 'I' in the output 'dest', users requiring the preservation of * incident vector 'I' in the output 'dest', users requiring the preservation of
* the 'w' component should manually adjust 'dest' after calling this function. * the 'w' component should manually adjust 'dest' after calling this function.
* *
* @param[in] I normalized incident vector * @param[in] v normalized incident vector
* @param[in] N normalized normal vector * @param[in] n normalized normal vector
* @param[in] eta ratio of indices of refraction (incident/transmitted) * @param[in] eta ratio of indices of refraction (incident/transmitted)
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise * @param[out] dest refraction vector if refraction occurs; zero vector otherwise
* *
@@ -1345,10 +1345,10 @@ glm_vec4_reflect(vec4 I, vec4 N, vec4 dest) {
*/ */
CGLM_INLINE CGLM_INLINE
bool bool
glm_vec4_refract(vec4 I, vec4 N, float eta, vec4 dest) { glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) {
float ndi, eni, k; float ndi, eni, k;
ndi = glm_vec4_dot(N, I); ndi = glm_vec4_dot(n, v);
eni = eta * ndi; eni = eta * ndi;
k = 1.0f + eta * eta - eni * eni; k = 1.0f + eta * eta - eni * eni;
@@ -1357,7 +1357,7 @@ glm_vec4_refract(vec4 I, vec4 N, float eta, vec4 dest) {
return false; return false;
} }
glm_vec4_scale(I, eta, dest); glm_vec4_scale(v, eta, dest);
glm_vec4_mulsubs(N, eni + sqrtf(k), dest); glm_vec4_mulsubs(N, eni + sqrtf(k), dest);
return true; return true;
} }

View File

@@ -305,12 +305,12 @@ glmc_vec2_make(const float * __restrict src, vec2 dest) {
CGLM_EXPORT CGLM_EXPORT
void void
glmc_vec2_reflect(vec2 I, vec2 N, vec2 dest) { glmc_vec2_reflect(vec2 v, vec2 n, vec2 dest) {
glm_vec2_reflect(I, N, dest); glm_vec2_reflect(v, n, dest);
} }
CGLM_EXPORT CGLM_EXPORT
bool bool
glmc_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest) { glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) {
return glm_vec2_refract(I, N, eta, dest); return glm_vec2_refract(v, n, eta, dest);
} }

View File

@@ -462,18 +462,18 @@ glmc_vec3_make(const float * __restrict src, vec3 dest) {
CGLM_EXPORT CGLM_EXPORT
void void
glmc_vec3_faceforward(vec3 N, vec3 I, vec3 Nref, vec3 dest) { glmc_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest) {
glm_vec3_faceforward(N, I, Nref, dest); glm_vec3_faceforward(n, v, nref, dest);
} }
CGLM_EXPORT CGLM_EXPORT
void void
glmc_vec3_reflect(vec3 I, vec3 N, vec3 dest) { glmc_vec3_reflect(vec3 v, vec3 n, vec3 dest) {
glm_vec3_reflect(I, N, dest); glm_vec3_reflect(v, n, dest);
} }
CGLM_EXPORT CGLM_EXPORT
bool bool
glmc_vec3_refract(vec3 I, vec3 N, float eta, vec3 dest) { glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) {
return glm_vec3_refract(I, N, eta, dest); return glm_vec3_refract(v, n, eta, dest);
} }

View File

@@ -426,12 +426,12 @@ glmc_vec4_make(const float * __restrict src, vec4 dest) {
CGLM_EXPORT CGLM_EXPORT
void void
glmc_vec4_reflect(vec4 I, vec4 N, vec4 dest) { glmc_vec4_reflect(vec4 v, vec4 n, vec4 dest) {
glm_vec4_reflect(I, N, dest); glm_vec4_reflect(v, n, dest);
} }
CGLM_EXPORT CGLM_EXPORT
bool bool
glmc_vec4_refract(vec4 I, vec4 N, float eta, vec4 dest) { glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) {
return glm_vec4_refract(I, N, eta, dest); return glm_vec4_refract(v, n, eta, dest);
} }