summaryrefslogtreecommitdiff
path: root/src/3d/renderer.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-06 08:05:20 +0100
committerskal <pascal.massimino@gmail.com>2026-02-06 08:05:20 +0100
commit8ded2005d441f8aab44c833fc658d9622c788ebd (patch)
treeefaf714b636788148db583903bfbff3b015f3f58 /src/3d/renderer.h
parent1ec5d1ae48d1dd3290992ba63a8ec581af02b9dd (diff)
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.
Diffstat (limited to 'src/3d/renderer.h')
-rw-r--r--src/3d/renderer.h13
1 files changed, 12 insertions, 1 deletions
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<AssetId, MeshGpuData> mesh_cache_;
+ const MeshGpuData* temp_mesh_override_ = nullptr; // HACK for test_mesh tool
WGPUTextureView noise_texture_view_ = nullptr;
WGPUTextureView sky_texture_view_ = nullptr;