Skip to content

Commit

Permalink
Use absolute transformation to set location for arrange
Browse files Browse the repository at this point in the history
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
  • Loading branch information
casperlamboo committed Dec 6, 2023
1 parent 0353037 commit 920809f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cura/Arranging/Nest2DArrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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

Expand Down Expand Up @@ -140,13 +140,17 @@ def createGroupOperationForArrange(self, add_new_nodes_in_scene: bool = False) -
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(
Expand Down

0 comments on commit 920809f

Please sign in to comment.