drwhut / tabletop-club

An open-source platform for playing tabletop games in a physics-based 3D environment for Windows, macOS, and Linux! Made with the Godot Engine.
https://tabletopclub.net
MIT License
1.27k stars 55 forks source link

Use Quat instead of Basis when sending rotations over the network. #151

Closed drwhut closed 1 year ago

drwhut commented 1 year ago

Is your feature request related to a problem? Please describe. When the physics state of pieces are sent from the server to the client, and when the client wants to set the rotation of a piece, Basis is used. While it does work in representing rotation, it is not optimal in terms of memory usage, calculation speed, and floating-point errors.

Describe the solution you'd like Using Quat instead uses 4 floats rather than 9, is more resistant to floating-point inaccuracies, and most importantly, slerp is much faster, which is very useful when the piece is being hovered.

Describe alternatives you've considered Sticking with using Basis, which works, but as mentioned, it is not optimal.

Additional context This optimisation was spotted in #133.