sector

package
v0.27.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: 5 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 sector is the world cut into sectors and the levels they are ticked at round the observers, the cameras the players look through.

Levels

A world's Config.Sectors cuts it into square sectors, whole blocks of the space's buckets (Grid), and its Config.LOD says each one's level (lod.Ladder): every tick the world lays a sector at the fullest level any observer sees it at, and marks the entities in it: those at L0 carry L0, those at L1 L1 and so on, those at L6 L6. What lies at L6 is asleep, not in the world's space, so no query, sight or collision meets it until its sector comes back.

An observer sees a sector finer at once and coarser only a tenth past a threshold and half a sector past its sight (lod.Ladder.Hold), and draws no two sectors side by side more than a level apart, lifting the coarser, though one at L6 may lie beside anything. A Keen entity keeps its sector and the eight round it ticked at its level at most, so those asleep there wake before it comes.

Tiers

Over the sectors the Grid has tiers: tier 0 the sectors, a cell of tier k 2ᵏ×2ᵏ of them from the grid's corner, the highest one cell over the whole world. A thing standing for good lives in a cell (Grid.Fit): one no longer than the world's small side by its centre whatever it overlaps, a longer one in the lowest tier a cell of which holds it whole; its level is the finest of the sectors under that cell (Grid.Under).

Paces

A system goes at the levels as the plugin owning it says (lod.Paces); world.Plugin.Pace is the pace of its Paces, an option of the system's query, by the marks Far1 to Far5 of how many levels coarser than the finest seen a sector is; world.Plugin.Within keeps a query to one scale. At L6 none goes.

Observers

Observers are whoever knows where the players look: the cameras plugin hands the world each of its cameras, a minimap's none.

Vocabulary

Marks: L0, L1, L2, L3, L4, L5, L6, Far1, Far2, Far3, Far4, Far5. Components: Keen.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Abstract added in v0.20.0

type Abstract struct{}

Abstract marks an entity travelling the abstract graph far from every camera: the collision neither pushes it nor is pushed by it, and the board does not slow it.

type Far1 added in v0.20.0

type Far1 struct{}

The marks of the pace: how many levels coarser than the finest level any observer sees the entity's sector is ticked at, zero-size components a system's pace goes by. None is Far0.

type Far2 added in v0.20.0

type Far2 struct{}

The marks of the pace: how many levels coarser than the finest level any observer sees the entity's sector is ticked at, zero-size components a system's pace goes by. None is Far0.

type Far3 added in v0.20.0

type Far3 struct{}

The marks of the pace: how many levels coarser than the finest level any observer sees the entity's sector is ticked at, zero-size components a system's pace goes by. None is Far0.

type Far4 added in v0.20.0

type Far4 struct{}

The marks of the pace: how many levels coarser than the finest level any observer sees the entity's sector is ticked at, zero-size components a system's pace goes by. None is Far0.

type Far5 added in v0.20.0

type Far5 struct{}

The marks of the pace: how many levels coarser than the finest level any observer sees the entity's sector is ticked at, zero-size components a system's pace goes by. None is Far0.

type Grid

type Grid struct {
	// contains filtered or unexported fields
}

Grid is a world cut into square sectors.

func NewGrid

func NewGrid(width, height uint32, wrapX, wrapY bool, side float32) *Grid

NewGrid cuts a world width x height, wrapping across where wrapX says and down where wrapY does, into sectors side a side.

func (*Grid) Box

func (g *Grid) Box(i int) geom.AABB

Box is sector i's rectangle, the last in a row or a column cut at the world's edge.

func (*Grid) Cols

func (g *Grid) Cols() int

Cols is how many sectors lie across the world; sector i lies in column i%Cols.

func (*Grid) Cover added in v0.20.0

func (g *Grid) Cover(box geom.AABB, dst []Part) []Part

Cover appends to dst each sector box covers, once, with the part of box within it; where the world wraps, box may run past its edges, its part across the seam given where that sector lies.

func (*Grid) Fit added in v0.20.0

func (g *Grid) Fit(box geom.AABB, small float32) (tier, cell int)

