Fix rectangle selection clipping

This commit is contained in:
Manolis Papadeas 2021-02-16 01:21:56 +02:00
parent cc69730eff
commit 5160c74e99

View file

@ -202,6 +202,8 @@ func select_rect(merge := true) -> void:
queue_free()
return
merge_multiple_selections(merge)
if not merge:
queue_free()
# var undo_data = _get_undo_data(false)
# Global.current_project.selected_rect = _selected_rect
# commit_undo("Rectangle Select", undo_data)
@ -226,13 +228,15 @@ func merge_multiple_selections(merge := true) -> void:
self.local_selected_pixels = selected_pixels_copy
else:
var arr = Geometry.clip_polygons_2d(selection.polygon, polygon)
if arr.size() == 1: # if the selections intersect
if arr.size() == 0: # if the new selection completely overlaps the current
selection.queue_free()
elif arr.size() == 1: # if the selections intersect
selection.set_polygon(arr[0])
var selected_pixels_copy = selection.local_selected_pixels.duplicate()
for pixel in local_selected_pixels:
selected_pixels_copy.erase(pixel)
selection.local_selected_pixels = selected_pixels_copy
queue_free()
func move_start(move_pixel : bool) -> void:
if not move_pixel: