Skip to main content

Module frame

Module frame 

Source
Expand description

The replication frame: what one subscriber receives per tick.

Integers are LEB128 varints (crate::varint); signed values are zigzag varints. Positions travel quantized: round(value / precision).

u8      version (1)
u8      flags: bit 0 FULL: the client clears its table first
f32 LE  precision
varint  despawn count, then ids: the first absolute, each next as the
        difference from the previous (ids ascend)
varint  spawn count, then per entity (ids ascend, delta-coded):
          id, x, y, z (zigzag, absolute quantized), components
varint  update count, then per entity (ids ascend, delta-coded):
          id, u8 mask (1 x, 2 y, 4 z, 8 components),
          the changed axes (zigzag, quantized difference from the value
          last sent), components when bit 8 is set
components: varint count, then per component:
          u8 id, varint (length + 1), bytes; length field 0 = removed

A spawn carries every present component. An update carries the ones that changed or were removed since that subscriber was last updated.

Modules§

mask
Bits of an update’s mask byte.

Structs§

DecodeError
Why a frame did not decode or apply.
FrameBuilder
Builds one frame. Add despawns in any order; add spawns and updates in ascending id order.
FrameSummary
What one frame did.
ReplicaEntity
An entity as a client sees it.
ReplicaTable
A client’s table of the entities it has been told about.

Constants§

FLAG_FULL
VERSION

Functions§

encode_update_body
Encode an update body (everything after the id): the mask, the changed axes, and the component changes. Returns the body.
encode_update_body_into
encode_update_body, appended to body.
quantize
value / precision, rounded. Non-finite values quantize to 0.
quantize3

Type Aliases§

ComponentChange
A component change inside an update: new bytes, or removed.