view

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 9 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 view is what one pair of eyes sees of a world.

View

A View is a rectangle of the world and the entities the space finds in it, as an EntitySet. The world keeps one a camera (world.Write.NewView) and the System refreshes each once a tick after movement; a View over the whole world simply sees everything.

Sectors seen

In a world cut into sectors a camera's View (NewSeen) is of the sectors its picture covers within its sight (the world's lod.Ladder.Sight times camera.SightOf), each at the lod.Level the camera sees it at, lod.Omitted off the picture or past the sight: two drawn side by side a level apart at most, none finer than it is ticked at. It holds the entities of the sectors seen; View.Level and View.Fog say how fully one at a point is drawn and how far into the fog.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntitySet

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

EntitySet is a set of the world's entities by index, the zero value empty and ready. It knows nothing of generations: fill it only with ids of entities alive at the time.

func (*EntitySet) Add

func (s *EntitySet) Add(id uid.UID64)

Add puts id in the set.

func (*EntitySet) Clear

func (s *EntitySet) Clear()

Clear empties the set, keeping its memory.

func (*EntitySet) Has

func (s *EntitySet) Has(id uid.UID64) bool

Has reports whether id is in the set; an index past its size is not.

func (*EntitySet) Len

func (s *EntitySet) Len() int

Len is how many entities the set holds.

type Sectors

type Sectors interface {
	Len() int
	Cols() int
	Box(i int) geom.AABB
	Of(x, y float32) int
	Level(cam camera.Camera, i int) lod.Level
	Ladder() lod.Ladder
}

Sectors is a world's grid of sectors as a View sees it: how many and how many in a row (the sector i lies at column i % Cols, row i / Cols), each one's rectangle, the one a point lies in, the level a camera sees one at (the level ticked for a camera that is no observer) and the world's ladder. An observer sees a sector at the level it is ticked at or coarser, never finer.

type System

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

System refreshes every View listed at views once a tick from the Space.

func NewSystem

func NewSystem(space *aabbworld.Space, views *[]*View, worldW, worldH uint32) *System

NewSystem builds the system over space, refreshing the Views listed at views.

func (*System) Init

func (s *System) Init(*goke.SysInit)

func (*System) Update

func (s *System) Update(*goke.CmdBuf, time.Duration)

type View

type View struct {
	// Bounds is the rectangle seen, as of the last tick.
	Bounds geom.AABB
	// Culled says Bounds is less than the whole world and In is the answer; false means everything.
	Culled bool
	// In is who the Space found in Bounds, when Culled.
	In EntitySet
	// contains filtered or unexported fields
}

View is a rectangle of the world and the entities the Space finds in it, refreshed each tick after movement. The zero value sees everything.

func New

func New(bounds func() geom.AABB) *View

New is a View over whatever bounds says.

func NewSeen

func NewSeen(cam camera.Camera, sectors Sectors) *View

NewSeen is a View of what cam shows of a world cut into sectors: the sectors its picture covers within its sight, each at its level, and the entities in them.

func (*View) Contains

func (v *View) Contains(id uid.UID64) bool

Contains reports whether id is in view.

func (*View) CopyInto added in v0.5.0

func (v *View) CopyInto(dst *View)

CopyInto has dst see what v sees now, keeping dst's memory; no tick refreshes dst.

func (*View) Fog

func (v *View) Fog(x, y float32) float32

Fog is how far into the fog before the camera's sight the world point (x, y) lies, 0 short of it to 1 at the sight's end.

func (*View) Fogging

func (v *View) Fogging() [4]float32

Fogging is the fog before the camera's sight ends as a shader takes it: from where (x, y), where it begins and where it ends; all zero without a sight.

func (*View) Grid

func (v *View) Grid() Sectors

Grid is the world's sectors the View sees, nil in a world of none.

func (*View) Level

func (v *View) Level(x, y float32) lod.Level

Level is how fully what stands at the world point (x, y) is drawn: the level the camera sees its sector at, shifted coarser by its LevelShift (camera.Shifted) to lod.L5 at most but never from lod.Standard or finer, lod.Omitted off the picture or past the sight; lod.Standard in a View of no sectors.

func (*View) Sectors

func (v *View) Sectors(each func(i int, box geom.AABB, level lod.Level))

Sectors calls each with every sector seen, its index in the Grid, its rectangle and its level, short of lod.Omitted; a View of no sectors has none.

Jump to

Keyboard shortcuts

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