The frame ring buffer is a utility collection class that stores a fixed number of latest frames in a ring buffer, usually in a certain time interval. A use-case for example are instant replays which allow to create a new simulation in the past time of the main simulation. More...
Inherits IDisposable.
Public Member Functions | |
DeterministicFrameRingBuffer (int capacity) | |
Create the frame ring buffer with a fixed capacity. More... | |
void | Clear () |
Clear all frames in the ring buffer. More... | |
DeterministicFrame | Find (int frameNumber, DeterministicFrameSnapshotBufferFindMode findMode=DeterministicFrameSnapshotBufferFindMode.Equal) |
Find a frame that matches the desired frame number. More... | |
DeterministicFrame | PeekBack (int offset=0) |
Return the frame at the head of the ring buffer. More... | |
void | PushBack (DeterministicFrame frame, Func< DeterministicFrame > createFrame) |
Add a frame to the collection, the frame object is copied. If the collection is full the oldest frame will be overwritten. More... | |
void | PushBack (DeterministicFrame frame, IDeterministicGame game, IDisposable context) |
Add a frame to the collection, the frame object is copied. If the collection is full the oldest frame will be overwritten. More... | |
Static Public Member Functions | |
static Int32 | GetSize (Int32 window, Int32 samplingRate) |
Calculate the required size based for the ring buffer on the time window and sampling rate. More... | |
static bool | TryGetCommonSamplingPattern (Int32 windowA, Int32 samplingA, Int32 windowB, Int32 samplingB, out Int32 commonWindow, out Int32 commonSampling) |
This method checks if there is a common sampling pattern between two windows of frames by comparing their sampling rates and window sizes. If a common pattern is found, it returns true and provides the common window size and sampling rate through the output parameters. Otherwise, it returns false and sets the output parameters to 0. More... | |
Public Attributes | |
DeterministicFrame[] | Data => _data |
Returns the internal data array. More... | |
Properties | |
int | Capacity [get] |
Returns the capacity of the ring buffer. More... | |
int | Count [get] |
Returns the current count of frames in the ring buffer. More... | |
DeterministicFrame | this[int index] [get] |
Access a frame by index. The index is relative to the head of the ring buffer, so index 0 is always the older frame stored. More... | |
The frame ring buffer is a utility collection class that stores a fixed number of latest frames in a ring buffer, usually in a certain time interval. A use-case for example are instant replays which allow to create a new simulation in the past time of the main simulation.
|
inline |
Create the frame ring buffer with a fixed capacity.
capacity | Ring buffer size |
ArgumentException | Is raised when the capacity is smaller than 1 |
|
inline |
Clear all frames in the ring buffer.
|
inline |
Find a frame that matches the desired frame number.
frameNumber | The desired frame number |
findMode | The find mode |
|
inline |
Add a frame to the collection, the frame object is copied. If the collection is full the oldest frame will be overwritten.
frame | The frame to save |
game | Game object |
context | Context object |
|
inline |
Add a frame to the collection, the frame object is copied. If the collection is full the oldest frame will be overwritten.
frame | The frame to save |
createFrame | A callback to create a copy of the frame |
|
inline |
Return the frame at the head of the ring buffer.
offset | The offset relative to the head |
InvalidOperationException | Is raised when the collection is empty |
IndexOutOfRangeException | Is raised when the offset is invalid or out of bounds |
|
inlinestatic |
This method checks if there is a common sampling pattern between two windows of frames by comparing their sampling rates and window sizes. If a common pattern is found, it returns true
and provides the common window size and sampling rate through the output parameters. Otherwise, it returns false
and sets the output parameters to 0.
windowA | Time window a in ticks |
samplingA | Sampling interval a |
windowB | Time window b in ticks |
samplingB | Sampling interval b |
commonWindow | Common time window |
commonSampling | Common sample rate |
true
if a common pattern was found
|
inlinestatic |
Calculate the required size based for the ring buffer on the time window and sampling rate.
window | Time window in ticks |
samplingRate | Sampling interval |
DeterministicFrame [] Photon.Deterministic.DeterministicFrameRingBuffer.Data => _data |
Returns the internal data array.
|
get |
Returns the capacity of the ring buffer.
|
get |
Returns the current count of frames in the ring buffer.
|
get |
Access a frame by index. The index is relative to the head of the ring buffer, so index 0 is always the older frame stored.
index | Index of the current saves frames. |
ArgumentOutOfRangeException | Is raised when the desired index value is less than 0 or out of bounds Count |