Skip to content

Commit

Permalink
Fix slider incorrect comparison
Browse files Browse the repository at this point in the history
Resulted in divide by zeros and incorrect behavior
  • Loading branch information
squidt committed Nov 18, 2024
1 parent e46ca49 commit 1158558
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addons/godot-xr-tools/interactables/interactable_slider.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ signal slider_moved(offset: float)

## Signal for slider moved
## Slider step size (zero for no steps)
@export var slider_steps : float = 0.0
@export var slider_steps : float = 0.0:
set(v):
slider_steps = maxf(v, 0)

## Slider position - move to test the position setup
@export var slider_position : float = 0.0:
set(v):
# Apply slider step-quantization
if is_zero_approx(slider_steps):
if !is_zero_approx(slider_steps):
v = roundf(v / slider_steps) * slider_steps

# Clamp position
Expand Down

0 comments on commit 1158558

Please sign in to comment.