Interpolating item drawRotation in the "shortest direction" (prevents twitching if the rotation changes e.g. from -0.1f to PI*2), physicsbodies are lerped towards their targetposition at a constant speed

This commit is contained in:
Regalis
2017-02-09 00:01:01 +02:00
parent 4c5da19ab4
commit 1f16bef01c
2 changed files with 21 additions and 9 deletions
+7
View File
@@ -30,6 +30,13 @@ namespace Barotrauma
return current * (float)alpha + previous * (1.0f - (float)alpha);
}
public static float InterpolateRotation(float previous, float current)
{
float angleDiff = MathUtils.GetShortestAngle(previous, current);
return previous + angleDiff * (float)alpha;
}
public static Vector2 Interpolate(Vector2 previous, Vector2 current)
{
return new Vector2(