Skip to content
Orbdale

Orbdale Terrain · OrbdaleTerrainCore module · class

Native::

FBrushMask

Experimental

One brush mask: a square grid of 8- or 16-bit samples, one channel, row-major, that scales a brush's falloff weight per post.

Declaration

class FBrushMask
Header
#include "Native/BrushMask.h"
Module
PublicDependencyModuleNames.Add("OrbdaleTerrainCore"); in your module’s Build.cs.
Stability
Experimental: supported, may change in a minor version, with a changelog line.
Thread
Tier 1, plain C++: any thread may read a mask.

Description

  • Orientation. The column grows with the brush's local +X and the row with its local +Y; FBrush::MaskAngle turns that frame counter-clockwise from the world's +X, and kBrushMaskMirror reverses the columns first.

  • Value. A sample becomes M in Q16 through its 16-bit unorm u (8-bit s gives u = 257·s): M = u + (u >> 15), so black is 0 and white exactly kBrushMaskOne.

  • Canonical bytes. 'TSBM', kBrushMaskFormatVersion, the bits, the side (u16), then the samples row after row, 16-bit ones little-endian. The content hash is HashBytesV5 over them; it is the mask's name in FBrush::MaskHash.

  • Mips. Derived when the mask is made and never hashed: level k + 1 is level k's 2 × 2 box, (a + b + c + d + 2) >> 2 on u, down to one sample. A dab samples the level LevelFor picks.

Immutable once made and shared by std::shared_ptr<const FBrushMask>; the only makers are Decode, FromSamples8 and FromSamples16. Tier 1, plain C++: any thread may read a mask.

Functions

  • Decodestatic

    Make a mask from its canonical bytes.

  • FromSamples8static

    Make an 8-bit mask from Side × Side samples, row-major (the column along local +X); refusals as Decode's.

  • FromSamples16static

    Make a 16-bit mask from Side × Side samples, row-major (the column along local +X); refusals as Decode's.

  • Encode

    Append the canonical bytes (header and samples) to Out: Decode of them gives this mask back, and HashBytesV5 of them is Hash().

  • Hash

    HashBytesV5 of the canonical bytes; never 0.

  • Side

    Samples per side of level 0.

  • Bits

    8 or 16.

  • Levels

    Level 0 plus its mips, down to one sample: log2(Side) + 1.

  • LevelSide

    Samples per side of Level (Side >> Level); 0 past the last level.

  • LevelTexels

    Level's samples as 16-bit unorm u, row-major; null past the last level.

  • Texel

    M at one sample of Level, in Q16 (0 to kBrushMaskOne); Col and Row are clamped to the level.

  • LevelFor

    The level a dab samples: the coarsest whose sample is no wider than one edit cell, 2 × HalfSide_mm × 2^k / Side <= Cell_mm, else level 0.

  • Bytes

    Bytes the mask keeps alive: every level's samples plus the object.

  • SameSamples

    Whether Other holds the same samples at the same bits and side: the same canonical bytes.

  • RenamedForTeststatic

    A copy of Mask named by Hash instead of its content hash, for tests of FBrushMaskRegistry's collision rule only: a real 64-bit collision cannot be made.