Skip to content

RandomMapModifier

Source: RandomMapModifier.h

RandomMapModifier

class RandomMapModifier
src/light/modifiers/RandomMapModifier.h:29

Inherits: ModifierBase

Modifier remapping every light through a random 1:1 permutation.

Public Attributes

uint8_t bpm = 6 : Reshuffles per minute (0–60); 6 ≈ every 10 s; 0 = frozen.

Public Methods

virtual inline const char * tags() const override : The catalog tags this modifier carries.

virtual inline Dim dimensions() const override : Shuffles within a box that spans all three axes.

inline ~RandomMapModifier() override : Releases the permutation buffers.

virtual inline void defineControls() override : The controls a user sets on the card.

virtual inline bool affectsPrepare(const char *) const override : Whether a change here forces the mapping to rebuild.

virtual inline void modifyLogicalSize(Coord3D & size) override : Resize the logical box this modifier presents to the effect.

virtual inline bool modifyLogical(Coord3D & pos) const override : Transform one light's logical position, false dropping it from the mapping.

virtual inline void tick() override : The hot tick, which by default ticks every enabled child and times each.

virtual inline bool consumeNeedsRebuild() override : Whether a beat has asked for a fresh permutation, which the Layer polls and coalesces.

inline void reshuffle() : Bump the generation so the next rebuild reshuffles, which a test can drive directly.

More info

Randomly remaps every light to another light, a true 1:1 permutation (every light goes somewhere, no gaps or duplicates), and reshuffles on a bpm timer. A static fold whose mapping changes on a beat: modifyLogical applies the permutation (the box is unchanged, each light maps to exactly one other). The bpm tick bumps the generation and rebuilds the Layer's mapping on a beat boundary, the path a control change takes, scoped to one Layer. A permutation is a discrete reshuffle rather than smooth motion, so a beat-gated rebuild is the right cost, not a per-frame remap.

How often it reshuffles

The rate control is reshuffles per minute, from none up to one a second. At zero the permutation freezes and never reshuffles again.

Cost: each beat re-runs the Layer's mapping rebuild on the render thread (a transient one-frame hitch), bounded by bpm≤60. The permutation buffer is a member sized to the box, (re)allocated only on a grid resize, never per frame. An alloc failure degrades to identity passthrough.

Sparse layouts: the permutation is over box indices, so a real light can map to a non-light cell (dropped → dark). Acceptable for v1. Author: MoonLight, https://github.com/ewowi/MoonLight/blob/main/src/MoonLight/Nodes/Modifiers/M_MoonLight.h