Documentation
¶
Index ¶
- type Bucket
- type BucketItem
- type CollisionSet
- type Hashmap
- func (h *Hashmap[T]) Add(shape Shape, val T)
- func (h *Hashmap[T]) BroadCheck(colSet CollisionSet[T], rect glm.Rect)
- func (h *Hashmap[T]) Check(colSet *CollisionSet[T], shape Shape)
- func (h *Hashmap[T]) Clear()
- func (h *Hashmap[T]) Collides(rect glm.Rect) bool
- func (h *Hashmap[T]) FindClosest(rect glm.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 glm.Vec2, val T)
- func (h *Pointmap[T]) AllIndexesInside(rect glm.Rect) iter.Seq[Index]
- func (h *Pointmap[T]) BroadCheck(list []T, bounds glm.Rect) []T
- func (h *Pointmap[T]) Clear()
- func (h *Pointmap[T]) Collides(bounds glm.Rect) bool
- func (h *Pointmap[T]) GetBucket(index Index) *PointBucket[T]
- func (h *Pointmap[T]) NarrowCheck(list []T, bounds glm.Rect) []T
- func (h *Pointmap[T]) Remove(pos glm.Vec2, val T)
- func (h *Pointmap[T]) RemoveCollides(bounds glm.Rect)
- type PositionHasher
- type Shape
- type ShapeType
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]) Check ¶
func (b *Bucket[T]) Check(colSet *CollisionSet[T], shape Shape)
func (*Bucket[T]) FindClosest ¶
func (b *Bucket[T]) FindClosest(shape Shape) (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], rect glm.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
func (*Hashmap[T]) Check ¶
func (h *Hashmap[T]) Check(colSet *CollisionSet[T], shape Shape)
Finds collisions and adds them directly into your collision set
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 glm.Vec2, val T)
func (*PointBucket[T]) Clear ¶
func (b *PointBucket[T]) Clear()
func (*PointBucket[T]) Length ¶
func (b *PointBucket[T]) Length() int
func (*PointBucket[T]) Remove ¶
func (b *PointBucket[T]) Remove(point glm.Vec2, val T)
func (*PointBucket[T]) RemoveCollides ¶
func (b *PointBucket[T]) RemoveCollides(bounds glm.Rect)
Remove every point that collides with the bucket
func (*PointBucket[T]) RemoveIndex ¶
func (b *PointBucket[T]) RemoveIndex(idx int)
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]) AllIndexesInside ¶
Iterates through all buckets inside the rectangle
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
func (*Pointmap[T]) RemoveCollides ¶
Remove every point that collides with the supplied bounds
type PositionHasher ¶
type PositionHasher struct {
// contains filtered or unexported fields
}
--------------------------------------------------------------------------------
func NewPositionHasher ¶
func NewPositionHasher(size [2]int) PositionHasher
func (*PositionHasher) IndexToRect ¶
func (h *PositionHasher) IndexToRect(index Index) glm.Rect
func (*PositionHasher) PositionToIndex ¶
func (h *PositionHasher) PositionToIndex(pos glm.Vec2) Index