From 920809f064d39f2426312428a02c7db0b3c4410d Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 6 Dec 2023 11:40:34 +0100 Subject: [PATCH] Use absolute transformation to set location for arrange Using relative positioning proved to create issues; when spamming of arrange instructions it was possible to end up in the following time line 1: arrange action a is started 2: arrange action b is started 3: arrange action a finished computation, and applies transformations on the models 4: arrange action b finishes computation and applies relative transformations on top of the previous transformations By using absolute positioning this issue is resolved CURA-11279 --- cura/Arranging/Nest2DArrange.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cura/Arranging/Nest2DArrange.py b/cura/Arranging/Nest2DArrange.py index 968522d5a3..a67d04aa8c 100644 --- a/cura/Arranging/Nest2DArrange.py +++ b/cura/Arranging/Nest2DArrange.py @@ -14,7 +14,7 @@ from UM.Math.Quaternion import Quaternion from UM.Math.Vector import Vector from UM.Operations.AddSceneNodeOperation import AddSceneNodeOperation from UM.Operations.GroupedOperation import GroupedOperation -from UM.Operations.RotateOperation import RotateOperation +from UM.Operations.SetTransformOperation import SetTransformOperation from UM.Operations.TranslateOperation import TranslateOperation from cura.Arranging.Arranger import Arranger @@ -140,13 +140,17 @@ class Nest2DArrange(Arranger): grouped_operation.addOperation(AddSceneNodeOperation(node, scene_root)) if node_item.binId() == 0: - # We found a spot for it rotation_matrix = Matrix() rotation_matrix.setByRotationAxis(node_item.rotation(), Vector(0, -1, 0)) - grouped_operation.addOperation(RotateOperation(node, Quaternion.fromMatrix(rotation_matrix))) + + orientation = node.getWorldOrientation() * Quaternion.fromMatrix(rotation_matrix) + translation = node.getWorldPosition().preMultiply(rotation_matrix) + Vector( + node_item.translation().x() / self._factor, + 0, + node_item.translation().y() / self._factor + ) grouped_operation.addOperation( - TranslateOperation(node, Vector(node_item.translation().x() / self._factor, 0, - node_item.translation().y() / self._factor))) + SetTransformOperation(node, orientation=orientation, translation=translation)) else: # We didn't find a spot grouped_operation.addOperation(