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; Vector3 lastPos, nextPos;
float lastYaw, nextYaw, lastPitch, nextPitch; float lastYaw, nextYaw, lastPitch, nextPitch;
public void SetInterpPosition( float t ) { public void SetInterpPosition( float t ) {
// The first two cases shouldn't happen, but just in case.. Position = Vector3.Lerp( lastPos, nextPos, t );
if( t < 0 ) { YawDegrees = Utils.Lerp( lastYaw, nextYaw, t );
Position = lastPos; PitchDegrees = Utils.Lerp( lastPitch, nextPitch, t );
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 );
}
} }
int tickCount = 0; int tickCount = 0;

View File

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