Fit is the tier and the cell a thing lying over box lives in: one whose longer side is small at most (zero, a quarter of a sector's side) the sector of its centre, whatever it overlaps; a longer one the cell of the lowest tier holding it whole, the top's where none below does.

func (*Grid) Len

func (g *Grid) Len() int

Len is how many sectors there are.

func (*Grid) Nearest added in v0.18.0

func (g *Grid) Nearest(i int, x, y float32) (nx, ny, dist float32)

Nearest is the point of sector i nearest the world point (x, y) and how far it lies, the shorter way round where the world wraps.

func (*Grid) Neighbours added in v0.18.0

func (g *Grid) Neighbours(i int, each func(j int))

Neighbours calls each with every sector touching sector i by a side or a corner, once, across a seam where the world wraps; one on the edge of a world that does not has fewer.

func (*Grid) Of

func (g *Grid) Of(x, y float32) int

Of is the sector of the world point (x, y), held to the world's edges.

func (*Grid) Rows

func (g *Grid) Rows() int

Rows is how many sectors lie down the world.

func (*Grid) Side

func (g *Grid) Side() float32

Side is a sector's side, in world units.

func (*Grid) TierBox added in v0.20.0

func (g *Grid) TierBox(k, i int) geom.AABB

TierBox is cell i of tier k's rectangle, cut at the world's edges.

func (*Grid) TierLen added in v0.20.0

func (g *Grid) TierLen(k int) int

TierLen is how many cells tier k has.

func (*Grid) TierOf added in v0.20.0

func (g *Grid) TierOf(k int, x, y float32) int

TierOf is the cell of tier k holding the world point (x, y), held to the world's edges.

func (*Grid) Tiers added in v0.20.0

func (g *Grid) Tiers() int

Tiers is how many tiers of cells lie over the sectors: tier 0 the sectors themselves, tier k cells of 2^k by 2^k sectors from sector 0, the top the first whose one cell covers the world.

func (*Grid) Under added in v0.20.0

func (g *Grid) Under(k, i int, each func(sector int))

Under calls each with every sector of cell i of tier k, row by row; one of tier 0 is the sector i.

type Keen added in v0.18.0

type Keen struct{ Level lod.Level }

Keen keeps the sector its entity is in and the eight round it ticked at Level at most while the entity lives.

type L0 added in v0.20.0

type L0 struct{}

The marks of the entities in a sector by the level it is ticked at: zero-size components a system's query includes or excludes. L6 is asleep, out of the world's space.

type L1 added in v0.18.0

type L1 struct{}

The marks of the entities in a sector by the level it is ticked at: zero-size components a system's query includes or excludes. L6 is asleep, out of the world's space.

type L2 added in v0.18.0

type L2 struct{}

The marks of the entities in a sector by the level it is ticked at: zero-size components a system's query includes or excludes. L6 is asleep, out of the world's space.

type L3 added in v0.18.0

type L3 struct{}

The marks of the entities in a sector by the level it is ticked at: zero-size components a system's query includes or excludes. L6 is asleep, out of the world's space.

type L4 added in v0.18.0

type L4 struct{}

The marks of the entities in a sector by the level it is ticked at: zero-size components a system's query includes or excludes. L6 is asleep, out of the world's space.

type L5 added in v0.20.0

type L5 struct{}

The marks of the entities in a sector by the level it is ticked at: zero-size components a system's query includes or excludes. L6 is asleep, out of the world's space.

type L6 added in v0.20.0

type L6 struct{}

The marks of the entities in a sector by the level it is ticked at: zero-size components a system's query includes or excludes. L6 is asleep, out of the world's space.

type Observers added in v0.18.0

type Observers interface {
	Observers(each func(cam camera.Camera))
}

Observers are the cameras the world lives round; a camera keeping the whole world in view, a minimap's, is none.

type Part added in v0.20.0

type Part struct {
	Sector int
	Box    geom.AABB
}

Part is a sector a rectangle covers and the part of the rectangle within it.

Jump to

Keyboard shortcuts

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