From 26cb9311f6014a3634a3d7a0b4b0b6848687f5f3 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Sat, 25 Jun 2022 18:24:11 +0300 Subject: [PATCH] Fix intersections --- src/Tools/SelectionTools/ColorSelect.gd | 3 ++- src/Tools/SelectionTools/EllipseSelect.gd | 3 ++- src/Tools/SelectionTools/Lasso.gd | 4 ++-- src/Tools/SelectionTools/MagicWand.gd | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Tools/SelectionTools/ColorSelect.gd b/src/Tools/SelectionTools/ColorSelect.gd index 9deb3d3e7a3..e88a029c3cd 100644 --- a/src/Tools/SelectionTools/ColorSelect.gd +++ b/src/Tools/SelectionTools/ColorSelect.gd @@ -25,7 +25,8 @@ func apply_selection(position: Vector2) -> void: var pos := Vector2(x, y) if color.is_equal_approx(cel_image.get_pixelv(pos)): if _intersect: - selection_map_copy.select_pixel(pos, selection_map_copy.is_pixel_selected(pos)) + var selected: bool = project.selection_map.is_pixel_selected(pos) + selection_map_copy.select_pixel(pos, selected) else: selection_map_copy.select_pixel(pos, !_subtract) diff --git a/src/Tools/SelectionTools/EllipseSelect.gd b/src/Tools/SelectionTools/EllipseSelect.gd index c5a47720b37..7917000ee1d 100644 --- a/src/Tools/SelectionTools/EllipseSelect.gd +++ b/src/Tools/SelectionTools/EllipseSelect.gd @@ -111,6 +111,7 @@ func apply_selection(_position: Vector2) -> void: func set_ellipse(selection_map: SelectionMap, position: Vector2) -> void: + var project: Project = Global.current_project var bitmap_size: Vector2 = selection_map.get_size() if _intersect: selection_map.clear() @@ -120,7 +121,7 @@ func set_ellipse(selection_map: SelectionMap, position: Vector2) -> void: if pos.x < 0 or pos.y < 0 or pos.x >= bitmap_size.x or pos.y >= bitmap_size.y: continue if _intersect: - if selection_map.is_pixel_selected(pos): + if project.selection_map.is_pixel_selected(pos): selection_map.select_pixel(pos, true) else: selection_map.select_pixel(pos, !_subtract) diff --git a/src/Tools/SelectionTools/Lasso.gd b/src/Tools/SelectionTools/Lasso.gd index bc7f5f46585..15b040e06f5 100644 --- a/src/Tools/SelectionTools/Lasso.gd +++ b/src/Tools/SelectionTools/Lasso.gd @@ -109,7 +109,7 @@ func lasso_selection(selection_map: SelectionMap, points: PoolVector2Array) -> v if point.x < 0 or point.y < 0 or point.x >= size.x or point.y >= size.y: continue if _intersect: - if selection_map.is_pixel_selected(point): + if project.selection_map.is_pixel_selected(point): selection_map.select_pixel(point, true) else: selection_map.select_pixel(point, !_subtract) @@ -122,7 +122,7 @@ func lasso_selection(selection_map: SelectionMap, points: PoolVector2Array) -> v v.y = y if Geometry.is_point_in_polygon(v, points): if _intersect: - if selection_map.is_pixel_selected(v): + if project.selection_map.is_pixel_selected(v): selection_map.select_pixel(v, true) else: selection_map.select_pixel(v, !_subtract) diff --git a/src/Tools/SelectionTools/MagicWand.gd b/src/Tools/SelectionTools/MagicWand.gd index 90ec7453753..cf331084726 100644 --- a/src/Tools/SelectionTools/MagicWand.gd +++ b/src/Tools/SelectionTools/MagicWand.gd @@ -182,7 +182,8 @@ func _select_segments(selection_map: SelectionMap) -> void: func _set_bit(p: Vector2, selection_map: SelectionMap) -> void: + var project: Project = Global.current_project if _intersect: - selection_map.select_pixel(p, selection_map.is_pixel_selected(p)) + selection_map.select_pixel(p, project.selection_map.is_pixel_selected(p)) else: selection_map.select_pixel(p, !_subtract)