Skip to content

Commit

Permalink
Pen pressure bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrlabs committed Sep 29, 2024
1 parent afefe15 commit 5cbb73d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lorien/BrushStroke/BrushStroke.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class_name BrushStroke

# ------------------------------------------------------------------------------------------------
const MAX_POINTS := 1000
const MAX_PRESSURE_DIFF := 0.1
const MAX_PRESSURE_DIFF := 0.05
const MIN_PRESSURE_VALUE := 0.1
const MAX_PRESSURE_VALUE := 1.0
const COLLIDER_NODE_NAME := "StrokeCollider"
Expand Down
3 changes: 2 additions & 1 deletion lorien/BrushStroke/BrushStrokeOptimizer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class_name BrushStrokeOptimizer

# -------------------------------------------------------------------------------------------------
const ANGLE_THRESHOLD := 0.5
const MIN_DISTANCE := 8.0
const MIN_DISTANCE := 4.0

# -------------------------------------------------------------------------------------------------
var points_removed := 0
Expand All @@ -13,6 +13,7 @@ func reset() -> void:

# -------------------------------------------------------------------------------------------------
func optimize(s: BrushStroke) -> void:

if s.points.size() < 8:
return

Expand Down
6 changes: 3 additions & 3 deletions lorien/InfiniteCanvas/Tools/BrushTool.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ extends CanvasTool

# -------------------------------------------------------------------------------------------------
const MOVEMENT_THRESHOLD := 1.0
const MIN_PRESSURE := 0.25
const DOT_MAX_DISTANCE_THRESHOLD := 6.0

# -------------------------------------------------------------------------------------------------
Expand All @@ -18,9 +17,10 @@ var _last_accepted_position: Vector2
# -------------------------------------------------------------------------------------------------
func tool_event(event: InputEvent) -> void:
_cursor.set_pressure(1.0)

if event is InputEventMouseMotion:
_current_pressure = event.pressure
if _current_pressure < 0 || is_zero_approx(_current_pressure):
_current_pressure = 1.0

var screen := DisplayServer.screen_get_size()
var velocity: Vector2 = event.screen_velocity / Vector2(screen.x, screen.y)
Expand Down Expand Up @@ -52,7 +52,7 @@ func _process(delta: float) -> void:
_moved = false

var diff := pos.distance_squared_to(_last_accepted_position)
if diff <= MOVEMENT_THRESHOLD || _current_pressure <= MIN_PRESSURE:
if diff <= MOVEMENT_THRESHOLD:
return

# Stabilizer smoothing
Expand Down
8 changes: 4 additions & 4 deletions lorien/UI/Dialogs/SettingsDialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ func _set_languages(current_locale: String) -> void:
func _set_tablet_drivers(current_driver: String) -> void:
for i: int in DisplayServer.tablet_get_driver_count():
var driver := DisplayServer.tablet_get_driver_name(i)
if driver != "dummy":
_tablet_driver.add_item(driver)
if current_driver == driver:
_tablet_driver.selected = i

_tablet_driver.add_item(driver)
if current_driver == driver:
_tablet_driver.selected = i

#--------------------------------------------------------------------------------------------------
func _set_keybindings() -> void:
Expand Down

0 comments on commit 5cbb73d

Please sign in to comment.