fix: avoid calculating velocity if accel is available

This commit is contained in:
JovannMC committed 2026-11-25 22:41:23 +03:00
1 parent 5e06df1458
commit e9622135c1
1 file changed
+2 -4
@@ -191,8 +191,8 @@ class DriverIncomingTrackersBehaviour(
val trackerId = event.trackerId.toInt()
if (trackerId == 0) return@on
// Map velocity to accel
val velocityAcceleration = event.linearVelocity?.let { velocity ->
// use linear acceleration if available, otherwise use calculated acceleration from velocity
val acceleration = event.linearAcceleration?.toVector3() ?: event.linearVelocity?.let { velocity ->
val now = timeSource.markNow()
val velocity = velocity.toVector3()
val lastVelocity = lastVelocities[trackerId]
@@ -204,8 +204,6 @@ class DriverIncomingTrackersBehaviour(
remapVelocity(deltaVelocity / deltaTime)
}
}
// use linear acceleration if available, otherwise use calculated acceleration from velocity
val acceleration = event.linearAcceleration?.toVector3() ?: velocityAcceleration
// Rotation offset done here before rotation gets to the tracker
val rotationOffset = rotationOffsets[trackerId] ?: Quaternion.IDENTITY
// Update tracker with new data