vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::NetPacing Class Reference

How fast a client turns wall time into ticks, so the server's queue of its commands holds a small cushion rather than running dry or deep. More...

#include <pacing.h>

Public Member Functions

void report (uint32_t lowWater, float roundTrip, float tickRate)
 Take one snapshot's reading of the queue.
float scale () const
 How much faster than wall time to run ticks.
float depth () const
 The low water as smoothed over the last few snapshots, in commands.
float target () const
 The low water this is steering toward, in commands.

Static Public Attributes

static constexpr float MAX_DILATION = 0.05f
 The most the pacing bends either way.

Detailed Description

How fast a client turns wall time into ticks, so the server's queue of its commands holds a small cushion rather than running dry or deep.

The two clocks drift: a fast client fills the queue until it is trimmed (dropped input), a slow one drains it until a tick runs on a repeat (a misprediction). So the client steers NetCommandBuffer::lowWater toward a cushion of a command or two, widened by the reading's jitter.

Proportional plus integral (the integral holds a steady drift). Both gains scale with the loop's delay - a round trip - and the tick rate; fixed gains swing between the bounds on a long link. Only ticks per wall second bend, by at most MAX_DILATION; the tick step does not, so replays are unaffected. Exactly one until a snapshot has said anything.

Member Function Documentation

◆ report()

void Vkm::Engine::NetPacing::report ( uint32_t lowWater,
float roundTrip,
float tickRate )

Take one snapshot's reading of the queue.

Parameters
lowWaterFewest commands waiting at any tick since the previous snapshot; at most NET_QUEUE_DEPTH_MAX.
roundTripRound trip now, in seconds; zero before one is measured.
tickRateTicks a second, which is commands a second.

◆ scale()

float Vkm::Engine::NetPacing::scale ( ) const
inline

How much faster than wall time to run ticks.

Returns
Within one MAX_DILATION either side of one, and exactly one before anything has been reported.

Member Data Documentation

◆ MAX_DILATION

float Vkm::Engine::NetPacing::MAX_DILATION = 0.05f
staticconstexpr

The most the pacing bends either way.

Covers clock drift and a frame loop running a little short, under what a player notices in their character's speed.


The documentation for this class was generated from the following file: