Skip to content

Commit

Permalink
Fix for Eraser issue, with too big eraser radius (#324)
Browse files Browse the repository at this point in the history
* Fixed eraser issue, that small strokes cannot be removed with a big eraser radius.

* Reactivated the old logic for intersection check, becuase in case of a big brush and zoomed out and a small eraser it would not work anymore.
  • Loading branch information
tafode authored Jan 13, 2025
1 parent c3cfed2 commit 568f55d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lorien/InfiniteCanvas/Tools/EraserTool.gd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func _stroke_intersects_circle(stroke: BrushStroke, circle_position: Vector2) ->
var bounding_box: Rect2 = _bounding_box_cache[stroke]
if !bounding_box.has_point(_last_mouse_position):
return false

# Check every segment of the brush stroke for an intersection with the curser
var eraser_brush_radius := float(_cursor._brush_size) * 0.5
for i: int in stroke.points.size() - 1:
Expand All @@ -44,8 +43,13 @@ func _stroke_intersects_circle(stroke: BrushStroke, circle_position: Vector2) ->
var radius := segment_radius + eraser_brush_radius
var start := stroke.position + stroke.points[i]
var end := stroke.position + stroke.points[i+1]

if Geometry2D.segment_intersects_circle(start, end, circle_position, radius*OVERLAP_THRESHOLD) >= 0:
return true

if Geometry2D.is_point_in_circle(stroke.points[i], circle_position, radius*OVERLAP_THRESHOLD):
return true

return false

# -------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 568f55d

Please sign in to comment.