lod

package
v0.25.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

View Source
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

func Seed added in v0.20.0

func Seed(whole uid.UID64, cell uint64) uint64

Seed is the number the cell'th place of the aggregate whole draws from, the same at every unfold, so its parts stand where they stood; what has changed since is the aggregate's own.

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.

const (
	UnobservedL4 Fallback = iota
	UnobservedL0
	UnobservedL1
	UnobservedL2
	UnobservedL3
	UnobservedL5
	UnobservedL6
)

The Fallbacks, each the level its name says: UnobservedL4 the default, UnobservedL6 a world no camera observes asleep.

func (Fallback) Level added in v0.19.0

func (f Fallback) Level() Level

Level is the level f stands for; it panics on a Fallback none of the constants is.

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

func (l Ladder) At(scale, dist float32) Level

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

func (l Ladder) FoldAfter() time.Duration

FoldAfter is how long an aggregate's sector lies at Strategic or coarser before it folds: Fold seconds, 3 for none.

func (Ladder) Hold

func (l Ladder) Hold(from Level, scale, dist, margin float32) Level

Hold is the level from goes to at scale, dist from the observer: a finer one at once, a coarser one only as far as it holds at the scale over Hysteresis and margin nearer.

func (Ladder) Widened

func (l Ladder) Widened(factor float32) Ladder

Widened is l seeing factor times as far, its Rings with its Sight, its Fog kept; a Sight without end stays so.

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.

const (
	L0 Level = iota
	L1
	L2
	L3
	L4
	L5
	L6
	// Levels is how many levels there are.
	Levels = 7
)

type Paces

type Paces [Levels]uint8

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.

func Slowing

func Slowing(n ...uint8) Paces

Slowing goes every step on the finest level seen and a step every n one to five levels coarser in turn, the last n repeated where fewer are given; it panics on no n, more than five, a 0 or a falling one.

func (Paces) Check

func (p Paces) Check()

Check panics on paces that cannot be: the finest level seen not every step, any six levels coarser, a level slower than the one after it or going after one that does not.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL