Possible bug with scene.pick and fastCheck?


I started bugging you guys a while ago with a bug in the highlightlayer, so might as well continue on the same path :stuck_out_tongue:

The app I’m building uses picking on sometimes quite large scenes and so far using the fastCheck has been working great for us. From the documentation fastCheck states “Launch a fast check only using the bounding boxes. Can be set to null.” Doc

So setting fastCheck to true would just do the picking using bounding boxes and not per poly intersections right? What I faced today was that it seems like the order in which the meshes appear in the scene.meshes array affects the picking if the bounding boxes two meshes are “overlapping” from the perspective of the camera.

I dug around the code a bit and indeed inside the _internalPick method, fastCheck is used to escape the loop as soon as the first hit is found https://github.com/BabylonJS/Babylon.js/blob/80d0ea04b2f9a075e3fe13a0f36a71a8b2df4f48/src/Culling/ray.ts#L694. This seems like something it shouldn’t do or then it’s undocumented? Shouldn’t the mesh.intersects(…) handle the “fastChecking” and the actual picking still try and find the “best” pick?

I created a playground where you can change the ORDER variable from 0 to 1 and see the difference. No need to move the camera, just click on a place where the ray would hit both the sphere and the ground. Babylon.js Playground

Well the doc is incorrect unfortunately.
I will correct it with “fastCheck defines if the first intersection will be used (and not the closest)”

What you need is a new option I added yesterday:)


Ah I figured it could’ve been that, but nice to get a confirmation :slight_smile: I’ll keep an eye out when that’s released than. Thanks for the reply