diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-14 15:14:25 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-14 15:14:25 +0100 |
| commit | 8ce27b7e15f0fc65c8ee78950c7501660b936178 (patch) | |
| tree | 391f32111b9a30a0156709b6c1ed2fae7b435d57 /src/tests/3d | |
| parent | e38be0dbf5816338ff97e2ee2f9adfff2902dc2b (diff) | |
style: Apply clang-format to codebase
Diffstat (limited to 'src/tests/3d')
| -rw-r--r-- | src/tests/3d/test_3d.cc | 11 | ||||
| -rw-r--r-- | src/tests/3d/test_3d_physics.cc | 2 | ||||
| -rw-r--r-- | src/tests/3d/test_3d_render.cc | 2 | ||||
| -rw-r--r-- | src/tests/3d/test_mesh.cc | 2 | ||||
| -rw-r--r-- | src/tests/3d/test_physics.cc | 12 |
5 files changed, 18 insertions, 11 deletions
diff --git a/src/tests/3d/test_3d.cc b/src/tests/3d/test_3d.cc index 7132b33..13edd45 100644 --- a/src/tests/3d/test_3d.cc +++ b/src/tests/3d/test_3d.cc @@ -1,10 +1,10 @@ // This file is part of the 64k demo project. // It tests the 3D system components (Camera, Object, Scene). +#include "../common/test_math_helpers.h" #include "3d/camera.h" #include "3d/object.h" #include "3d/scene.h" -#include "../common/test_math_helpers.h" #include <cassert> #include <iostream> @@ -76,7 +76,8 @@ void test_object_transform() { vec4 original_space_t = inv_model_t * vec4(translated_point.x, translated_point.y, translated_point.z, 1.0); - assert(test_near(original_space_t.x, 0.0f, 0.001f) && test_near(original_space_t.y, 0.0f, 0.001f) && + assert(test_near(original_space_t.x, 0.0f, 0.001f) && + test_near(original_space_t.y, 0.0f, 0.001f) && test_near(original_space_t.z, 0.0f, 0.001f)); // Model matrix with rotation (90 deg Y) and translation (5,0,0) @@ -88,10 +89,12 @@ void test_object_transform() { // Translates to (5,0,-1) vec4 p_trs(1, 0, 0, 1); vec4 transformed_p = model_trs * p_trs; - assert(test_near(transformed_p.x, 5.0f, 0.001f) && test_near(transformed_p.z, -1.0f, 0.001f)); + assert(test_near(transformed_p.x, 5.0f, 0.001f) && + test_near(transformed_p.z, -1.0f, 0.001f)); // Apply inverse to transformed point to get back original point vec4 original_space_trs = inv_model_trs * transformed_p; - assert(test_near(original_space_trs.x, 1.0f, 0.001f) && test_near(original_space_trs.y, 0.0f, 0.001f) && + assert(test_near(original_space_trs.x, 1.0f, 0.001f) && + test_near(original_space_trs.y, 0.0f, 0.001f) && test_near(original_space_trs.z, 0.0f, 0.001f)); } diff --git a/src/tests/3d/test_3d_physics.cc b/src/tests/3d/test_3d_physics.cc index 9e4f71b..26b9bfa 100644 --- a/src/tests/3d/test_3d_physics.cc +++ b/src/tests/3d/test_3d_physics.cc @@ -1,6 +1,7 @@ // This file is part of the 64k demo project. // Standalone "mini-demo" for testing the 3D physics engine. +#include "../common/test_3d_helpers.h" #include "3d/bvh.h" #include "3d/camera.h" #include "3d/object.h" @@ -12,7 +13,6 @@ #include "gpu/texture_manager.h" #include "platform/platform.h" #include "procedural/generator.h" -#include "../common/test_3d_helpers.h" #include <cmath> #include <cstdio> #include <cstring> diff --git a/src/tests/3d/test_3d_render.cc b/src/tests/3d/test_3d_render.cc index 10de907..9398649 100644 --- a/src/tests/3d/test_3d_render.cc +++ b/src/tests/3d/test_3d_render.cc @@ -1,6 +1,7 @@ // This file is part of the 64k demo project. // Standalone "mini-demo" for testing the 3D renderer. +#include "../common/test_3d_helpers.h" #include "3d/camera.h" #include "3d/object.h" #include "3d/renderer.h" @@ -11,7 +12,6 @@ #include "gpu/texture_manager.h" #include "platform/platform.h" #include "procedural/generator.h" -#include "../common/test_3d_helpers.h" #include <cmath> #include <cstdio> #include <cstring> diff --git a/src/tests/3d/test_mesh.cc b/src/tests/3d/test_mesh.cc index d4ce097..2a13125 100644 --- a/src/tests/3d/test_mesh.cc +++ b/src/tests/3d/test_mesh.cc @@ -1,6 +1,7 @@ // This file is part of the 64k demo project. // Standalone test for loading and rendering a single mesh from a .obj file. +#include "../common/test_3d_helpers.h" #include "3d/camera.h" #include "3d/object.h" #include "3d/renderer.h" @@ -11,7 +12,6 @@ #include "platform/platform.h" #include "procedural/generator.h" #include "util/asset_manager_utils.h" -#include "../common/test_3d_helpers.h" #include <algorithm> #include <cmath> #include <cstdio> 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() { |
