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_seam : bool= true
|
||||||
var visual_indicator_handle : bool = true
|
var visual_indicator_handle : bool = true
|
||||||
|
|
||||||
|
|
||||||
var previous_point : Vector2
|
var previous_point : Vector2
|
||||||
var is_dragging : bool = false
|
var is_dragging : bool = false
|
||||||
var _last_known_camera_facing : Vector3 = Vector3(0, 0, -1)
|
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 _mdr : MeshDataResource = null
|
||||||
|
|
||||||
var _vertices : PoolVector3Array
|
var _vertices : PoolVector3Array
|
||||||
@ -208,12 +211,32 @@ func forward_spatial_gui_input(index, camera, event):
|
|||||||
var grab_threshold : float = 8
|
var grab_threshold : float = 8
|
||||||
|
|
||||||
if event.get_button_index() == BUTTON_LEFT:
|
if event.get_button_index() == BUTTON_LEFT:
|
||||||
if event.is_pressed():
|
if !event.is_pressed():
|
||||||
var mouse_pos = event.get_position()
|
# If a handle was being dragged only run these
|
||||||
|
is_dragging = false
|
||||||
|
|
||||||
# if (_gizmo_select(p_index, _edit.mouse_pos))
|
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():
|
||||||
# return true;
|
_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
|
# select vertex
|
||||||
var closest_idx : int = -1
|
var closest_idx : int = -1
|
||||||
var closest_dist : float = 1e10
|
var closest_dist : float = 1e10
|
||||||
@ -262,16 +285,13 @@ func forward_spatial_gui_input(index, camera, event):
|
|||||||
_selected_points.resize(0)
|
_selected_points.resize(0)
|
||||||
|
|
||||||
redraw()
|
redraw()
|
||||||
|
#Rect drag
|
||||||
else:
|
else:
|
||||||
is_dragging = false
|
pass
|
||||||
|
else:
|
||||||
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():
|
# event is pressed
|
||||||
_undo_redo.create_action("Drag")
|
_rect_drag = true
|
||||||
_undo_redo.add_do_method(self, "apply_vertex_array", _mdr, _mdr.array[ArrayMesh.ARRAY_VERTEX])
|
_rect_drag_start_point = event.get_position()
|
||||||
_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:
|
||||||
|
Loading…
Reference in New Issue
Block a user