Skip to main content

Module position

Module position 

Source
Expand description

World-coordinate helpers for Source 2’s split position storage.

Networked entities in Source 2 do not transmit a full world position every tick. Each position is split across two networked fields:

  • an integer cell index (m_cellX, m_cellY, m_cellZ) identifying which fixed-size cell of the world the entity is currently in, and
  • a quantized offset (m_vecOrigin.m_vecX, etc.) describing where inside that cell the entity sits, bounded to [0, CELL_SIZE).

The true world position (in Hammer units, the same coordinate space used by Valve’s level editor and .vmap data) is reconstructed via cell_to_world. Reading the offset alone gives a sawtooth signal that resets every time the entity crosses a cell boundary, not a usable coordinate. See Entity::world_position for the typical entity-side combine.

Constants§

CELL_BITS
Number of bits used by Source 2 to address a position within a cell.
CELL_SIZE
Edge length of a single cell in Hammer units (2^CELL_BITS).
WORLD_HALF
Half the addressable world extent in Hammer units.

Functions§

cell_to_world
Combine a cell index and an in-cell offset into a world coordinate.