diff options
author | Ghostkeeper <rubend@tutanota.com> | 2021-05-21 14:30:53 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2021-05-21 14:30:53 +0300 |
commit | 6eeb135672b5d493d763f5486d98ed55fdbc7b38 (patch) | |
tree | e99dbee728fc95fbab899461a9e820c0f1b01906 /cura/Scene | |
parent | cfb32bfd50226ccd1ca20ba76aeb068b08143002 (diff) |
Fix calculating AABBs if group nodes are involved
The position of the group node should in theory never be included.
We'll return that position only if there is no mesh data and all children have no AABB either. In that case we'll return a degenerate AABB so that handling code has something to work with. But then also make sure that those degenerate AABBs are ignored if we want to get the AABB of a parent node.
Contributes to issue CURA-7873.
Diffstat (limited to 'cura/Scene')
-rw-r--r-- | cura/Scene/CuraSceneNode.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/cura/Scene/CuraSceneNode.py b/cura/Scene/CuraSceneNode.py index 93a1511681..9b5c432b36 100644 --- a/cura/Scene/CuraSceneNode.py +++ b/cura/Scene/CuraSceneNode.py @@ -119,22 +119,23 @@ class CuraSceneNode(SceneNode): self._aabb = None if self._mesh_data: self._aabb = self._mesh_data.getExtents(self.getWorldTransformation(copy = False)) - else: # If there is no mesh_data, use a bounding box that encompasses the local (0,0,0) - position = self.getWorldPosition() - self._aabb = AxisAlignedBox(minimum = position, maximum = position) for child in self.getAllChildren(): if child.callDecoration("isNonPrintingMesh"): # Non-printing-meshes inside a group should not affect push apart or drop to build plate continue - if not child.getMeshData(): - # Nodes without mesh data should not affect bounding boxes of their parents. + if child.getBoundingBox().minimum == child.getBoundingBox().maximum: + # Child had a degenerate bounding box, such as an empty group. Don't count it along. continue if self._aabb is None: self._aabb = child.getBoundingBox() else: self._aabb = self._aabb + child.getBoundingBox() + if self._aabb is None: # No children that should be included? Just use your own position then, but it's an invalid AABB. + position = self.getWorldPosition() + self._aabb = AxisAlignedBox(minimum = position, maximum = position) + def __deepcopy__(self, memo: Dict[int, object]) -> "CuraSceneNode": """Taken from SceneNode, but replaced SceneNode with CuraSceneNode""" |