MyGridGyroSystem SlowdownTorque is incorrectly calculated with invTensor.Scale

Vanir shared this bug 2 days ago
Submitted

https://github.com/KeenSoftwareHouse/SpaceEngineers/blob/54f2f0f3169cda687a25a438097902a43bdfa603/Sources/Sandbox.Game/Game/GameSystems/MyGridGyroSystem.cs#L153C1-L153C51

// MyGridGyroSystem.cs:153
SlowdownTorque /= invTensor.Scale;

Matrix.Scale uses off-diagonal elements to calculate its magnitudes, but the three axes are treated independently when applied to SlowdownTorque which loses the directional coupling that the tensor also represents.

I believe the transformation should be a full Vector3.Transform of the slowdown torque by the tensor instead of using scale first.

In asymmetric grids the tensor has significant off-diagonal terms which describe how rotation in one axis induces forces in another axis. By using Matrix.Scale it is removing some of this detail and assuming that the grid's local axes are aligned with its principal axes of inertia which often isn't the case.

This bug can cause asymmetric grids with gyros on board (even if they are switched off) to bias towards the orientation of minimum inertia. The behaviour typically doesn't happen because the forces are so small that they are clamped or rounded down to zero, but in some circumstances the grid's inertia can spike momentarily on a particular tick high enough that it does not round and instead applies a slowdown force to the grid using these incorrect axes.

I believe that with a vector transform the complete matrix should properly represent this difference in alignment and cancel out unwanted forces.

We've experienced this more consistently when using high world speed limits, where when traveling at these higher speeds the grid inertia can occasionally spike and cause an unexpected yaw/pitch/roll. This immediately stops if your grids are on override, as the Gyro system switches to a different update method which does not calculate or apply slowdown forces with inertia. The unexpected yaw/pitch/roll is exaggerated on grids with highly asymmetric mass distributions, and not present at all on grids that are purely symmetrical.

Leave a Comment
 
Attach a file