From 68818a525d966e0260571e2a9cae0ae5d36d6afe Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Tue, 5 Dec 2023 13:53:30 +0100 Subject: [PATCH 1/5] Use absolute transform coordinates instead of relative CURA-11279 --- cura/Arranging/GridArrange.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cura/Arranging/GridArrange.py b/cura/Arranging/GridArrange.py index f3c5f3a1a9..be6b36cc5a 100644 --- a/cura/Arranging/GridArrange.py +++ b/cura/Arranging/GridArrange.py @@ -242,13 +242,9 @@ class GridArrange(Arranger): center_grid_y = coord_grid_y + (0.5 * self._grid_height) bounding_box = node.getBoundingBox() - center_node_x = (bounding_box.left + bounding_box.right) * 0.5 - center_node_y = (bounding_box.back + bounding_box.front) * 0.5 + center_node_z = bounding_box.height / 2 - delta_x = center_grid_x - center_node_x - delta_y = center_grid_y - center_node_y - - return TranslateOperation(node, Vector(delta_x, 0, delta_y)) + return TranslateOperation(node, Vector(center_grid_x, center_node_z, center_grid_y), True) def _getGridCornerPoints( self, From 9a108dc7205cda8983faafe6576c055f0b613e66 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Tue, 5 Dec 2023 14:41:15 +0100 Subject: [PATCH 2/5] Set explicit parameter name Co-authored-by: Casper Lamboo --- cura/Arranging/GridArrange.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/Arranging/GridArrange.py b/cura/Arranging/GridArrange.py index be6b36cc5a..c30b5c897f 100644 --- a/cura/Arranging/GridArrange.py +++ b/cura/Arranging/GridArrange.py @@ -244,7 +244,7 @@ class GridArrange(Arranger): bounding_box = node.getBoundingBox() center_node_z = bounding_box.height / 2 - return TranslateOperation(node, Vector(center_grid_x, center_node_z, center_grid_y), True) + return TranslateOperation(node, Vector(center_grid_x, center_node_z, center_grid_y), set_position = True) def _getGridCornerPoints( self, From 0353037b31cfd715bc01193ca676f871d2373515 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 6 Dec 2023 11:36:54 +0100 Subject: [PATCH 3/5] Use `getWorldPosition` for `TranslateOperation` CURA-11279 --- cura/Arranging/GridArrange.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cura/Arranging/GridArrange.py b/cura/Arranging/GridArrange.py index c30b5c897f..13778e9de9 100644 --- a/cura/Arranging/GridArrange.py +++ b/cura/Arranging/GridArrange.py @@ -241,10 +241,8 @@ class GridArrange(Arranger): center_grid_x = coord_grid_x + (0.5 * self._grid_width) center_grid_y = coord_grid_y + (0.5 * self._grid_height) - bounding_box = node.getBoundingBox() - center_node_z = bounding_box.height / 2 - - return TranslateOperation(node, Vector(center_grid_x, center_node_z, center_grid_y), set_position = True) + return TranslateOperation(node, Vector(center_grid_x, node.getWorldPosition().y, center_grid_y), + set_position=True) def _getGridCornerPoints( self, From 920809f064d39f2426312428a02c7db0b3c4410d Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 6 Dec 2023 11:40:34 +0100 Subject: [PATCH 4/5] 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( From 237d1a899baa03da667b72a7cc5be395b65e2dc5 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 6 Dec 2023 12:10:34 +0100 Subject: [PATCH 5/5] Revert "Use absolute transformation to set location for arrange" This reverts commit 920809f064d39f2426312428a02c7db0b3c4410d. --- cura/Arranging/Nest2DArrange.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/cura/Arranging/Nest2DArrange.py b/cura/Arranging/Nest2DArrange.py index a67d04aa8c..968522d5a3 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.SetTransformOperation import SetTransformOperation +from UM.Operations.RotateOperation import RotateOperation from UM.Operations.TranslateOperation import TranslateOperation from cura.Arranging.Arranger import Arranger @@ -140,17 +140,13 @@ 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)) - - 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(RotateOperation(node, Quaternion.fromMatrix(rotation_matrix))) grouped_operation.addOperation( - SetTransformOperation(node, orientation=orientation, translation=translation)) + TranslateOperation(node, Vector(node_item.translation().x() / self._factor, 0, + node_item.translation().y() / self._factor))) else: # We didn't find a spot grouped_operation.addOperation(