summaryrefslogtreecommitdiff
path: root/src/util/mini_math.h
AgeCommit message (Collapse)Author
12 hoursfix(math): Normalize axis in quat::from_axis to prevent scaling artifactsskal
Fixed critical bug causing mesh and bounding box stretching during rotation. ROOT CAUSE: quat::from_axis() did not normalize the input axis vector. When called with non-unit vectors (e.g., {0.5, 1.0, 0.0}), it created invalid quaternions that encoded scaling transformations instead of pure rotations. SYMPTOMS: - Mesh vertices stretched during rotation (non-uniform scaling) - Bounding boxes deformed and stretched - Transform matrices became non-orthogonal ISSUE LOCATIONS: - src/tests/test_mesh.cc:309 - axis {0.5, 1.0, 0.0} (length ≈1.118) - src/gpu/effects/flash_cube_effect.cc:79 - axis {0.3, 1, 0.2} (length ≈1.044) FIX: Added automatic normalization in quat::from_axis(): a = a.normalize(); // Ensure axis is unit vector RESULT: - All quaternions now represent pure rotations - No scaling artifacts during rotation - Bounding boxes remain orthogonal - Fixes Task A (test_mesh stretching bug) SAFETY: This change is backward compatible. Code that already passed normalized axes will work identically (normalizing a unit vector = identity). handoff(Claude): Rotation stretching bug fixed. Both shader normal transformation (previous commit) and quaternion creation (this commit) now work correctly. test_mesh should display properly rotated meshes without distortion.
4 daysfix(3d): Tighten torus proxy hull and ensure floor grid visibilityskal
- Adjusted Torus proxy hull in vs_main to 1.5x0.5x1.5 for better SDF fit. - Updated VisualDebug::add_box to use per-object local extents. - Standardized floor grid mapping in fs_main using planar p.xz projection. - Verified non-uniform scale and rotation robustness in test_3d_render.
4 daysfix(3d): Correct debug box transforms and restore object texturesskal
- Updated VisualDebug to accept mat4 transforms, enabling wireframes to follow rotating objects. - Restored SDF bump mapping and floor grid texture in the fragment shader. - Added vec4::xyz() helper to mini_math.h. - Fixed Renderer3D to pass the full model matrix for debug visualization.
4 daysfix(gpu): Resolve high-DPI squished rendering and 3D shadow bugsskal
- Implemented dynamic resolution support in all shaders and effects. - Added explicit viewport setting for all render passes to ensure correct scaling. - Fixed 3D shadow mapping by adding PLANE support and standardizing soft shadow logic. - Propagated resize events through the Effect hierarchy. - Applied project-wide code formatting.
4 daysfeat(3d): Support non-uniform scale and shadows on rasterized objectsskal
- Implemented full support for non-uniform scaling by calculating and passing the 'model_inverse_transpose' matrix to the shader for correct normal transformation. - Added 'transpose()' and 'inverse()' methods to the 'mat4' class in 'mini_math.h'. - Refactored the shader to use the new matrix for lighting rasterized objects. - Updated the test scene to use a rasterized floor (CUBE) instead of an SDF one, ensuring it receives correct lighting and shadows even with non-uniform scale.
5 daysfeat: Implement 3D system and procedural texture managerskal
- 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.
6 daysclang-formatskal
6 daysstyle: add vertical compression rules to clang-formatskal
- Enabled AllowShortFunctionsOnASingleLine: All - Enabled AllowShortBlocksOnASingleLine: Always - Enabled AllowShortIfStatementsOnASingleLine: Always - Enabled AllowShortLoopsOnASingleLine: true - Set MaxEmptyLinesToKeep: 1 - Applied formatting to all source files.
7 daysImplement procedural audio generation, spectral effects, and WebGPU particle ↵skal
system
7 daysenforce code styleskal
7 daysadd mini_math.h header-only vector libskal