mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 18:15:28 -04:00
Simplify local player interpolation.
This commit is contained in:
parent
39e67a182e
commit
b673944a61
@ -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;
|
||||
|
@ -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 );
|
||||
@ -245,8 +246,7 @@ namespace ClassicalSharp {
|
||||
|
||||
bool visible = activeScreen == null || !activeScreen.BlocksWorld;
|
||||
if( visible ) {
|
||||
//EnvRenderer.EnableAmbientLighting();
|
||||
float t = (float)( ticksAccumulator / ticksPeriod );
|
||||
//EnvRenderer.EnableAmbientLighting();
|
||||
RenderPlayers( e.Time, t );
|
||||
ParticleManager.Render( e.Time, t );
|
||||
SelectedPos = Camera.GetPickedPos(); // TODO: only pick when necessary
|
||||
|
Loading…
x
Reference in New Issue
Block a user