(single_obj=None, ignore_matrix=False)
| 72 | |
| 73 | |
| 74 | def scene_bbox(single_obj=None, ignore_matrix=False): |
| 75 | bbox_min = (math.inf,) * 3 |
| 76 | bbox_max = (-math.inf,) * 3 |
| 77 | found = False |
| 78 | for obj in scene_meshes() if single_obj is None else [single_obj]: |
| 79 | found = True |
| 80 | for coord in obj.bound_box: |
| 81 | coord = Vector(coord) |
| 82 | if not ignore_matrix: |
| 83 | coord = obj.matrix_world @ coord |
| 84 | bbox_min = tuple(min(x, y) for x, y in zip(bbox_min, coord)) |
| 85 | bbox_max = tuple(max(x, y) for x, y in zip(bbox_max, coord)) |
| 86 | if not found: |
| 87 | raise RuntimeError("no objects in scene to compute bounding box for") |
| 88 | return Vector(bbox_min), Vector(bbox_max) |
| 89 | |
| 90 | |
| 91 | def scene_meshes(): |
no test coverage detected