mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-05 13:03:59 -06:00
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.
This commit is contained in:
parent
cfb32bfd50
commit
6eeb135672
1 changed files with 6 additions and 5 deletions
|
@ -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"""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue