Skip to content
Brass Orrery

Orrery Terrain · OrreryTerrainCore module · class

Native::

FTerrainHashTree

Experimental

The incremental SyncHash of one world.

Declaration

class FTerrainHashTree
Header
#include "Native/Net/HashTree.h"
Module
PublicDependencyModuleNames.Add("OrreryTerrainCore"); in your module’s Build.cs.
Stability
Experimental: supported, may change in a minor version, with a changelog line.
Thread
Game thread, like every FTerrainWorld write.

Description

The hash covers what FTerrainSerialization::StateHash covers, so it changes exactly when that does, but it is a different value: StateHash stays the identity of a save and of a test.

  • A seed: the natural ground's hash and the configuration the save's CONF section holds.

  • The stack: a chain over the features in order, each the hash of its stack bytes (EncodeFeature); a feature's hash is cached while the stack holds it.

  • Per field (the sculpt layer, then each channel in ascending id), a wrapping sum over its set tiles of Combine(field, tile key, content hash): the sculpt state's DeltaHash, a painted tile's content hash. The sums are kept per 32 × 32-tile chunk, the leaves of a two-level tree.

Update diffs the world's sculpt and channel tables against the copy-on-write shares it took last time (TTileTable::ForEachChanged), so it costs O(table chunks) pointer compares plus the tiles of the chunks written since, and nothing on a write. It seals the tables it shares, so their next write clones the chunk, as a publish does; that changes nothing a reader sees.

Tier 1. Game thread, like every FTerrainWorld write. FTerrainWorld::SyncHash keeps one per world.

Functions

  • FTerrainHashTree (2 overloads)
  • operator=
  • Update

    Bring the sums up to World's truth and return its SyncHash.

  • Recomputestatic

    The SyncHash computed from scratch, sharing nothing with any tree: O(world).

  • Hash

    As of the last Update; 0 before any.

  • StackHash

    The stack's part as of the last Update: a repair sends the stack when it differs.

  • Leaves

    The leaves as of the last Update with any tile: by field (sculpt, then channels by id), then chunk row, then column.