BVHTree.FromObject - blender 2.8 wonkiness

I blender 2.79 I could do:
sourceSurface_BVHT = BVHTree.FromObject(obj, context.scene)

This would give me BVHT of obj with modifiers, in world space. Now in 2.8 it won’t work, and I have to add additional line:
context.depsgraph.scene.update() #this is new line
sourceSurface_BVHT = BVHTree.FromObject(obj, context.depsgraph)

Is this normal, to have to use context.depsgraph.scene.update() for ‘data.transform’ to take effect? Maybe there is way to update depsgraph jut for this one object (for performance gain)?
After that I just to run: - to revert mesh transformation.

Also I noticed when running modal timer operator, If I change some custom scene property (eg. float slider), operator won’t see this property change. I have to use:


To read the updated value. The new depsgraph makes things more complicated it seems. Is there info, when do I have to use depshgrapth evaluated props, objects, etc. and when I can skip it?

Maybe this will help some people:

sourceSurface_BVHT = BVHTree.FromObject(snapSurface, context.depsgraph)

Seems to be around 10x faster than doing method from above (with context.depsgraph.scene.update() ). I guess this is how things are now in blender 2.8, and if you want to use world space object, then do this in depsgrapht.object[x].transform


Just a quick reply in thanks- this saved me a bunch of time. Honestly all of the BVHTree.From functions should have an optional “world_space” bool parameter and do all of this behind the scenes. And while they’re at it, they should probably make it True by default- when would you ever want to build a BVHTree and not use the world position of the geometry?

1 Like