dont use I macro defined in standard

This commit is contained in:
Recep Aslantas
2024-03-31 13:24:50 +03:00
parent f388df7f3e
commit bf4c5b4e26
4 changed files with 33 additions and 33 deletions

View File

@@ -1091,16 +1091,16 @@ glms_vec3_(make)(const float * __restrict src) {
* *
* 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
* @returns oriented vector, pointing away from the surface. * @returns oriented vector, pointing away from the surface.
*/ */
CGLM_INLINE CGLM_INLINE
vec3s vec3s
glms_vec3_(faceforward)(vec3s N, vec3s I, vec3s Nref) { glms_vec3_(faceforward)(vec3s n, vec3s v, vec3s nref) {
vec3s dest; vec3s dest;
glm_vec3_faceforward(N.raw, I.raw, Nref.raw, dest.raw); glm_vec3_faceforward(n.raw, v.raw, nref.raw, dest.raw);
return dest; return dest;
} }
@@ -1126,8 +1126,8 @@ glms_vec3_(reflect)(vec3s v, vec3s 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
* *
@@ -1135,8 +1135,8 @@ glms_vec3_(reflect)(vec3s v, vec3s n) {
*/ */
CGLM_INLINE CGLM_INLINE
bool bool
glms_vec3_(refract)(vec3s I, vec3s N, float eta, vec3s * __restrict dest) { glms_vec3_(refract)(vec3s v, vec3s n, float eta, vec3s * __restrict dest) {
return glm_vec3_refract(I.raw, N.raw, eta, dest->raw); return glm_vec3_refract(v.raw, n.raw, eta, dest->raw);
} }
#endif /* cglms_vec3s_h */ #endif /* cglms_vec3s_h */

View File

@@ -781,15 +781,15 @@ TEST_IMPL(GLM_PREFIX, vec2_reflect) {
} }
TEST_IMPL(GLM_PREFIX, vec2_refract) { TEST_IMPL(GLM_PREFIX, vec2_refract) {
vec2 I = {sqrtf(0.5f), -sqrtf(0.5f)}; /* Incoming vector at 45 degrees to normal */ vec2 v = {sqrtf(0.5f), -sqrtf(0.5f)}; /* Incoming vector at 45 degrees to normal */
vec2 N = {0.0f, 1.0f}; /* Surface normal */ vec2 N = {0.0f, 1.0f}; /* Surface normal */
vec2 dest; vec2 dest;
float eta; float eta;
float r; float r;
/* Water to Air (eta = 1.33/1.0) */ /* Water to Air (eta = 1.33/1.0) */
eta = 1.33f / 1.0f; eta = 1.33f / 1.0f;
r = GLM(vec2_refract)(I, N, eta, dest); r = GLM(vec2_refract)(v, N, eta, dest);
// In 2D, we expect a similar bending behavior as in 3D, so we check dest[1] // In 2D, we expect a similar bending behavior as in 3D, so we check dest[1]
if (!(dest[0] == 0.0f && dest[1] == 0.0f)) { if (!(dest[0] == 0.0f && dest[1] == 0.0f)) {
ASSERT(dest[1] < -sqrtf(0.5f)); // Refracted ray bends away from the normal ASSERT(dest[1] < -sqrtf(0.5f)); // Refracted ray bends away from the normal
@@ -801,17 +801,17 @@ TEST_IMPL(GLM_PREFIX, vec2_refract) {
/* Air to Glass (eta = 1.0 / 1.5) */ /* Air to Glass (eta = 1.0 / 1.5) */
eta = 1.0f / 1.5f; eta = 1.0f / 1.5f;
r = GLM(vec2_refract)(I, N, eta, dest); r = GLM(vec2_refract)(v, N, eta, dest);
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal
/* Glass to Water (eta = 1.5 / 1.33) */ /* Glass to Water (eta = 1.5 / 1.33) */
eta = 1.5f / 1.33f; eta = 1.5f / 1.33f;
r = GLM(vec2_refract)(I, N, eta, dest); r = GLM(vec2_refract)(v, N, eta, dest);
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal, less bending than air to glass ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal, less bending than air to glass
/* Diamond to Air (eta = 2.42 / 1.0) */ /* Diamond to Air (eta = 2.42 / 1.0) */
eta = 2.42f / 1.0f; eta = 2.42f / 1.0f;
r = GLM(vec2_refract)(I, N, eta, dest); r = GLM(vec2_refract)(v, N, eta, dest);
if (!(dest[0] == 0.0f && dest[1] == 0.0f)) { if (!(dest[0] == 0.0f && dest[1] == 0.0f)) {
/* High potential for total internal reflection, but if it occurs, expect significant bending */ /* High potential for total internal reflection, but if it occurs, expect significant bending */
ASSERT(dest[1] < -sqrtf(0.5f)); ASSERT(dest[1] < -sqrtf(0.5f));

View File

@@ -1843,12 +1843,12 @@ TEST_IMPL(GLM_PREFIX, vec3_make) {
TEST_IMPL(GLM_PREFIX, vec3_faceforward) { TEST_IMPL(GLM_PREFIX, vec3_faceforward) {
vec3 N = {0.0f, 1.0f, 0.0f}; vec3 N = {0.0f, 1.0f, 0.0f};
vec3 I = {1.0f, -1.0f, 0.0f}; vec3 v = {1.0f, -1.0f, 0.0f};
vec3 Nref = {0.0f, -1.0f, 0.0f}; vec3 Nref = {0.0f, -1.0f, 0.0f};
vec3 dest; vec3 dest;
GLM(vec3_faceforward)(N, I, Nref, dest); GLM(vec3_faceforward)(N, v, Nref, dest);
ASSERT(dest[0] == 0.0f ASSERT(dest[0] == 0.0f
&& dest[1] == -1.0f && dest[1] == -1.0f
&& dest[2] == 0.0f); /* Expect N flipped */ && dest[2] == 0.0f); /* Expect N flipped */
@@ -1886,15 +1886,15 @@ TEST_IMPL(GLM_PREFIX, vec3_reflect) {
} }
TEST_IMPL(GLM_PREFIX, vec3_refract) { TEST_IMPL(GLM_PREFIX, vec3_refract) {
vec3 I = {sqrtf(0.5f), -sqrtf(0.5f), 0.0f}; /* Incoming vector at 45 degrees to normal */ vec3 v = {sqrtf(0.5f), -sqrtf(0.5f), 0.0f}; /* Incoming vector at 45 degrees to normal */
vec3 N = {0.0f, 1.0f, 0.0f}; /* Surface normal */ vec3 N = {0.0f, 1.0f, 0.0f}; /* Surface normal */
vec3 dest; vec3 dest;
float eta; float eta;
bool r; bool r;
/* Water to Air (eta = 1.33/1.0) */ /* Water to Air (eta = 1.33/1.0) */
eta = 1.33f / 1.0f; eta = 1.33f / 1.0f;
r = GLM(vec3_refract)(I, N, eta, dest); r = GLM(vec3_refract)(v, N, eta, dest);
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f)) { if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f)) {
ASSERT(dest[1] < -sqrtf(0.5f)); ASSERT(dest[1] < -sqrtf(0.5f));
ASSERT(r == true); ASSERT(r == true);
@@ -1905,21 +1905,21 @@ TEST_IMPL(GLM_PREFIX, vec3_refract) {
/* Air to Glass (eta = 1.0 / 1.5) */ /* Air to Glass (eta = 1.0 / 1.5) */
eta = 1.0f / 1.5f; eta = 1.0f / 1.5f;
r = GLM(vec3_refract)(I, N, eta, dest); r = GLM(vec3_refract)(v, N, eta, dest);
/* Expect bending towards the normal */ /* Expect bending towards the normal */
ASSERT(dest[1] < -sqrtf(0.5f)); ASSERT(dest[1] < -sqrtf(0.5f));
/* Glass to Water (eta = 1.5 / 1.33) */ /* Glass to Water (eta = 1.5 / 1.33) */
eta = 1.5f / 1.33f; eta = 1.5f / 1.33f;
r = GLM(vec3_refract)(I, N, eta, dest); r = GLM(vec3_refract)(v, N, eta, dest);
/* Expect bending towards the normal, less bending than air to glass */ /* Expect bending towards the normal, less bending than air to glass */
ASSERT(dest[1] < -sqrtf(0.5f)); ASSERT(dest[1] < -sqrtf(0.5f));
/* Diamond to Air (eta = 2.42 / 1.0) */ /* Diamond to Air (eta = 2.42 / 1.0) */
eta = 2.42f / 1.0f; eta = 2.42f / 1.0f;
r = GLM(vec3_refract)(I, N, eta, dest); r = GLM(vec3_refract)(v, N, eta, dest);
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f)) { if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f)) {
/* High potential for total internal reflection, but if it occurs, expect significant bending */ /* High potential for total internal reflection, but if it occurs, expect significant bending */
ASSERT(dest[1] < -sqrtf(0.5f)); ASSERT(dest[1] < -sqrtf(0.5f));

View File

@@ -1571,15 +1571,15 @@ TEST_IMPL(GLM_PREFIX, vec4_reflect) {
} }
TEST_IMPL(GLM_PREFIX, vec4_refract) { TEST_IMPL(GLM_PREFIX, vec4_refract) {
vec4 I = {sqrtf(0.5f), -sqrtf(0.5f), 0.0f, 0.0f}; /* Incoming vector */ vec4 v = {sqrtf(0.5f), -sqrtf(0.5f), 0.0f, 0.0f}; /* Incoming vector */
vec4 N = {0.0f, 1.0f, 0.0f, 0.0f}; /* Surface normal */ vec4 N = {0.0f, 1.0f, 0.0f, 0.0f}; /* Surface normal */
vec4 dest; vec4 dest;
float eta; float eta;
float r; float r;
/* Water to Air (eta = 1.33/1.0) */ /* Water to Air (eta = 1.33/1.0) */
eta = 1.33f / 1.0f; eta = 1.33f / 1.0f;
r = GLM(vec4_refract)(I, N, eta, dest); r = GLM(vec4_refract)(v, N, eta, dest);
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f)) { if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f)) {
ASSERT(dest[1] < -sqrtf(0.5f)); ASSERT(dest[1] < -sqrtf(0.5f));
ASSERT(r == true); ASSERT(r == true);
@@ -1590,17 +1590,17 @@ TEST_IMPL(GLM_PREFIX, vec4_refract) {
/* Air to Glass (eta = 1.0 / 1.5) */ /* Air to Glass (eta = 1.0 / 1.5) */
eta = 1.0f / 1.5f; eta = 1.0f / 1.5f;
r = GLM(vec4_refract)(I, N, eta, dest); r = GLM(vec4_refract)(v, N, eta, dest);
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal
/* Glass to Water (eta = 1.5 / 1.33) */ /* Glass to Water (eta = 1.5 / 1.33) */
eta = 1.5f / 1.33f; eta = 1.5f / 1.33f;
r = GLM(vec4_refract)(I, N, eta, dest); r = GLM(vec4_refract)(v, N, eta, dest);
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal, less bending than air to glass ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal, less bending than air to glass
/* Diamond to Air (eta = 2.42 / 1.0) */ /* Diamond to Air (eta = 2.42 / 1.0) */
eta = 2.42f / 1.0f; eta = 2.42f / 1.0f;
r = GLM(vec4_refract)(I, N, eta, dest); r = GLM(vec4_refract)(v, N, eta, dest);
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f)) { if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f)) {
/* High potential for total internal reflection, but if it occurs, expect significant bending */ /* High potential for total internal reflection, but if it occurs, expect significant bending */
ASSERT(dest[1] < -sqrtf(0.5f)); ASSERT(dest[1] < -sqrtf(0.5f));