feat(studio,stacking,animations,collections): M16 ModBison Studio, object stacking, model animations, and poly collections for MVP 2
checkpoint / checkpoint (push) Successful in 6m32s
checkpoint / checkpoint (push) Successful in 6m32s
This commit is contained in:
@@ -27,8 +27,28 @@ func apply(core: EditorCore, args: Dictionary) -> Variant:
|
||||
|
||||
match op:
|
||||
"move":
|
||||
return _apply_vector3(core, object_id, args.get("value", obj.position),
|
||||
obj.position, "Move", core.model.set_object_position_raw)
|
||||
var new_val: Vector3 = args.get("value", obj.position)
|
||||
var old_val: Vector3 = obj.position
|
||||
var delta: Vector3 = new_val - old_val
|
||||
if new_val.is_equal_approx(old_val):
|
||||
return false
|
||||
var children_snapshots: Array = []
|
||||
for child in core.model.payload.objects:
|
||||
if child.properties is Dictionary and child.properties.get("parent_id") == object_id:
|
||||
children_snapshots.append({"id": child.id, "old_pos": child.position, "new_pos": child.position + delta})
|
||||
core.undo_redo.begin("Move '%s'" % object_id)
|
||||
core.undo_redo.add_do(func():
|
||||
core.model.set_object_position_raw(object_id, new_val)
|
||||
for cs in children_snapshots:
|
||||
core.model.set_object_position_raw(cs["id"], cs["new_pos"])
|
||||
)
|
||||
core.undo_redo.add_undo(func():
|
||||
core.model.set_object_position_raw(object_id, old_val)
|
||||
for cs in children_snapshots:
|
||||
core.model.set_object_position_raw(cs["id"], cs["old_pos"])
|
||||
)
|
||||
core.undo_redo.commit()
|
||||
return true
|
||||
"rotate":
|
||||
return _apply_vector4(core, object_id, args.get("value", obj.rotation),
|
||||
obj.rotation, "Rotate", core.model.set_object_rotation_raw)
|
||||
|
||||
Reference in New Issue
Block a user