mirror of
https://github.com/recp/cglm.git
synced 2025-10-04 01:00:46 +00:00
dont use I macro defined in standard
This commit is contained in:
@@ -199,11 +199,11 @@ glmc_vec2_make(const float * __restrict src, vec2 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_vec2_reflect(vec2 I, vec2 N, vec2 dest);
|
||||
glmc_vec2_reflect(vec2 v, vec2 n, vec2 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
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
|
||||
}
|
||||
|
@@ -336,15 +336,15 @@ glmc_vec3_make(const float * __restrict src, vec3 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
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
|
||||
void
|
||||
glmc_vec3_reflect(vec3 I, vec3 N, vec3 dest);
|
||||
glmc_vec3_reflect(vec3 v, vec3 n, vec3 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
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
|
||||
}
|
||||
|
@@ -313,11 +313,11 @@ glmc_vec4_make(const float * __restrict src, vec4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_vec4_reflect(vec4 I, vec4 N, vec4 dest);
|
||||
glmc_vec4_reflect(vec4 v, vec4 n, vec4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
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
|
||||
}
|
||||
|
@@ -54,8 +54,8 @@
|
||||
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_make(float * restrict src)
|
||||
CGLM_INLINE vec2s glms_vec2_reflect(vec2s I, vec2s N)
|
||||
CGLM_INLINE bool glms_vec2_refract(vec2s I, vec2s N, float eta, vec2s *dest)
|
||||
CGLM_INLINE vec2s glms_vec2_reflect(vec2s v, vec2s n)
|
||||
CGLM_INLINE bool glms_vec2_refract(vec2s v, vec2s n, float eta, vec2s *dest)
|
||||
*/
|
||||
|
||||
#ifndef cglms_vec2s_h
|
||||
@@ -702,9 +702,9 @@ glms_vec2_(make)(const float * __restrict src) {
|
||||
*/
|
||||
CGLM_INLINE
|
||||
vec2s
|
||||
glms_vec2_(reflect)(vec2s I, vec2s N) {
|
||||
glms_vec2_(reflect)(vec2s v, vec2s n) {
|
||||
vec2s dest;
|
||||
glm_vec2_reflect(I.raw, N.raw, dest.raw);
|
||||
glm_vec2_reflect(v.raw, n.raw, dest.raw);
|
||||
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.
|
||||
* Otherwise, computes refraction vector, stores it in dest, and returns true.
|
||||
*
|
||||
* @param[in] I normalized incident vector
|
||||
* @param[in] N normalized normal vector
|
||||
* @param[in] v normalized incident vector
|
||||
* @param[in] n normalized normal vector
|
||||
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
||||
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
||||
*
|
||||
@@ -724,8 +724,8 @@ glms_vec2_(reflect)(vec2s I, vec2s N) {
|
||||
*/
|
||||
CGLM_INLINE
|
||||
bool
|
||||
glms_vec2_(refract)(vec2s I, vec2s N, float eta, vec2s * __restrict dest) {
|
||||
return glm_vec2_refract(I.raw, N.raw, eta, dest->raw);
|
||||
glms_vec2_(refract)(vec2s v, vec2s n, float eta, vec2s * __restrict dest) {
|
||||
return glm_vec2_refract(v.raw, n.raw, eta, dest->raw);
|
||||
}
|
||||
|
||||
#endif /* cglms_vec2s_h */
|
||||
|
@@ -76,9 +76,9 @@
|
||||
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_make(float * restrict src);
|
||||
CGLM_INLINE vec3s glms_vec3_faceforward(vec3s N, vec3s I, vec3s Nref);
|
||||
CGLM_INLINE vec3s glms_vec3_reflect(vec3s I, vec3s N);
|
||||
CGLM_INLINE bool glms_vec3_refract(vec3s I, vec3s N, float eta, vec3s *dest)
|
||||
CGLM_INLINE vec3s glms_vec3_faceforward(vec3s n, vec3s v, vec3s nref);
|
||||
CGLM_INLINE vec3s glms_vec3_reflect(vec3s v, vec3s n);
|
||||
CGLM_INLINE bool glms_vec3_refract(vec3s v, vec3s n, float eta, vec3s *dest)
|
||||
|
||||
Convenient:
|
||||
CGLM_INLINE vec3s glms_cross(vec3s a, vec3s b);
|
||||
@@ -1113,9 +1113,9 @@ glms_vec3_(faceforward)(vec3s N, vec3s I, vec3s Nref) {
|
||||
*/
|
||||
CGLM_INLINE
|
||||
vec3s
|
||||
glms_vec3_(reflect)(vec3s I, vec3s N) {
|
||||
glms_vec3_(reflect)(vec3s v, vec3s n) {
|
||||
vec3s dest;
|
||||
glm_vec3_reflect(I.raw, N.raw, dest.raw);
|
||||
glm_vec3_reflect(v.raw, n.raw, dest.raw);
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
@@ -67,8 +67,8 @@
|
||||
CGLM_INLINE vec4s glms_vec4_cubic(float s);
|
||||
CGLM_INLINE vec4s glms_vec4_swizzle(vec4s v, int mask);
|
||||
CGLM_INLINE vec4s glms_vec4_make(float * restrict src);
|
||||
CGLM_INLINE vec4s glms_vec4_reflect(vec4s I, vec4s N);
|
||||
CGLM_INLINE bool glms_vec4_refract(vec4s I, vec4s N, float eta, vec4s *dest)
|
||||
CGLM_INLINE vec4s glms_vec4_reflect(vec4s v, vec4s n);
|
||||
CGLM_INLINE bool glms_vec4_refract(vec4s v, vec4s n, float eta, vec4s *dest)
|
||||
*/
|
||||
|
||||
#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
|
||||
*
|
||||
* @param[in] I incident vector
|
||||
* @param[in] N normalized normal vector
|
||||
* @param[in] v incident vector
|
||||
* @param[in] n normalized normal vector
|
||||
* @returns reflection result
|
||||
*/
|
||||
CGLM_INLINE
|
||||
vec4s
|
||||
glms_vec4_(reflect)(vec4s I, vec4s N) {
|
||||
glms_vec4_(reflect)(vec4s v, vec4s n) {
|
||||
vec4s dest;
|
||||
glm_vec4_reflect(I.raw, N.raw, dest.raw);
|
||||
glm_vec4_reflect(v.raw, n.raw, dest.raw);
|
||||
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
|
||||
* the 'w' component should manually adjust 'dest' after calling this function.
|
||||
*
|
||||
* @param[in] I normalized incident vector
|
||||
* @param[in] N normalized normal vector
|
||||
* @param[in] v normalized incident vector
|
||||
* @param[in] n normalized normal vector
|
||||
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
||||
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
||||
*
|
||||
@@ -964,8 +964,8 @@ glms_vec4_(reflect)(vec4s I, vec4s N) {
|
||||
*/
|
||||
CGLM_INLINE
|
||||
bool
|
||||
glms_vec4_(refract)(vec4s I, vec4s N, float eta, vec4s * __restrict dest) {
|
||||
return glm_vec4_refract(I.raw, N.raw, eta, dest->raw);
|
||||
glms_vec4_(refract)(vec4s v, vec4s n, float eta, vec4s * __restrict dest) {
|
||||
return glm_vec4_refract(v.raw, n.raw, eta, dest->raw);
|
||||
}
|
||||
|
||||
#endif /* cglms_vec4s_h */
|
||||
|
@@ -55,8 +55,8 @@
|
||||
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_make(float * restrict src, vec2 dest)
|
||||
CGLM_INLINE void glm_vec2_reflect(vec2 I, vec2 N, vec2 dest)
|
||||
CGLM_INLINE void glm_vec2_refract(vec2 I, vec2 N, float eta, 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)
|
||||
*/
|
||||
|
||||
#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
|
||||
*
|
||||
* @param[in] I incident vector
|
||||
* @param[in] N normalized normal vector
|
||||
* @param[in] v incident vector
|
||||
* @param[in] n normalized normal vector
|
||||
* @param[out] dest destination vector for the reflection result
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_vec2_reflect(vec2 I, vec2 N, vec2 dest) {
|
||||
glm_vec2_reflect(vec2 v, vec2 n, vec2 dest) {
|
||||
vec2 temp;
|
||||
glm_vec2_scale(N, 2.0f * glm_vec2_dot(I, N), temp);
|
||||
glm_vec2_sub(I, temp, dest);
|
||||
glm_vec2_scale(n, 2.0f * glm_vec2_dot(v, n), temp);
|
||||
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.
|
||||
* Otherwise, computes refraction vector, stores it in dest, and returns true.
|
||||
*
|
||||
* @param[in] I normalized incident vector
|
||||
* @param[in] N normalized normal vector
|
||||
* @param[in] v normalized incident vector
|
||||
* @param[in] n normalized normal vector
|
||||
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
||||
* @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
|
||||
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;
|
||||
|
||||
ndi = glm_vec2_dot(N, I);
|
||||
ndi = glm_vec2_dot(n, v);
|
||||
eni = eta * ndi;
|
||||
k = 1.0f + eta * eta - eni * eni;
|
||||
|
||||
@@ -756,8 +756,8 @@ glm_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest) {
|
||||
return false;
|
||||
}
|
||||
|
||||
glm_vec2_scale(I, eta, dest);
|
||||
glm_vec2_mulsubs(N, eni + sqrtf(k), dest);
|
||||
glm_vec2_scale(v, eta, dest);
|
||||
glm_vec2_mulsubs(n, eni + sqrtf(k), dest);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -80,9 +80,9 @@
|
||||
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_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_reflect(vec3 I, vec3 N, vec3 dest);
|
||||
CGLM_INLINE void glm_vec3_refract(vec3 I, vec3 N, float eta, 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_refract(vec3 v, vec3 n, float eta, vec3 dest);
|
||||
|
||||
Convenient:
|
||||
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
|
||||
*
|
||||
* @param[in] N vector to orient
|
||||
* @param[in] I incident vector
|
||||
* @param[in] Nref reference vector
|
||||
* @param[in] n vector to orient
|
||||
* @param[in] v incident vector
|
||||
* @param[in] nref reference vector
|
||||
* @param[out] dest oriented vector, pointing away from the surface
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_vec3_faceforward(vec3 N, vec3 I, vec3 Nref, vec3 dest) {
|
||||
if (glm_vec3_dot(I, Nref) < 0.0f) {
|
||||
glm_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest) {
|
||||
if (glm_vec3_dot(v, nref) < 0.0f) {
|
||||
/* N is facing away from I */
|
||||
glm_vec3_copy(N, dest);
|
||||
glm_vec3_copy(n, dest);
|
||||
} else {
|
||||
/* 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
|
||||
*
|
||||
* @param[in] I incident vector
|
||||
* @param[in] N normalized normal vector
|
||||
* @param[in] v incident vector
|
||||
* @param[in] n normalized normal vector
|
||||
* @param[out] dest reflection result
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_vec3_reflect(vec3 I, vec3 N, vec3 dest) {
|
||||
glm_vec3_reflect(vec3 v, vec3 n, vec3 dest) {
|
||||
vec3 temp;
|
||||
glm_vec3_scale(N, 2.0f * glm_vec3_dot(I, N), temp);
|
||||
glm_vec3_sub(I, temp, dest);
|
||||
glm_vec3_scale(n, 2.0f * glm_vec3_dot(v, n), temp);
|
||||
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.
|
||||
* Otherwise, computes refraction vector, stores it in dest, and returns true.
|
||||
*
|
||||
* @param[in] I normalized incident vector
|
||||
* @param[in] N normalized normal vector
|
||||
* @param[in] v normalized incident vector
|
||||
* @param[in] n normalized normal vector
|
||||
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
||||
* @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
|
||||
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;
|
||||
|
||||
ndi = glm_vec3_dot(N, I);
|
||||
ndi = glm_vec3_dot(n, v);
|
||||
eni = eta * ndi;
|
||||
k = 1.0f + eta * eta - eni * eni;
|
||||
|
||||
@@ -1270,8 +1270,8 @@ glm_vec3_refract(vec3 I, vec3 N, float eta, vec3 dest) {
|
||||
return false;
|
||||
}
|
||||
|
||||
glm_vec3_scale(I, eta, dest);
|
||||
glm_vec3_mulsubs(N, eni + sqrtf(k), dest);
|
||||
glm_vec3_scale(v, eta, dest);
|
||||
glm_vec3_mulsubs(n, eni + sqrtf(k), dest);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -65,8 +65,8 @@
|
||||
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_make(float * restrict src, vec4 dest);
|
||||
CGLM_INLINE void glm_vec4_reflect(vec4 I, vec4 N, vec4 dest);
|
||||
CGLM_INLINE void glm_vec4_refract(vec4 I, vec4 N, float eta, 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);
|
||||
|
||||
DEPRECATED:
|
||||
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
|
||||
*
|
||||
* @param[in] I incident vector
|
||||
* @param[in] N normalized normal vector
|
||||
* @param[in] v incident vector
|
||||
* @param[in] n normalized normal vector
|
||||
* @param[out] dest destination vector for the reflection result
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_vec4_reflect(vec4 I, vec4 N, vec4 dest) {
|
||||
glm_vec4_reflect(vec4 v, vec4 n, vec4 dest) {
|
||||
vec4 temp;
|
||||
|
||||
/* TODO: direct simd touch */
|
||||
glm_vec4_scale(N, 2.0f * glm_vec4_dot(I, N), temp);
|
||||
glm_vec4_sub(I, temp, dest);
|
||||
glm_vec4_scale(n, 2.0f * glm_vec4_dot(v, n), temp);
|
||||
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
|
||||
* the 'w' component should manually adjust 'dest' after calling this function.
|
||||
*
|
||||
* @param[in] I normalized incident vector
|
||||
* @param[in] N normalized normal vector
|
||||
* @param[in] v normalized incident vector
|
||||
* @param[in] n normalized normal vector
|
||||
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
||||
* @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
|
||||
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;
|
||||
|
||||
ndi = glm_vec4_dot(N, I);
|
||||
ndi = glm_vec4_dot(n, v);
|
||||
eni = eta * ndi;
|
||||
k = 1.0f + eta * eta - eni * eni;
|
||||
|
||||
@@ -1357,7 +1357,7 @@ glm_vec4_refract(vec4 I, vec4 N, float eta, vec4 dest) {
|
||||
return false;
|
||||
}
|
||||
|
||||
glm_vec4_scale(I, eta, dest);
|
||||
glm_vec4_scale(v, eta, dest);
|
||||
glm_vec4_mulsubs(N, eni + sqrtf(k), dest);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user