diff options
Diffstat (limited to 'src/tests/3d/test_physics.cc')
| -rw-r--r-- | src/tests/3d/test_physics.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/tests/3d/test_physics.cc b/src/tests/3d/test_physics.cc index c1c5c32..6c1f814 100644 --- a/src/tests/3d/test_physics.cc +++ b/src/tests/3d/test_physics.cc @@ -1,10 +1,10 @@ // This file is part of the 64k demo project. // It tests the CPU-side SDF library and BVH for physics and collision. +#include "../common/test_math_helpers.h" #include "3d/bvh.h" #include "3d/physics.h" #include "3d/sdf_cpu.h" -#include "../common/test_math_helpers.h" #include <cassert> #include <iostream> @@ -46,18 +46,22 @@ void test_calc_normal() { // Sphere normal at (1,0,0) should be (1,0,0) auto sphere_sdf = [](vec3 p) { return sdf::sdSphere(p, 1.0f); }; vec3 n = sdf::calc_normal({1, 0, 0}, sphere_sdf); - assert(test_near(n.x, 1.0f, 0.001f) && test_near(n.y, 0.0f, 0.001f) && test_near(n.z, 0.0f, 0.001f)); + assert(test_near(n.x, 1.0f, 0.001f) && test_near(n.y, 0.0f, 0.001f) && + test_near(n.z, 0.0f, 0.001f)); // Box normal at side auto box_sdf = [](vec3 p) { return sdf::sdBox(p, {1, 1, 1}); }; n = sdf::calc_normal({1, 0, 0}, box_sdf); - assert(test_near(n.x, 1.0f, 0.001f) && test_near(n.y, 0.0f, 0.001f) && test_near(n.z, 0.0f, 0.001f)); + assert(test_near(n.x, 1.0f, 0.001f) && test_near(n.y, 0.0f, 0.001f) && + test_near(n.z, 0.0f, 0.001f)); // Plane normal should be n vec3 plane_n(0, 1, 0); auto plane_sdf = [plane_n](vec3 p) { return sdf::sdPlane(p, plane_n, 1.0f); }; n = sdf::calc_normal({0, 0, 0}, plane_sdf); - assert(test_near(n.x, plane_n.x, 0.001f) && test_near(n.y, plane_n.y, 0.001f) && test_near(n.z, plane_n.z, 0.001f)); + assert(test_near(n.x, plane_n.x, 0.001f) && + test_near(n.y, plane_n.y, 0.001f) && + test_near(n.z, plane_n.z, 0.001f)); } void test_bvh() { |
