Simplify local player interpolation.

This commit is contained in:
UnknownShadow200 2015-02-14 09:01:04 +11:00
parent 39e67a182e
commit b673944a61
2 changed files with 6 additions and 17 deletions

View File

@ -291,20 +291,9 @@ namespace ClassicalSharp {
Vector3 lastPos, nextPos;
float lastYaw, nextYaw, lastPitch, nextPitch;
public void SetInterpPosition( float t ) {
// The first two cases shouldn't happen, but just in case..
if( t < 0 ) {
Position = lastPos;
YawDegrees = lastYaw;
PitchDegrees = lastPitch;
} else if( t > 1 ) {
Position = nextPos;
YawDegrees = nextYaw;
PitchRadians = nextPitch;
} else {
Position = Vector3.Lerp( lastPos, nextPos, t );
YawDegrees = Utils.Lerp( lastYaw, nextYaw, t );
PitchDegrees = Utils.Lerp( lastPitch, nextPitch, t );
}
Position = Vector3.Lerp( lastPos, nextPos, t );
YawDegrees = Utils.Lerp( lastYaw, nextYaw, t );
PitchDegrees = Utils.Lerp( lastPitch, nextPitch, t );
}
int tickCount = 0;

View File

@ -234,7 +234,8 @@ namespace ClassicalSharp {
if( ticksThisFrame > ticksFrequency / 3 ) {
Utils.LogWarning( "Falling behind (did {0} ticks this frame)", ticksThisFrame );
}
LocalPlayer.SetInterpPosition( (float)( ticksAccumulator / ticksPeriod ) );
float t = (float)( ticksAccumulator / ticksPeriod );
LocalPlayer.SetInterpPosition( t );
Graphics.Clear();
Graphics.SetMatrixMode( MatrixType.Modelview );
@ -246,7 +247,6 @@ namespace ClassicalSharp {
bool visible = activeScreen == null || !activeScreen.BlocksWorld;
if( visible ) {
//EnvRenderer.EnableAmbientLighting();
float t = (float)( ticksAccumulator / ticksPeriod );
RenderPlayers( e.Time, t );
ParticleManager.Render( e.Time, t );
SelectedPos = Camera.GetPickedPos(); // TODO: only pick when necessary