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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user