Also remove other transformations when getting the center position

The other transformations, in particular rotation, were also influencing the merge. The transformations were not removed when calculating the center position, causing the center position of a mesh to be calculating differently. When the meshes were actually transformed/moved, all of the transformations were removed but this gave the model a different center position. The different center position wasn't properly being compensated for using the previously calculated center position.

Fixes CURA-7873.
This commit is contained in:
Ghostkeeper 2021-05-21 13:45:51 +02:00
parent 6eeb135672
commit 48d1715c2d
No known key found for this signature in database
GPG Key ID: D2A8871EE34EC59A

View File

@ -1526,12 +1526,8 @@ class CuraApplication(QtApplication):
# Compute the center of the objects # Compute the center of the objects
object_centers = [] object_centers = []
# Forget about the translation that the original objects have
zero_translation = Matrix(data=numpy.zeros(3))
for mesh, node in zip(meshes, group_node.getChildren()): for mesh, node in zip(meshes, group_node.getChildren()):
transformation = node.getLocalTransformation() transformed_mesh = mesh.getTransformed(Matrix()) # Forget about the transformations that the original object had.
transformation.setTranslation(zero_translation)
transformed_mesh = mesh.getTransformed(transformation)
center = transformed_mesh.getCenterPosition() center = transformed_mesh.getCenterPosition()
if center is not None: if center is not None:
object_centers.append(center) object_centers.append(center)
@ -1546,7 +1542,7 @@ class CuraApplication(QtApplication):
# Move each node to the same position. # Move each node to the same position.
for mesh, node in zip(meshes, group_node.getChildren()): for mesh, node in zip(meshes, group_node.getChildren()):
node.setTransformation(Matrix()) node.setTransformation(Matrix()) # Removes any changes in position and rotation.
# Align the object around its zero position # Align the object around its zero position
# and also apply the offset to center it inside the group. # and also apply the offset to center it inside the group.
node.setPosition(-mesh.getZeroPosition() - offset) node.setPosition(-mesh.getZeroPosition() - offset)