Documentation ¶
Index ¶
- type Bucket
- type BucketItem
- type CollisionSet
- type Hashmap
- func (h *Hashmap[T]) Add(shape phy2.Rect, val T)
- func (h *Hashmap[T]) BroadCheck(colSet CollisionSet[T], shape phy2.Rect)
- func (h *Hashmap[T]) Check(colSet *CollisionSet[T], shape phy2.Rect)
- func (h *Hashmap[T]) Clear()
- func (h *Hashmap[T]) Collides(shape phy2.Rect) bool
- func (h *Hashmap[T]) FindClosest(shape phy2.Rect) (T, bool)
- func (h *Hashmap[T]) GetBucket(index Index) *Bucket[T]
- func (h *Hashmap[T]) Remove(val T)
- type Index
- type PointBucket
- type PointBucketItem
- type Pointmap
- func (h *Pointmap[T]) Add(pos phy2.Vec, val T)
- func (h *Pointmap[T]) BroadCheck(list []T, bounds phy2.Rect) []T
- func (h *Pointmap[T]) Clear()
- func (h *Pointmap[T]) Collides(bounds phy2.Rect) bool
- func (h *Pointmap[T]) GetBucket(index Index) *PointBucket[T]
- func (h *Pointmap[T]) NarrowCheck(list []T, bounds phy2.Rect) []T
- type PositionHasher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket[T comparable] struct { List []BucketItem[T] }
func NewBucket ¶
func NewBucket[T comparable]() *Bucket[T]
func (*Bucket[T]) FindClosest ¶
func (b *Bucket[T]) FindClosest(shape phy2.Rect) (BucketItem[T], bool)
type BucketItem ¶
type BucketItem[T comparable] struct { // contains filtered or unexported fields }
type CollisionSet ¶
type CollisionSet[T comparable] struct { List []T }
func NewCollisionSet ¶
func NewCollisionSet[T comparable](cap int) *CollisionSet[T]
func (*CollisionSet[T]) Add ¶
func (s *CollisionSet[T]) Add(t T)
func (*CollisionSet[T]) Clear ¶
func (s *CollisionSet[T]) Clear()
type Hashmap ¶
type Hashmap[T comparable] struct { PositionHasher Bucket *arrayMap[Bucket[T]] // contains filtered or unexported fields }
-------------------------------------------------------------------------------- TODO: rename? ColliderMap?
func NewHashmap ¶
func NewHashmap[T comparable](chunksize [2]int, startingSize int) *Hashmap[T]
func (*Hashmap[T]) BroadCheck ¶
func (h *Hashmap[T]) BroadCheck(colSet CollisionSet[T], shape phy2.Rect)
Adds the collisions directly into your collision set. This one doesnt' do any narrow phase detection. It returns all objects that collide with the same chunk
type PointBucket ¶
type PointBucket[T comparable] struct { List []PointBucketItem[T] }
func NewPointBucket ¶
func NewPointBucket[T comparable]() *PointBucket[T]
func (*PointBucket[T]) Add ¶
func (b *PointBucket[T]) Add(point phy2.Vec, val T)
func (*PointBucket[T]) Clear ¶
func (b *PointBucket[T]) Clear()
type PointBucketItem ¶
type PointBucketItem[T comparable] struct { // contains filtered or unexported fields }
type Pointmap ¶
type Pointmap[T comparable] struct { PositionHasher Bucket *arrayMap[PointBucket[T]] // contains filtered or unexported fields }
TODO: rename? ColliderMap?
func NewPointmap ¶
func NewPointmap[T comparable](chunksize [2]int, startingSize int) *Pointmap[T]
func (*Pointmap[T]) BroadCheck ¶
TODO: Right now this does a broad phased check Adds the collisions directly into your collision list. Items are deduplicated by nature of them only existing once in this Pointmap. (ie if you add multiple of the same thing, you might get multiple out)
func (*Pointmap[T]) Collides ¶
TODO: This only does a broadphase check. no narrow phase Returns true if the bounds collides with anything
func (*Pointmap[T]) GetBucket ¶
func (h *Pointmap[T]) GetBucket(index Index) *PointBucket[T]
func (*Pointmap[T]) NarrowCheck ¶
TODO: I think I'd rather the default for this be called "Check" then have the other be called CheckBroad or something
type PositionHasher ¶
type PositionHasher struct {
// contains filtered or unexported fields
}
--------------------------------------------------------------------------------
func NewPositionHasher ¶
func NewPositionHasher(size [2]int) PositionHasher
func (*PositionHasher) PositionToIndex ¶
func (h *PositionHasher) PositionToIndex(pos phy2.Vec) Index