Skip to content

ME-6451 register mesh information#22

Merged
mbalajee merged 2 commits intofeature/triangle-pickingfrom
dev/balaji/ME-6451-register-mesh
Feb 9, 2026
Merged

ME-6451 register mesh information#22
mbalajee merged 2 commits intofeature/triangle-pickingfrom
dev/balaji/ME-6451-register-mesh

Conversation

@mbalajee
Copy link

@mbalajee mbalajee commented Feb 5, 2026

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.

@mbalajee mbalajee force-pushed the dev/balaji/ME-6451-register-mesh branch from 34952df to c39e020 Compare February 5, 2026 12:55
@mbalajee mbalajee force-pushed the dev/balaji/ME-6451-register-mesh branch from c39e020 to e3a7062 Compare February 5, 2026 12:57
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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bvh will be used for triangle intersection

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PickingRegistry class 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.

Comment on lines 143 to 144
slog.d << "PickingRegistry: Registered mesh for entity " << entity.getId()
<< " with " << (meshData.indices.size() / 3) << " triangles" << io::endl;
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
// Mesh Registration
// ============================================================================

bool PickingRegistry::registerMesh(const Entity entity, const cgltf_mesh* mesh) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any memory implications for making this registry?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

@pirlande-fw pirlande-fw self-assigned this Feb 6, 2026
@pirlande-fw pirlande-fw removed their request for review February 6, 2026 02:14
…ailable independent of whether AssetLoaderExtended is used or not
@mbalajee mbalajee merged commit 801b865 into feature/triangle-picking Feb 9, 2026
@mbalajee mbalajee mentioned this pull request Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants