From 1d00505ca7e6d8facd0cea131f1b01b97145e8f7 Mon Sep 17 00:00:00 2001 From: zypherift Date: Wed, 4 Mar 2026 23:09:27 +0100 Subject: [PATCH] edit: fine tune wall collision vibration --- firka/lib/ui/phone/screens/login/login_screen.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/firka/lib/ui/phone/screens/login/login_screen.dart b/firka/lib/ui/phone/screens/login/login_screen.dart index 86f62e0..b3e08ce 100644 --- a/firka/lib/ui/phone/screens/login/login_screen.dart +++ b/firka/lib/ui/phone/screens/login/login_screen.dart @@ -816,32 +816,42 @@ class _FloatingCardsSlideState extends State<_FloatingCardsSlide> double vx = _velocities[i].dx; double vy = _velocities[i].dy; + // capture incoming velocity components before any bounce damping + final double preVx = vx; + final double preVy = vy; + double impactSpeed = 0.0; // normal to the wall + bool hit = false; if (pos.dx < minX) { pos = Offset(minX, pos.dy); vx = vx.abs() * _bounceDamping; + impactSpeed = math.max(impactSpeed, preVx.abs()); hit = true; } else if (pos.dx > maxX) { pos = Offset(maxX, pos.dy); vx = -vx.abs() * _bounceDamping; + impactSpeed = math.max(impactSpeed, preVx.abs()); hit = true; } if (pos.dy < minY) { pos = Offset(pos.dx, minY); vy = vy.abs() * _bounceDamping; + impactSpeed = math.max(impactSpeed, preVy.abs()); hit = true; } else if (pos.dy > maxY) { pos = Offset(pos.dx, maxY); vy = -vy.abs() * _bounceDamping; + impactSpeed = math.max(impactSpeed, preVy.abs()); hit = true; } _velocities[i] = _clampVel(Offset(vx, vy)); _positions[i] = pos; - if (hit && _velocities[i].distance > _vibrateSpeedThreshold) { + // vibrate only when the component toward the wall exceeded threshold + if (hit && impactSpeed > _vibrateSpeedThreshold) { wallHitThisTick = true; } }