BVHTree.FromObject - blender 2.8 wonkiness


#1

I blender 2.79 I could do:

obj.data.transform(obj.matrix_world)
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:

obj.data.transform(obj.matrix_world)
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: obj.data.transform(obj.matrix_world.inverted()) - 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:

Context.depsgraph.scene.changed_property

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?


#2

Maybe this will help some people:

context.depsgraph.objects[snapSurface.name].data.transform(snapSurface.matrix_world)
sourceSurface_BVHT = BVHTree.FromObject(snapSurface, context.depsgraph)
context.depsgraph.objects[snapSurface.name].data.transform(snapSurface.matrix_world.inverted())

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