collide

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 8 Imported by: 2 modules, 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 collide finds and separates overlapping boxes of a Space: BroadPhase names the pairs that may touch, a NarrowPhase gathers them as Pairs, and Separate tests each exactly and pushes the overlapping apart.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadPhase

func BroadPhase(space *aabbworld.Space, reach float64, want aabbworld.Capability, fn func(a, b uid.UID64))

BroadPhase calls fn once per pair sharing want that may touch in a step of reach × shorter side.

Types

type NarrowPhase

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

NarrowPhase tests a batch of candidate pairs exactly and separates the ones that overlap. The zero value is ready, buffers are reused between batches; one serves one goroutine.

func (*NarrowPhase) Add

func (n *NarrowPhase) Add(p Pair) int

Add enters a pair into the batch and returns the index onContact and whose name it by.

func (*NarrowPhase) Left

func (n *NarrowPhase) Left() []uid.UID64

Left is who the last Separate pushed out through an open edge; good until the next Reset.

func (*NarrowPhase) Reset

func (n *NarrowPhase) Reset()

Reset empties the batch, keeping the memory.

func (*NarrowPhase) Separate

func (n *NarrowPhase) Separate(
	space *aabbworld.Space, iterations int,
	onContact func(i int, pen geom.Vec), whose func(i int) (a, b uid.UID64),
)

Separate reports each overlap once, pushes it apart, and reindexes what moved as whose names it.

type Pair

type Pair struct {
	A, B             *plane.AABB
	KeyA, KeyB       uint32 // one key per box across the batch; zero measures every pass
	StaticA, StaticB bool
	Sensor           bool
}

Pair is two boxes that may be in contact; the narrow phase moves them in place through A and B. A static side is never moved; a Sensor pair is reported but never separated.

Jump to

Keyboard shortcuts

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