Documentation
¶
Index ¶
- type Globals
- type MinHash
- func (h *MinHash) Adr(pos mat.Vec) mat.Point
- func (h *MinHash) Insert(adr *mat.Point, pos mat.Vec, id, group int)
- func (h *MinHash) Query(rect mat.AABB, coll []int, group int, including bool) []int
- func (h *MinHash) Remove(adr mat.Point, id, group int) bool
- func (h *MinHash) TileSize() mat.Vec
- func (h *MinHash) Update(old *mat.Point, pos mat.Vec, id, group int) bool
- type Node
- type Set
- type Set22
- type T
- type TNode
- type Tree
- func (t *Tree) Bail()
- func (t *Tree) FormatDebug(depth int) string
- func (t *Tree) Insert(te TreeEntity) bool
- func (t *Tree) Query(group int, include bool, coll []TreeEntity, area mat.AABB) []TreeEntity
- func (t *Tree) QueryAll(coll *[]TreeEntity, area mat.AABB)
- func (t *Tree) Remove(te TreeEntity) bool
- func (t *Tree) Split()
- func (t *Tree) TotalCount() (total int)
- func (t *Tree) Update() (count int)
- type TreeEntity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Globals ¶
type Globals struct { Cap int // contains filtered or unexported fields }
Globals stored data shared by all tree nodes
type MinHash ¶
type MinHash struct { Nodes []Node // 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
type Node ¶
Node keeps over all count of ids in sets for quick lookup Its a main building piece of hasher, as we do not expect big amounts of entities in a single node it does not use maps to store ids witch is not that elegant but fatser
func (*Node) Collect ¶
Collect retrieve ids from a node to coll, if include is true only ids of given group will get collected, otherwise ewerithing but specified group is returned
func (*Node) CollectAll ¶
CollectAll colects all objects withoud differentiating a group
type Set22 ¶
type Set22 struct { Group int IDs []TreeEntity }
Set22 is an id set that also has a group important for node
type TNode ¶
TNode keeps over all count of ids in sets for quick lookup Its a main building piece of hasher, as we do not expect big amounts of entities in a single node it does not use maps to store ids witch is not that elegant but fatser
func (*TNode) Collect ¶
func (n *TNode) Collect(group int, include bool, coll []TreeEntity) []TreeEntity
Collect retrieve ids from a node to coll, if include is true only ids of given group will get collected, otherwise ewerithing but specified group is returned
func (*TNode) CollectAll ¶
func (n *TNode) CollectAll(coll *[]TreeEntity)
CollectAll colects all objects withoud differentiating a group
func (*TNode) Remove ¶
func (n *TNode) Remove(id TreeEntity, group int) bool
Remove panics if id does not exist within the node, you always have to make sure you are removing correctly as leaving dead ids in a hasher is leaking of memory
method panics if object you tried to remove is not present to remove
type Tree ¶
Tree is a quadtree that prefers updating over reinseting. If you have to detect collizions between big amount of objects with variety of shape sizes this is a good pick, use hasher instead if you are using lot of same sized objects
Tree has to be initialized with NTree as Tree.Globals is pointer ¶
Tree is not fully tested feature
func (*Tree) FormatDebug ¶
FormatDebug makes a readable formatting of tree structure
func (*Tree) Insert ¶
func (t *Tree) Insert(te TreeEntity) bool
Insert inserts entity to tree, returns false if entity cannot be inserted
func (*Tree) Query ¶
func (t *Tree) Query(group int, include bool, coll []TreeEntity, area mat.AABB) []TreeEntity
Query returns all entities that can intersect with area, if include is false only entities with different group are returned, othervise entities with sam group are returned, using QueryAll if you don't need all groups and filtering them your self is slower as Quadterr si structured to optimize the process
func (*Tree) QueryAll ¶
func (t *Tree) QueryAll(coll *[]TreeEntity, area mat.AABB)
QueryAll returns all Entities that area can intersect with
func (*Tree) Remove ¶
func (t *Tree) Remove(te TreeEntity) bool
Remove removes the entity, if there is no such entity, false is returned
func (*Tree) TotalCount ¶
TotalCount returns total count of children in Tree