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 ¶
- type Abstract
- type Far1
- type Far2
- type Far3
- type Far4
- type Far5
- type Grid
- func (g *Grid) Box(i int) geom.AABB
- func (g *Grid) Cols() int
- func (g *Grid) Cover(box geom.AABB, dst []Part) []Part
- func (g *Grid) Fit(box geom.AABB, small float32) (tier, cell int)
- func (g *Grid) Len() int
- func (g *Grid) Nearest(i int, x, y float32) (nx, ny, dist float32)
- func (g *Grid) Neighbours(i int, each func(j int))
- func (g *Grid) Of(x, y float32) int
- func (g *Grid) Rows() int
- func (g *Grid) Side() float32
- func (g *Grid) TierBox(k, i int) geom.AABB
- func (g *Grid) TierLen(k int) int
- func (g *Grid) TierOf(k int, x, y float32) int
- func (g *Grid) Tiers() int
- func (g *Grid) Under(k, i int, each func(sector int))
- type Keen
- type L0
- type L1
- type L2
- type L3
- type L4
- type L5
- type L6
- type Observers
- type Part
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 ¶
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 ¶
Box is sector i's rectangle, the last in a row or a column cut at the world's edge.
func (*Grid) Cover ¶ added in v0.20.0
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
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) Nearest ¶ added in v0.18.0
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
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) TierBox ¶ added in v0.20.0
TierBox is cell i of tier k's rectangle, cut at the world's edges.
func (*Grid) TierOf ¶ added in v0.20.0
TierOf is the cell of tier k holding the world point (x, y), held to the world's edges.
type Keen ¶ added in v0.18.0
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.