I am using blender for a synthetic data generation for over a month now. I was hoping to achieve the same computation with less time than using BVH tree for collision detection, no luck so far.

I was using bound box in bpy module, like

cube = bpy.data.objects['Cube']
cube.bound_box # return itterable of points in 3d space

There are two problems that I faced,

  1. Bound box won't update on its own because of the transformation of the objects, like rotation, location, scale. For that I had to use bpy.ops.transform_apply(scale=True, location=True, rotation=True)

  2. When I did use that force update, I noticed that the bound box that blender gives isn't ideal as they mention in documents, it can be confirmed in the example below enter image description here The surface of the cube is itself a bound box as it is a cube after all, but the cube.bound_box is giving this bound box shown in pic, which is nowhere near ideal.

Note: If anyone found something wrong in this post, please do comment as I am in the middle of development of a framework which is basically a automation of this scene creation. It will really help me a lot, if you could suggest or provide the solution of my issues that I mentioned above.

  • $\begingroup$ The boundbox is the bounding coordinates in local space. If you want the global coordinate multiply each coordinate by the matrix world of the object, just as you would to get the global coordinates of each vertex. eg for the default cube the vertex coordinates match the bbox coordinates. Transforming at object level does not effect the coordinates at a local level. $\endgroup$
    – batFINGER
    Nov 30, 2020 at 12:30
  • $\begingroup$ Algorithm here github.com/intel-isl/Open3D/blob/… $\endgroup$
    – lemon
    Nov 30, 2020 at 12:39
  • $\begingroup$ @lemon .... first step would be to look at AABB (axis aligned bounding box) which is what the blender bounding box is. The OP has transformed the mesh and hence changed the vert coordinates and hence the AABB, whereas would suggest they transform the bbox coords into global space to "See the update" Would be same issue if they used the cube verts which also wouldn't "update" when "using transformation like location, rotation and scale" on the object. eg blender.stackexchange.com/a/62047/15543 to calc global bbox center. $\endgroup$
    – batFINGER
    Nov 30, 2020 at 12:49
  • $\begingroup$ @batFINGER, I think he wants to know the minimal enclosing bb. $\endgroup$
    – lemon
    Nov 30, 2020 at 12:58
  • $\begingroup$ We'll see. As OP mentioned in post wasn't seeing an update in bbox so applied the transform to the mesh data (local) and hence the bbox now "isn't ideal". Suggest instead to [ob.matrix_world @ Vector(b) for b in ob.bound_box] will giive the transformed coordinates of the "updated bbox" and will be both axis and object aligned as it was in the first place. IMO this is a local vs global coordinates issue, not how to program an OOBB. Anyway we'll see. $\endgroup$
    – batFINGER
    Nov 30, 2020 at 13:01


You must log in to answer this question.

Browse other questions tagged .