mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
micro optimizations
This commit is contained in:
parent
141b9e9a76
commit
592a41d065
@ -156,7 +156,6 @@ protected void BeginPredicting()
|
|||||||
}
|
}
|
||||||
|
|
||||||
double blendingStartTime;
|
double blendingStartTime;
|
||||||
float BlendingElapsedTime() => (float)(NetworkTime.time - blendingStartTime);
|
|
||||||
protected void BeginBlending()
|
protected void BeginBlending()
|
||||||
{
|
{
|
||||||
state = ForecastState.BLENDING;
|
state = ForecastState.BLENDING;
|
||||||
@ -252,11 +251,11 @@ void FixedUpdateClient()
|
|||||||
{
|
{
|
||||||
// physics movements need to be done in FixedUpdate.
|
// physics movements need to be done in FixedUpdate.
|
||||||
|
|
||||||
if (state == ForecastState.PREDICTING)
|
// PREDICTING checks state, which happens in update()
|
||||||
{
|
// if (state == ForecastState.PREDICTING)
|
||||||
// PREDICTING checks state, which happens in update()
|
// {
|
||||||
}
|
// }
|
||||||
else if (state == ForecastState.BLENDING)
|
if (state == ForecastState.BLENDING)
|
||||||
{
|
{
|
||||||
// TODO snapshot interpolation
|
// TODO snapshot interpolation
|
||||||
|
|
||||||
@ -268,14 +267,15 @@ void FixedUpdateClient()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sample the blending curve to find out how much to blend right now
|
// sample the blending curve to find out how much to blend right now
|
||||||
float blendingElapsed = BlendingElapsedTime();
|
|
||||||
|
float blendingElapsed = (float)(NetworkTime.time - blendingStartTime);
|
||||||
float relativeElapsed = blendingElapsed / blendingTime;
|
float relativeElapsed = blendingElapsed / blendingTime;
|
||||||
float p = blendingCurve.Evaluate(relativeElapsed);
|
float p = blendingCurve.Evaluate(relativeElapsed);
|
||||||
// Debug.Log($"{name} BLENDING @ {blendingElapsed:F2} / {blendingTime:F2} => {(p*100):F0}%");
|
// Debug.Log($"{name} BLENDING @ {blendingElapsed:F2} / {blendingTime:F2} => {(p*100):F0}%");
|
||||||
|
|
||||||
// blend local position to remote position
|
// blend local position to remote position.
|
||||||
Vector3 currentPosition = predictedRigidbody.position;
|
// getting both at once is fastest.
|
||||||
Quaternion currentRotation = predictedRigidbody.rotation;
|
tf.GetPositionAndRotation(out Vector3 currentPosition, out Quaternion currentRotation);
|
||||||
|
|
||||||
// smoothly interpolate to the target position.
|
// smoothly interpolate to the target position.
|
||||||
// speed relative to how far away we are.
|
// speed relative to how far away we are.
|
||||||
@ -305,10 +305,10 @@ void FixedUpdateClient()
|
|||||||
BeginFollowing();
|
BeginFollowing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (state == ForecastState.FOLLOWING)
|
// FOLLOWING sets Transform, which happens in Update().
|
||||||
{
|
// else if (state == ForecastState.FOLLOWING)
|
||||||
// FOLLOWING sets Transform, which happens in Update().
|
// {
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedUpdate()
|
void FixedUpdate()
|
||||||
|
@ -22,4 +22,4 @@ Predicted:
|
|||||||
2024-03-15: 625 FPS Client, 1700 FPS Server // Vector3.MoveTowardsCustom()
|
2024-03-15: 625 FPS Client, 1700 FPS Server // Vector3.MoveTowardsCustom()
|
||||||
2024-03-18: 628 FPS Client, 1700 FPS Server // removed O(N) insertion from CorrectHistory()
|
2024-03-18: 628 FPS Client, 1700 FPS Server // removed O(N) insertion from CorrectHistory()
|
||||||
2024-03-28: 800 FPS Client, 1700 FPS Server // FAST mode prediction
|
2024-03-28: 800 FPS Client, 1700 FPS Server // FAST mode prediction
|
||||||
2024-04-04: 570 FPS Client, 1700 FPS Server // Forecasting & hand-off
|
2024-04-04: 580 FPS Client, 1700 FPS Server // Forecasting & hand-off
|
||||||
|
Loading…
Reference in New Issue
Block a user