Documentation
¶
Overview ¶
Package lod is the one ladder of levels of detail the world is ticked and drawn by: a Level for each sector of the world, from the scale it is seen at and how far it lies.
Levels ¶
A world's Ladder says a sector's level from the shown pixels a world unit spans there and its distance from the observer (coarser than a level past its ring, Rings, so a camera seeing far at one scale does not hold the world at that scale's level; nothing past the Sight); the level ticked is the fullest any observer sees it at, and each camera draws at its own. A system says by its Paces (Exact, Steady, Slowing) how often it goes in a sector by how many levels coarser that is than the finest any observer sees, the finest going every step. The words of the levels are a contract every kind of thing keeps:
level and word a figure a tile the ground L0 close its L0 look, else as at L2 as at L2 as at L2 L1 close, no detail its L1 look, else as at L2 as at L2 as at L2 L2 full sprite, edged, upright covers, ways, grid full L3 no detail flat sprite tile and ways no grid L4 shape blob; what stands: sheet colour coarse, no shade or lamps L5 colour blob, thinned; sheet in half colour coarser, no water L6 nothing nothing nothing nothing
A figure with a body (world.Body) stands whole in relief out to the level the world's bodies reach, the close scale, L2 or L3, and as a card of its body beyond, down to L3.
The levels are three scales of two rungs each, exact and coarse, and the omission: the close scale from Close (L0, L1), the standard from Standard (L2, L3), the strategic from Strategic (L4, L5), and Omitted (L6), neither ticked nor drawn. The close scale is a game's to switch on by its thresholds, Scales[L0] and Scales[L1], a zero leaving that level out, so the zero Ladder never reaches it; a system of its detail keeps to it by world.Plugin.Within at Exact, ticking only where someone looks so close, and a figure declares its look there with world.Slot.At. A sector at the close scale is the finest seen, so the standard one beside it goes two levels coarser in every system's Paces.
What stands on the board goes as a figure; clouds and shadows keep to no level yet, a later stage. An aggregate (world.Aggregate) is its parts finer than Strategic and itself alone from it, folding once its sector has lain there the ladder's Fold seconds, a field's (world.Field) each sector apart; Seed is the number a place of it draws from, the same at every unfold. A unit walks cells finer than Strategic and the abstract graph of the regions from it (navigation). A descent realises the coarse state in fine terms as the fine processes would have run it, an ascent sums the fine into the coarse, both from the same state and seed; what the coarse level does not model the descent does not invent.
A world no camera observes is ticked at the ladder's Unobserved level (Fallback), L4 unless set. A camera keeps the ladder's Keep share of a level's entities, the same ones every frame, and the figures' colour goes into the ground in texels of its Texel.
Index ¶
Constants ¶
const ( // Close is the close scale's first rung, used only where a ladder sets its thresholds. Close = L0 // Standard is the standard scale's first rung, a thing in full. Standard = L2 // Strategic is the strategic scale's first rung, a thing's shape and aggregates folded. Strategic = L4 // Omitted is the level neither ticked nor drawn. Omitted = L6 )
The exact rungs the scales begin at, and the omission.
const Hysteresis = 0.9
Hysteresis is the share of a threshold a scale must fall under before its level goes coarser, so a sector at the edge of two levels does not flicker between them.
Variables ¶
var ( // Exact goes every step on the finest level seen alone. Exact = Paces{1, 0, 0, 0, 0, 0, 0} // Steady goes every step at every level but Omitted. Steady = Paces{1, 1, 1, 1, 1, 1, 0} // Contact goes every step up to two levels coarser than the finest seen, none beyond. Contact = Paces{1, 1, 1, 0, 0, 0, 0} )
Functions ¶
Types ¶
type Fallback ¶ added in v0.19.0
type Fallback uint8
Fallback is the level a world no camera observes is ticked at, its zero L4.
type Ladder ¶
type Ladder struct {
Scales [Levels - 1]float32
Sight float32
Fog float32
// Rings is how far from an observer the levels reach: a sector past Rings[k] is coarser than
// level k whatever scale it shows, a zero bounding none, so a camera seeing far at one scale,
// an orthographic one, does not hold the world at that scale's level.
Rings [Levels - 1]float32
// Unobserved is the level a world no camera observes is ticked at.
Unobserved Fallback
// Keep is the share of a level's entities a camera's publisher keeps, in [0, 1], zero for
// all; the rest are thinned by their identity, and Omitted's means nothing, none being
// published.
Keep [Levels]float32
// Texel is how many world units a texel of the sheet of what stands spans, zero the units a
// pixel spans at L4's threshold (a sector's side over 64 without one). The world raises it so
// the sheet spans 4096 texels a side at most.
Texel float32
// Fold is how many seconds an aggregate's sector lies at Strategic or coarser before it
// folds, zero for 3: a hold past the levels' own, so one on the edge of L3 and L4 does not
// flicker.
Fold float32
// Unfolds is how many stretches of aggregates the world unfolds in a step at most, those
// nearest an observer first; zero for 16.
Unfolds int
}
Ladder is the world's levels: Scales[k] the fewest shown pixels a world unit must span for level k (L0 to L5), strictly decreasing where set, a zero leaving a close level out and met by any scale from Standard on; Sight how far from an observer the world is ticked and drawn at all (zero, without end), its last Fog fading. The zero Ladder is Standard everywhere without end round an observer, Strategic with none.
func (Ladder) At ¶
At is the level of what a world unit spans scale shown pixels of, dist from the observer: the first whose threshold the scale meets, a close one only where set, or the coarser one dist reaches within the Rings; Omitted under the last or past the Sight.
func (Ladder) Check ¶
func (l Ladder) Check()
Check panics on a ladder that cannot be: a negative number, a threshold not under the one before where set, a Fog past the Sight, a Keep past 1, an unknown Unobserved.
func (Ladder) FoldAfter ¶ added in v0.20.0
FoldAfter is how long an aggregate's sector lies at Strategic or coarser before it folds: Fold seconds, 3 for none.
type Level ¶
type Level uint8
Level is how fully a thing is ticked and drawn: three scales of two rungs each, exact and coarse, the close scale's L0 the fullest, and L6 neither ticked nor drawn.
type Paces ¶
Paces are the steps of the world a system takes one step over in a sector k levels coarser than the finest any observer sees, at Paces[k], 0 none; at Omitted none ever.