Bounding box access


I was working on an improved zoom-to-fit-selection tool and I was getting some good results. But since the day after the Blender Conference, object.bound_box no longer contains any data. Everything’s just zero. Setting the display mode of the object to Bounds does show the bounding box correctly, but this bounding box sure isn’t coming from object.bound_box.

I also tried using mesh.texture_space_location and mesh.texture_space_size, because these define a bounding box as well, but they also don’t seem to update when editing the object. While it is updated somewhere, because it does show in the viewport.

Question is… the bounding box is calculated, but where can I access it in Python in 2.8?

Have fun!

@mont29 did some changes in this area, maybe he knows more. As far as I know it is supposed to be updating this bounding box in the original object, but maybe something is still broken here.

1 Like

Yes, bbox are broken currently in Blender2.8, innseveral known cases at least. Am even considering reverting my changes from late October.

The problem is that in non-CoW Blender, bbox computation was pretty crazy, even computing e.g. mesh bbox from call to get object bbox, etc. With new despgraph and CoW, all this cross-ID behavior is utterly broken and totally wrong (that can end up in concurrent accesses, double freeing, and all that kind of nasty threading issues). And current code is a maze, with bboxes being computed and freed several times during evaluation process, in a rather impossible-to-follow fashion.

So bbox computation needs to be seriously refactored imho, ideally that should be done early in beta phase :confused:


Thank you for your answers and for the fix! This commit just fixed the problem and bounding boxes are working again: