mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Added undo redo support for mdr ed's handle operations.
This commit is contained in:
parent
3337cfdc3c
commit
3a6c705201
@ -43,6 +43,9 @@ var _selected_points : PoolIntArray
|
|||||||
|
|
||||||
var _mesh_outline_generator
|
var _mesh_outline_generator
|
||||||
|
|
||||||
|
var _handle_drag_op : bool = false
|
||||||
|
var _drag_op_orig_verices : PoolVector3Array = PoolVector3Array()
|
||||||
|
|
||||||
var _editor_plugin : EditorPlugin = null
|
var _editor_plugin : EditorPlugin = null
|
||||||
var _undo_redo : UndoRedo = null
|
var _undo_redo : UndoRedo = null
|
||||||
|
|
||||||
@ -64,6 +67,9 @@ func set_handle(index: int, camera: Camera, point: Vector2):
|
|||||||
if !is_dragging:
|
if !is_dragging:
|
||||||
relative = Vector2()
|
relative = Vector2()
|
||||||
is_dragging = true
|
is_dragging = true
|
||||||
|
|
||||||
|
_handle_drag_op = true
|
||||||
|
_drag_op_orig_verices = copy_mdr_verts_array()
|
||||||
|
|
||||||
if edit_mode == EditMode.EDIT_MODE_NONE:
|
if edit_mode == EditMode.EDIT_MODE_NONE:
|
||||||
return
|
return
|
||||||
@ -213,7 +219,15 @@ func forward_spatial_gui_input(index, camera, event):
|
|||||||
redraw()
|
redraw()
|
||||||
else:
|
else:
|
||||||
is_dragging = false
|
is_dragging = false
|
||||||
|
|
||||||
|
if _handle_drag_op && _mdr && _mdr.array.size() == ArrayMesh.ARRAY_MAX && _mdr.array[ArrayMesh.ARRAY_VERTEX] != null && _mdr.array[ArrayMesh.ARRAY_VERTEX].size() == _drag_op_orig_verices.size():
|
||||||
|
_undo_redo.create_action("Drag")
|
||||||
|
_undo_redo.add_do_method(self, "apply_vertex_array", _mdr, _mdr.array[ArrayMesh.ARRAY_VERTEX])
|
||||||
|
_undo_redo.add_undo_method(self, "apply_vertex_array", _mdr, _drag_op_orig_verices)
|
||||||
|
_undo_redo.commit_action()
|
||||||
|
|
||||||
|
_handle_drag_op = false
|
||||||
|
|
||||||
# elif event is InputEventMouseMotion:
|
# elif event is InputEventMouseMotion:
|
||||||
# if edit_mode == EditMode.EDIT_MODE_NONE:
|
# if edit_mode == EditMode.EDIT_MODE_NONE:
|
||||||
# return false
|
# return false
|
||||||
@ -649,7 +663,7 @@ func create_face():
|
|||||||
return
|
return
|
||||||
|
|
||||||
if selection_mode == SelectionMode.SELECTION_MODE_VERTEX:
|
if selection_mode == SelectionMode.SELECTION_MODE_VERTEX:
|
||||||
_mdr.disconnect("changed", self, "on_mdr_changed")
|
disable_change_event()
|
||||||
|
|
||||||
var points : PoolVector3Array = PoolVector3Array()
|
var points : PoolVector3Array = PoolVector3Array()
|
||||||
|
|
||||||
@ -658,9 +672,10 @@ func create_face():
|
|||||||
|
|
||||||
MDRMeshUtils.add_triangulated_mesh_from_points(_mdr, points, _last_known_camera_facing)
|
MDRMeshUtils.add_triangulated_mesh_from_points(_mdr, points, _last_known_camera_facing)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_selected_points.resize(0)
|
_selected_points.resize(0)
|
||||||
_mdr.connect("changed", self, "on_mdr_changed")
|
enable_change_event()
|
||||||
on_mdr_changed()
|
|
||||||
elif selection_mode == SelectionMode.SELECTION_MODE_EDGE:
|
elif selection_mode == SelectionMode.SELECTION_MODE_EDGE:
|
||||||
pass
|
pass
|
||||||
elif selection_mode == SelectionMode.SELECTION_MODE_FACE:
|
elif selection_mode == SelectionMode.SELECTION_MODE_FACE:
|
||||||
@ -1114,6 +1129,18 @@ func apply_mesh_change(mdr : MeshDataResource, arr : Array) -> void:
|
|||||||
|
|
||||||
mdr.array = copy_arrays(arr)
|
mdr.array = copy_arrays(arr)
|
||||||
|
|
||||||
|
func apply_vertex_array(mdr : MeshDataResource, verts : PoolVector3Array) -> void:
|
||||||
|
if !mdr:
|
||||||
|
return
|
||||||
|
|
||||||
|
var mdr_arr : Array = mdr.array
|
||||||
|
|
||||||
|
if mdr_arr.size() != ArrayMesh.ARRAY_MAX:
|
||||||
|
return
|
||||||
|
|
||||||
|
mdr_arr[ArrayMesh.ARRAY_VERTEX] = verts
|
||||||
|
mdr.array = mdr_arr
|
||||||
|
|
||||||
func copy_arrays(arr : Array) -> Array:
|
func copy_arrays(arr : Array) -> Array:
|
||||||
return arr.duplicate(true)
|
return arr.duplicate(true)
|
||||||
|
|
||||||
@ -1125,3 +1152,19 @@ func copy_pool_int_array(pia : PoolIntArray) -> PoolIntArray:
|
|||||||
ret[i] = pia[i]
|
ret[i] = pia[i]
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
func copy_mdr_verts_array() -> PoolVector3Array:
|
||||||
|
var ret : PoolVector3Array = PoolVector3Array()
|
||||||
|
|
||||||
|
if !_mdr:
|
||||||
|
return ret
|
||||||
|
|
||||||
|
var mdr_arr : Array = _mdr.array
|
||||||
|
|
||||||
|
if mdr_arr.size() != ArrayMesh.ARRAY_MAX || mdr_arr[ArrayMesh.ARRAY_VERTEX] == null || mdr_arr[ArrayMesh.ARRAY_VERTEX].size() == 0:
|
||||||
|
return ret
|
||||||
|
|
||||||
|
var vertices : PoolVector3Array = mdr_arr[ArrayMesh.ARRAY_VERTEX]
|
||||||
|
ret.append_array(vertices)
|
||||||
|
|
||||||
|
return ret
|
||||||
|
Loading…
Reference in New Issue
Block a user