Skip to content

Commit b583b33

Browse files
committed
Refactor cursor motion threshold constants
1 parent 5ccd196 commit b583b33

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

crates/rendering/src/layers/cursor.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const CLICK_SHRINK_SIZE: f32 = 0.7;
1717
const CURSOR_IDLE_MIN_DELAY_MS: f64 = 500.0;
1818
const CURSOR_IDLE_FADE_OUT_MS: f64 = 400.0;
1919
const CURSOR_VECTOR_CAP: f32 = 320.0;
20-
const CURSOR_MIN_MOTION: f32 = 0.01;
20+
const CURSOR_MIN_MOTION_NORMALIZED: f32 = 0.01;
21+
const CURSOR_MIN_MOTION_PX: f32 = 1.0;
2122
const CURSOR_BASELINE_FPS: f32 = 60.0;
2223
const CURSOR_MULTIPLIER: f32 = 3.0;
2324
const CURSOR_MAX_STRENGTH: f32 = 5.0;
@@ -243,7 +244,8 @@ impl CursorLayer {
243244
let normalized_motion = ((combined_motion_px.x / screen_diag).powi(2)
244245
+ (combined_motion_px.y / screen_diag).powi(2))
245246
.sqrt();
246-
let has_motion = normalized_motion > CURSOR_MIN_MOTION && cursor_strength > f32::EPSILON;
247+
let has_motion =
248+
normalized_motion > CURSOR_MIN_MOTION_NORMALIZED && cursor_strength > f32::EPSILON;
247249
let scaled_motion = if has_motion {
248250
clamp_cursor_vector(combined_motion_px * cursor_strength)
249251
} else {
@@ -439,8 +441,8 @@ impl CursorLayer {
439441

440442
fn combine_cursor_motion(parent: XY<f32>, child: XY<f32>) -> XY<f32> {
441443
fn combine_axis(parent: f32, child: f32) -> f32 {
442-
if parent.abs() > CURSOR_MIN_MOTION
443-
&& child.abs() > CURSOR_MIN_MOTION
444+
if parent.abs() > CURSOR_MIN_MOTION_PX
445+
&& child.abs() > CURSOR_MIN_MOTION_PX
444446
&& parent.signum() != child.signum()
445447
{
446448
0.0

0 commit comments

Comments
 (0)