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
This commit is contained in:
c.lamboo 2023-12-06 11:40:34 +01:00
parent 0353037b31
commit 920809f064

View file

@ -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(