Improve Raycast

@Helder_Oliveira I have been playing around with ‘bounding volume hierarchy’ or bvh, which improves raycasting. here is an example with you teeth example Morton BVH Pick

A warning or two - this is an experimental version, once loaded (please be patient) you need to use the ‘Click to Generate BVH’ button and wait until it disappears before clicking on the jaw. Waiting means that the browser warning about ‘something slowing it down’ might appear two or three times while the bvh is generated (again be patient). Once the button disappears click on the jaw and the time for the pick is given and small red boxes appear wherever the picking ray hit the jaw. I am getting around 1 to 3 ms to pick. I do not know if that is sufficient improvement for you.

In a full version you would be able to generate and save the bvh along with the mesh for later re-loading and use.

The code, should you want to use/develop it, is at GitHub - BabylonJSGuide/bvh: bounding volume hierarchies for ray tracing in Babylon.js.

The good news is that this topic suggests that at some point BVH (using a different method to generate) will become part of Babylon.js and may be generated using the GPU.

More test/info

5 Likes