commit 96a07e217c782b471045533813456c046d02dd93
parent 4a2e1c1025a288048e63cca45400b596c0955b60
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Tue, 19 Jan 2021 15:12:08 +0100
Add a test on closest_point hit normals
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/test_s3d_closest_point.c b/src/test_s3d_closest_point.c
@@ -957,7 +957,7 @@ test_single_triangle(struct s3d_device* dev)
const float amplitude = exp2f((float)a);
const float eps = 5e-6f * amplitude;
FOR_EACH(i, 0, 1000) {
- float A[3], B[3], C[3], AB[3], AC[3], BC[3], N[3];
+ float A[3], B[3], C[3], AB[3], AC[3], BC[3], N[3], hit_N[3];
int j, n;
/* Randomly generate a triangle ABC */
@@ -973,7 +973,7 @@ test_single_triangle(struct s3d_device* dev)
f3_sub(AB, B, A);
f3_sub(AC, C, A);
f3_sub(BC, C, B);
- f3_cross(N, AB, AC);
+ f3_cross(N, AC, AB); /* Left hand convention */
f3_normalize(N, N);
f3_set(vertices + 0, A);
@@ -1070,6 +1070,8 @@ test_single_triangle(struct s3d_device* dev)
/* Intersection-point's position is less accurate than hit distance */
d = f3_len(f3_sub(tmp, closest, attr.value));
CHK(d <= 10 * eps);
+ f3_normalize(hit_N, hit.normal);
+ CHK(f3_eq_eps(N, hit_N, FLT_EPSILON));
}
CHK(s3d_shape_ref_put(msh) == RES_OK);