Fixed merging for already grouped objects

This commit is contained in:
Jaime van Kessel 2016-11-07 11:19:03 +01:00
parent 8503492b4d
commit e7df64da8b

View File

@ -866,7 +866,7 @@ class CuraApplication(QtApplication):
return
# Compute the center of the objects when their origins are aligned.
object_centers = [node.getMeshData().getCenterPosition().scale(node.getScale()) for node in group_node.getChildren() if node.getMeshData()]
object_centers = [node.getBoundingBox().center for node in group_node.getChildren()]
if object_centers and len(object_centers) > 0:
middle_x = sum([v.x for v in object_centers]) / len(object_centers)
middle_y = sum([v.y for v in object_centers]) / len(object_centers)
@ -874,11 +874,10 @@ class CuraApplication(QtApplication):
offset = Vector(middle_x, middle_y, middle_z)
else:
offset = Vector(0, 0, 0)
# Move each node to the same position.
for center, node in zip(object_centers, group_node.getChildren()):
# Align the object and also apply the offset to center it inside the group.
node.setPosition(center - offset)
node.translate(-1 * (center - offset), SceneNode.TransformSpace.World)
# Use the previously found center of the group bounding box as the new location of the group
group_node.setPosition(group_node.getBoundingBox().center)