mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-21 13:16:49 +01:00
Rework mdr ed's gizmo so it's able to handle rect style selection later.
This commit is contained in:
parent
6f8525a44b
commit
44f3ab6c5e
@ -40,11 +40,14 @@ var visual_indicator_outline : bool = true
|
||||
var visual_indicator_seam : bool= true
|
||||
var visual_indicator_handle : bool = true
|
||||
|
||||
|
||||
var previous_point : Vector2
|
||||
var is_dragging : bool = false
|
||||
var _last_known_camera_facing : Vector3 = Vector3(0, 0, -1)
|
||||
|
||||
var _rect_drag : bool = false
|
||||
var _rect_drag_start_point : Vector2 = Vector2()
|
||||
var _rect_drag_min_ofset : float = 10
|
||||
|
||||
var _mdr : MeshDataResource = null
|
||||
|
||||
var _vertices : PoolVector3Array
|
||||
@ -208,12 +211,32 @@ func forward_spatial_gui_input(index, camera, event):
|
||||
var grab_threshold : float = 8
|
||||
|
||||
if event.get_button_index() == BUTTON_LEFT:
|
||||
if event.is_pressed():
|
||||
var mouse_pos = event.get_position()
|
||||
if !event.is_pressed():
|
||||
# If a handle was being dragged only run these
|
||||
is_dragging = false
|
||||
|
||||
# if (_gizmo_select(p_index, _edit.mouse_pos))
|
||||
# return true;
|
||||
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()
|
||||
|
||||
if _handle_drag_op:
|
||||
_handle_drag_op = false
|
||||
return true
|
||||
|
||||
# See whether we should check for a click or a selection box
|
||||
var mouse_pos : Vector2 = event.get_position()
|
||||
var rect_size : Vector2 = _rect_drag_start_point - mouse_pos
|
||||
rect_size.x = abs(rect_size.x)
|
||||
rect_size.y = abs(rect_size.y)
|
||||
var had_rect_drag : bool = false
|
||||
|
||||
if rect_size.x > _rect_drag_min_ofset || rect_size.y > _rect_drag_min_ofset:
|
||||
had_rect_drag = true
|
||||
|
||||
# Click
|
||||
if !had_rect_drag:
|
||||
# select vertex
|
||||
var closest_idx : int = -1
|
||||
var closest_dist : float = 1e10
|
||||
@ -262,16 +285,13 @@ func forward_spatial_gui_input(index, camera, event):
|
||||
_selected_points.resize(0)
|
||||
|
||||
redraw()
|
||||
#Rect drag
|
||||
else:
|
||||
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
|
||||
pass
|
||||
else:
|
||||
# event is pressed
|
||||
_rect_drag = true
|
||||
_rect_drag_start_point = event.get_position()
|
||||
|
||||
# elif event is InputEventMouseMotion:
|
||||
# if edit_mode == EditMode.EDIT_MODE_NONE:
|
||||
|
Loading…
Reference in New Issue
Block a user