Perform Platform physics changes on scene changed again and use a custom operation for better op merging

This commit is contained in:
Arjen Hiemstra 2015-01-06 17:16:24 +01:00
parent bfa3c00200
commit e24c120e82
2 changed files with 35 additions and 16 deletions

View file

@ -0,0 +1,27 @@
from UM.Operations.Operation import Operation
from UM.Operations.AddSceneNodeOperation import AddSceneNodeOperation
from UM.Operations.TranslateOperation import TranslateOperation
## A specialised operation designed specifically to modify the previous operation.
class PlatformPhysicsOperation(Operation):
def __init__(self, node, translation):
super().__init__()
self._node = node
self._translation = translation
def undo(self):
pass
def redo(self):
pass
def mergeWith(self, other):
if type(other) is AddSceneNodeOperation:
other._node.translate(self._translation)
return other
elif type(other) is TranslateOperation:
other._translation += self._translation
return other
else:
return False