From 8ded2005d441f8aab44c833fc658d9622c788ebd Mon Sep 17 00:00:00 2001 From: skal Date: Fri, 6 Feb 2026 08:05:20 +0100 Subject: feat(tests): Add test_mesh tool for OBJ loading and normal visualization Implemented a new standalone test tool 'test_mesh' to: - Load a .obj file specified via command line. - Display the mesh with rotation and basic lighting on a tiled floor. - Provide a '--debug' option to visualize vertex normals as cyan lines. - Updated asset_packer to auto-generate smooth normals for OBJs if missing. - Fixed various WGPU API usage inconsistencies and build issues on macOS. - Exposed Renderer3D::GetVisualDebug() for test access. - Added custom Vec3 struct and math utilities for OBJ parsing. This tool helps verify mesh ingestion and normal computation independently of the main demo logic. --- src/3d/renderer.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/3d/renderer.h') diff --git a/src/3d/renderer.h b/src/3d/renderer.h index 5caf19b..5c9fd38 100644 --- a/src/3d/renderer.h +++ b/src/3d/renderer.h @@ -65,13 +65,23 @@ class Renderer3D { // Set whether to use BVH acceleration void SetBvhEnabled(bool enabled) { bvh_enabled_ = enabled; } - private: struct MeshGpuData { WGPUBuffer vertex_buffer; WGPUBuffer index_buffer; uint32_t num_indices; }; + // HACK for test_mesh tool + void override_mesh_buffers(const MeshGpuData* data) { + temp_mesh_override_ = data; + } + +#if !defined(STRIP_ALL) + VisualDebug& GetVisualDebug() { return visual_debug_; } +#endif + + private: + void create_pipeline(); WGPURenderPipeline create_pipeline_impl(bool use_bvh); void create_mesh_pipeline(); @@ -98,6 +108,7 @@ class Renderer3D { bool bvh_enabled_ = true; std::map mesh_cache_; + const MeshGpuData* temp_mesh_override_ = nullptr; // HACK for test_mesh tool WGPUTextureView noise_texture_view_ = nullptr; WGPUTextureView sky_texture_view_ = nullptr; -- cgit v1.2.3