diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-01 10:51:15 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-01 10:51:15 +0100 |
| commit | 8bdc4754647c9c6691130fa91d51fee93c5fc88f (patch) | |
| tree | 2cfd7f72a21541c488ea48629eef47a6774fc2c4 /src/tests/test_maths.cc | |
| parent | 7905abd9f7ad35231289e729b42e3ad57a943ff5 (diff) | |
feat: Implement 3D system and procedural texture manager
- Extended mini_math.h with mat4 multiplication and affine transforms.
- Implemented TextureManager for runtime procedural texture generation and GPU upload.
- Added 3D system components: Camera, Object, Scene, and Renderer3D.
- Created test_3d_render mini-demo for interactive 3D verification.
- Fixed WebGPU validation errors regarding depthSlice and unimplemented WaitAny.
Diffstat (limited to 'src/tests/test_maths.cc')
| -rw-r--r-- | src/tests/test_maths.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tests/test_maths.cc b/src/tests/test_maths.cc index d9bc4d1..64bbb45 100644 --- a/src/tests/test_maths.cc +++ b/src/tests/test_maths.cc @@ -110,6 +110,25 @@ void test_matrices() { mat4 view = mat4::look_at(eye, target, up); // Point (0,0,0) in world should be at (0,0,-5) in view space assert(near(view.m[14], -5.0f)); + + // Test matrix multiplication + mat4 t = mat4::translate({1, 2, 3}); + mat4 s = mat4::scale({2, 2, 2}); + mat4 ts = t * s; // Scale then Translate (if applied to vector on right: M*v) + + // v = (1,1,1,1) -> scale(2,2,2) -> (2,2,2,1) -> translate(1,2,3) -> (3,4,5,1) + vec4 v(1, 1, 1, 1); + vec4 res = ts * v; + assert(near(res.x, 3.0f)); + assert(near(res.y, 4.0f)); + assert(near(res.z, 5.0f)); + + // Test Rotation + // Rotate 90 deg around Z. (1,0,0) -> (0,1,0) + mat4 r = mat4::rotate({0, 0, 1}, 1.570796f); + vec4 v_rot = r * vec4(1, 0, 0, 1); + assert(near(v_rot.x, 0.0f)); + assert(near(v_rot.y, 1.0f)); } // Tests easing curves |
