mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Prediction: RingBuffer perf comments
This commit is contained in:
parent
52d00aa3e3
commit
4d6ac92b62
@ -48,7 +48,7 @@ public class PredictedRigidbody : NetworkBehaviour
|
|||||||
|
|
||||||
// client keeps state history for correction & reconciliation.
|
// client keeps state history for correction & reconciliation.
|
||||||
// this needs to be a SortedList because we need to be able to insert inbetween.
|
// this needs to be a SortedList because we need to be able to insert inbetween.
|
||||||
// RingBuffer would be faster iteration, but can't do insertions.
|
// => RingBuffer: see prediction_ringbuffer_2 branch, but it's slower!
|
||||||
[Header("State History")]
|
[Header("State History")]
|
||||||
public int stateHistoryLimit = 32; // 32 x 50 ms = 1.6 seconds is definitely enough
|
public int stateHistoryLimit = 32; // 32 x 50 ms = 1.6 seconds is definitely enough
|
||||||
readonly SortedList<double, RigidbodyState> stateHistory = new SortedList<double, RigidbodyState>();
|
readonly SortedList<double, RigidbodyState> stateHistory = new SortedList<double, RigidbodyState>();
|
||||||
|
@ -28,6 +28,7 @@ public static class Prediction
|
|||||||
{
|
{
|
||||||
// get the two states closest to a given timestamp.
|
// get the two states closest to a given timestamp.
|
||||||
// those can be used to interpolate the exact state at that time.
|
// those can be used to interpolate the exact state at that time.
|
||||||
|
// => RingBuffer: see prediction_ringbuffer_2 branch, but it's slower!
|
||||||
public static bool Sample<T>(
|
public static bool Sample<T>(
|
||||||
SortedList<double, T> history,
|
SortedList<double, T> history,
|
||||||
double timestamp, // current server time
|
double timestamp, // current server time
|
||||||
@ -98,6 +99,7 @@ public static bool Sample<T>(
|
|||||||
// inserts a server state into the client's history.
|
// inserts a server state into the client's history.
|
||||||
// readjust the deltas of the states after the inserted one.
|
// readjust the deltas of the states after the inserted one.
|
||||||
// returns the corrected final position.
|
// returns the corrected final position.
|
||||||
|
// => RingBuffer: see prediction_ringbuffer_2 branch, but it's slower!
|
||||||
public static T CorrectHistory<T>(
|
public static T CorrectHistory<T>(
|
||||||
SortedList<double, T> history,
|
SortedList<double, T> history,
|
||||||
int stateHistoryLimit,
|
int stateHistoryLimit,
|
||||||
|
Loading…
Reference in New Issue
Block a user