mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Moved the selection codes to their own methods.
This commit is contained in:
parent
f71d65be85
commit
0d45bd0f97
@ -201,42 +201,13 @@ func select_all() -> void:
|
||||
|
||||
redraw()
|
||||
|
||||
func forward_spatial_gui_input(index, camera, event):
|
||||
_last_known_camera_facing = camera.transform.basis.xform(Vector3(0, 0, -1))
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
func selection_click_select_through(index, camera, event):
|
||||
var gt : Transform = get_spatial_node().global_transform
|
||||
var ray_from : Vector3 = camera.global_transform.origin
|
||||
var gpoint : Vector2 = event.get_position()
|
||||
var grab_threshold : float = 8
|
||||
|
||||
if event.get_button_index() == BUTTON_LEFT:
|
||||
if !event.is_pressed():
|
||||
# If a handle was being dragged only run these
|
||||
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()
|
||||
|
||||
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
|
||||
@ -285,9 +256,15 @@ func forward_spatial_gui_input(index, camera, event):
|
||||
_selected_points.resize(0)
|
||||
|
||||
redraw()
|
||||
#Rect drag
|
||||
else:
|
||||
# Always return false here, so the drag rect thing disappears in the editor
|
||||
|
||||
func selection_drag_rect_select_through(index, camera, event):
|
||||
var gt : Transform = get_spatial_node().global_transform
|
||||
|
||||
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 rect : Rect2 = Rect2(_rect_drag_start_point, rect_size)
|
||||
|
||||
# This is needed so selection works even when you drag from bottom to top, and from right to left
|
||||
@ -316,7 +293,7 @@ func forward_spatial_gui_input(index, camera, event):
|
||||
break
|
||||
redraw()
|
||||
|
||||
return false
|
||||
return
|
||||
|
||||
if event.shift:
|
||||
for isel in selected:
|
||||
@ -324,12 +301,47 @@ func forward_spatial_gui_input(index, camera, event):
|
||||
_selected_points.push_back(isel)
|
||||
|
||||
redraw()
|
||||
return false
|
||||
return
|
||||
|
||||
_selected_points.resize(0)
|
||||
_selected_points.append_array(selected)
|
||||
|
||||
redraw()
|
||||
|
||||
func forward_spatial_gui_input(index, camera, event):
|
||||
_last_known_camera_facing = camera.transform.basis.xform(Vector3(0, 0, -1))
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.get_button_index() == BUTTON_LEFT:
|
||||
if !event.is_pressed():
|
||||
# If a handle was being dragged only run these
|
||||
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()
|
||||
|
||||
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
|
||||
|
||||
if !had_rect_drag:
|
||||
return selection_click_select_through(index, camera, event)
|
||||
else:
|
||||
selection_drag_rect_select_through(index, camera, event)
|
||||
# Always return false here, so the drag rect thing disappears in the editor
|
||||
return false
|
||||
else:
|
||||
# event is pressed
|
||||
|
Loading…
Reference in New Issue
Block a user