Fix localToWorld update and smooth physics movement.
Problem
Currently we only do the localToWorld update once per frame, however, when the game is below 30 fps, we run the systems tagged with the fixed step multiple times in one frame. This is particularly troublesome since the Collisions need the updated localToWorld to compute if objects are colliding and their contact points.
With the game the game itself also running at a higher frame rate, the movement with physics looks very "low fps", due to the position only being updated at 30 fps.
Proposed solution at the moment
Put Position, Rotation, etc in a single Transform component, to make sure the matrix is always updated.
Ideally we'd have a Transform, a GlobalTransform, and a FixedTransform.
FixedTransform would hold new transform resulting from the fixed update. The AccumulatedCorrection would still hold the correction of the position to apply to FixedTransform. This means the physics would not directly manipulate the Transform but instead the FixedTransform.
The Transform would be updated by interpolating the FixedTransform between fixed updates. (see: https://docs.rs/avian2d/latest/avian2d/interpolation/struct.PhysicsInterpolationPlugin.html)
- Note: When we do the fixed update, we need to always have exactly the
FixedTransformapplied to theTransform. (so when performing 2 fixed updates in one frame, when doing the second we need to make sure the first is instantly fully applied to theTransform)
Unfortunately merging the components into Transform, FixedTransform, etc, isn't enough to guarantee that the matrix will always be updated. Only the local space matrix will be updated - we would still need to propagate these changes to parents in some system. I'm not sure on how we can achieve this, we should discuss this further...