spatial

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IntGroup added in v0.4.2

type IntGroup struct {
	ID, Idx, Len int
}

type IntNode added in v0.4.2

type IntNode struct {
	Groups []IntGroup
	Ints   []int
}

func (*IntNode) Collect added in v0.4.2

func (n *IntNode) Collect(group int, including bool, coll []int) []int

func (*IntNode) Insert added in v0.4.2

func (n *IntNode) Insert(item int, group int)

func (*IntNode) Remove added in v0.4.2

func (n *IntNode) Remove(item int, group int) bool

type Item added in v0.4.2

type Item generic.Type

type ItemGroup added in v0.4.2

type ItemGroup struct {
	ID, Idx, Len int
}

type ItemNode added in v0.4.2

type ItemNode struct {
	Groups []ItemGroup
	Items  []Item
}

func (*ItemNode) Collect added in v0.4.2

func (n *ItemNode) Collect(group int, including bool, coll []Item) []Item

func (*ItemNode) Insert added in v0.4.2

func (n *ItemNode) Insert(item Item, group int)

func (*ItemNode) Remove added in v0.4.2

func (n *ItemNode) Remove(item Item, group int) bool

type MinHash

type MinHash struct {
	Nodes []IntNode
	// contains filtered or unexported fields
}

MinHash is for efficient spatial hasher, tuned to perfection is able to handle thousands of entities for cost of using ids and limited space, if you will be dealing with concentrated entity use this over

func NMinHash

func NMinHash(w, h int, tileSize mat.Vec) MinHash

NMinHash is MinHash constructor

func (*MinHash) Adr

func (h *MinHash) Adr(pos mat.Vec) mat.Point

Adr returns node, position belongs to

func (*MinHash) Insert

func (h *MinHash) Insert(adr *mat.Point, pos mat.Vec, id, group int)

Insert adds shape to MinHash

func (*MinHash) Query

func (h *MinHash) Query(rect mat.AABB, coll []int, group int, including bool) []int

Query returns colliding shapes with given rect

func (*MinHash) Remove

func (h *MinHash) Remove(adr mat.Point, id, group int) bool

Remove removes shape from MinHash. If operation fails, false is returned

func (*MinHash) TileSize

func (h *MinHash) TileSize() mat.Vec

TileSize ...

func (*MinHash) Update

func (h *MinHash) Update(old *mat.Point, pos mat.Vec, id, group int) bool

Update updates state of object if it changed quadrant, if operation fails, false is returned

type QuadNode added in v0.4.2

type QuadNode struct {
	IntNode
	mat.AABB

	Children, Level, Parent, Self int
	Branch, Closed                bool
}

type QuadTree added in v0.4.2

type QuadTree struct {
	Bounds            mat.AABB
	Nodes             []QuadNode
	NodeCap, DepthCap int
}

func (*QuadTree) Close added in v0.4.2

func (t *QuadTree) Close(node int)

func (*QuadTree) Count added in v0.4.2

func (t *QuadTree) Count(node int) (count int)

func (*QuadTree) Debug added in v0.4.2

func (t *QuadTree) Debug(depth, node int) string

FormatDebug makes a readable formatting of tree structure

func (*QuadTree) Insert added in v0.4.2

func (t *QuadTree) Insert(address *int, bounds mat.AABB, id, group int) bool

func (*QuadTree) Query added in v0.4.2

func (t *QuadTree) Query(group int, include bool, area mat.AABB, helpers ...[]int) (coll, frontier, temp []int)

func (*QuadTree) Remove added in v0.4.2

func (t *QuadTree) Remove(address, id, group int) bool

func (*QuadTree) ShouldSplit added in v0.4.2

func (t *QuadTree) ShouldSplit(n *QuadNode) bool

func (*QuadTree) Split added in v0.4.2

func (t *QuadTree) Split(node int)

func (*QuadTree) Update added in v0.4.2

func (t *QuadTree) Update(address *int, bounds mat.AABB, id, group int)

Jump to

Keyboard shortcuts

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