mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 13:59:02 +08:00
Platform physics now set the absolute position, instead of transforming in local space
This fixes issues with 3MF, which don't share the same local coordinate space. CURA-382
This commit is contained in:
parent
70a33d9dc5
commit
75be8080ec
@ -3,21 +3,22 @@
|
|||||||
|
|
||||||
from UM.Operations.Operation import Operation
|
from UM.Operations.Operation import Operation
|
||||||
from UM.Operations.GroupedOperation import GroupedOperation
|
from UM.Operations.GroupedOperation import GroupedOperation
|
||||||
|
from UM.Scene.SceneNode import SceneNode
|
||||||
|
|
||||||
## A specialised operation designed specifically to modify the previous operation.
|
## A specialised operation designed specifically to modify the previous operation.
|
||||||
class PlatformPhysicsOperation(Operation):
|
class PlatformPhysicsOperation(Operation):
|
||||||
def __init__(self, node, translation):
|
def __init__(self, node, translation):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._node = node
|
self._node = node
|
||||||
self._old_position = node.getPosition()
|
self._old_transformation = node.getLocalTransformation()
|
||||||
self._new_position = node.getPosition() + translation
|
self._translation = translation
|
||||||
self._always_merge = True
|
self._always_merge = True
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._node.setPosition(self._old_position)
|
self._node.setTransformation(self._old_transformation)
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._node.setPosition(self._new_position)
|
self._node.translate(self._translation, SceneNode.TransformSpace.World)
|
||||||
|
|
||||||
def mergeWith(self, other):
|
def mergeWith(self, other):
|
||||||
group = GroupedOperation()
|
group = GroupedOperation()
|
||||||
@ -28,4 +29,4 @@ class PlatformPhysicsOperation(Operation):
|
|||||||
return group
|
return group
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "PlatformPhysicsOperation(new_position = {0})".format(self._new_position)
|
return "PlatformPhysicsOperation(translation = {0})".format(self._translation)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user