ME-6452 triangle picking#23
Conversation
|
Please add a release note line to NEW_RELEASE_NOTES.md. If this PR does not warrant a release note, add the 'internal' label to this PR. |
There was a problem hiding this comment.
Pull request overview
Adds CPU-side triangle picking for glTF meshes by registering mesh geometry during asset loading, building a BVH (tinybvh), and enabling optional runtime filtering to skip hidden triangles during intersection.
Changes:
- Introduces
PickingRegistryto extract mesh positions/indices, build BVHs, and perform screen-to-world ray picks. - Defers mesh registration until buffers are loaded, then registers meshes in
ResourceLoader. - Patches tinybvh traversal to optionally skip triangles based on caller-provided ranges.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| third_party/tiny-bvh/tiny_bvh.h | Adds optional pick-time triangle filtering hook during BVH intersection. |
| samples/gltf_viewer.cpp | Updates sample click handling to demonstrate CPU picking / registry usage. |
| libs/gltfio/src/ResourceLoader.cpp | Registers deferred meshes into the picking registry after buffer loading. |
| libs/gltfio/src/PickingRegistry.cpp | Implements mesh extraction, BVH build, screen-ray computation, and picking. |
| libs/gltfio/src/FilamentAsset.cpp | Clears picking registry on asset destruction; exposes getPickingRegistry(). |
| libs/gltfio/src/FFilamentAsset.h | Stores pending mesh registrations and embeds PickingRegistry. |
| libs/gltfio/src/AssetLoader.cpp | Defers mesh registration until cgltf buffers are loaded. |
| libs/gltfio/include/gltfio/PickingRegistry.h | Declares public picking registry API and related data structures. |
| libs/gltfio/include/gltfio/FilamentAsset.h | Adds public FilamentAsset::getPickingRegistry() API. |
| libs/gltfio/CMakeLists.txt | Adds new header/source to the gltfio build. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c4969c4 to
111efba
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
3b661ee to
67e9551
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
https://fieldwire.atlassian.net/browse/ME-6452
This PR introduces CPU-side triangle picking for glTF meshes. The picker computes a ray from screen coordinates, intersects it against mesh geometry on the CPU using a BVH (tinybvh), and returns the closest hit.
In addition, the BVH intersection is extended to support skipping hidden triangles, so geometry that has been hidden at runtime is not pickable.
Motivation
We need reliable triangle-level picking results on the CPU:
What’s included
Why patch tinybvh?
To support runtime filtering (“don’t pick hidden triangles”) efficiently while still using an indexed + BVH-based approach.
Options considered:
Rebuild BVH / BVH vertices on every pick
Expand vertices to explicit triangles + custom intersection
Indexed geometry + BVH traversal (chosen)
Verdict: use indexed geometry for memory efficiency and extend tinybvh to filter hidden triangles.
Memory metrics
Representative measurements comparing expanded triangles vs indexed route:
160K
60K
Behavior notes
Testing
after.mov
before.mov