ME-6451 register mesh information#22
Conversation
34952df to
c39e020
Compare
c39e020 to
e3a7062
Compare
| struct MeshData { | ||
| std::vector<math::float3> positions; // Vertex positions in local space | ||
| std::vector<uint32_t> indices; // Triangle indices (3 per triangle) | ||
| std::unique_ptr<tinybvh::BVH> bvh; // BVH for accelerated ray tracing |
There was a problem hiding this comment.
bvh will be used for triangle intersection
There was a problem hiding this comment.
Pull request overview
This PR implements the foundation for triangle picking in glTF meshes by introducing a PickingRegistry that stores mesh geometry data and builds BVH (Bounding Volume Hierarchy) acceleration structures for efficient ray-triangle intersection testing.
Changes:
- Adds
PickingRegistryclass to extract and store vertex positions and triangle indices from glTF meshes - Integrates TinyBVH library for building acceleration structures
- Registers mesh data during renderable creation in
AssetLoader
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| libs/gltfio/include/gltfio/PickingRegistry.h | Defines the PickingRegistry class and MeshData structure for managing mesh geometry and BVH data |
| libs/gltfio/src/PickingRegistry.cpp | Implements mesh registration, geometry extraction from cgltf, and BVH construction |
| libs/gltfio/src/FFilamentAsset.h | Adds PickingRegistry member to FFilamentAsset |
| libs/gltfio/src/AssetLoader.cpp | Calls registerMesh after creating renderables |
| libs/gltfio/CMakeLists.txt | Adds new PickingRegistry files to build configuration |
Comments suppressed due to low confidence (1)
libs/gltfio/include/gltfio/PickingRegistry.h:130
- Extra blank line at end of file. Remove the trailing blank line to follow common formatting conventions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
libs/gltfio/src/PickingRegistry.cpp
Outdated
| slog.d << "PickingRegistry: Registered mesh for entity " << entity.getId() | ||
| << " with " << (meshData.indices.size() / 3) << " triangles" << io::endl; |
There was a problem hiding this comment.
The log message references meshData after it has been moved on line 141. This will result in logging incorrect data (likely 0 triangles). Cache the triangle count before moving meshData, or access it from mMeshes[entity] after the move.
| // Mesh Registration | ||
| // ============================================================================ | ||
|
|
||
| bool PickingRegistry::registerMesh(const Entity entity, const cgltf_mesh* mesh) { |
There was a problem hiding this comment.
are there any memory implications for making this registry?
There was a problem hiding this comment.
@j1george did some benchmarking for the space occupied by the meshData,
https://fieldwire.atlassian.net/browse/ME-6454
it's around 200MB for larger models. He hasn't faced any memory issues when playing around with those models. So i assume it is fine. I will keep an eye on the memory once we start consuming this code from android
…ailable independent of whether AssetLoaderExtended is used or not
https://fieldwire.atlassian.net/browse/ME-6275
This PR sets up the base for triangle picking implementation.
Gets the vertex (triangle co-ordinates) and index data from source gltf. AssetLoader parses the gltf file using cgltf library. Once the parsing is done, we get reference to cgltf_mesh (mesh object in gltf) and read position & index data from it and store in PickingRegistry.