How exactly does epsilon work in BVH tree?

The way I understood it- was that if you create a bvhtree from bmesh, you could specify an epsilon ‘offset’ factor that would allow you to use the other bvhtree utilities, such as find_nearest, raycast, etc.

I’m sure I’m just not understanding it correctly, because the behavior I’m seeing is not consistent with that description. In the following example, I’ve set up a super basic GL line test that changes color when a raycast comes back with valid data. As you can see, it starts out fine- as I move the mouse around the perimeter of the mesh, the line turns green indicating a successful ray hit, but as I work my way around the mesh, you can see that the rays are failing in certain areas where they should be hitting.

I’m creating my bvhtree from a bmesh on operator invoke, using an epsilon of .5, and doing a simple ray_cast using the view vector derived from region_2d_to_vector_3d in modal mousemove. I just don’t understand it! Hoping somebody here can shed some light, I’m new to using bvhtree , and assuming I can get it working the way I want I have a ton of cool ideas for how to use it in the future.

Is there any chance this is a bug? it seems unlikely since bvh trees would be used elsewhere, but I just can’t figure this out. I wish there was a way to visualize the bvh volumes to know for sure what’s happening under the hood.

I guess the epsilon is specified in Blender units? If that’s the case, 0.5 is huge (most scenes use 1 BU = 1 m, so your epsilon would be 50 cm).
Have you tried a smaller value like 0.000001?

I mean… sure- but I wouldn’t think that would matter. the default cube is 2m³ so trying to detect hits 50cm away from the perimeter would be pretty trivial. I mean- just go into edit mode and try to select a vertex along the perimeter and note when it stops working, it’s around 50cm with the cube framed in the viewport, or more (1m+ when zoomed out since it’s relative to the viewport). Internally, Blender is using bvh trees for selection so it should work exactly the same.