Documentation
¶
Index ¶
- Constants
- func BroadPhase(spatialGrid *SpatialGrid, bodies []*actor.RigidBody, workersCount int) <-chan Pair
- func EPA(p <-chan CollisionPair, workersCount int) <-chan *constraint.ContactConstraint
- func GJK(pairChan <-chan Pair, workersCount int) <-chan CollisionPair
- func NarrowPhase(pairs <-chan Pair, workersCount int) []*constraint.ContactConstraint
- type Cell
- type CellKey
- type CollisionEnterEvent
- type CollisionExitEvent
- type CollisionPair
- type CollisionStayEvent
- type Event
- type EventListener
- type EventType
- type Events
- type Pair
- type SleepEvent
- type SpatialGrid
- type TriggerEnterEvent
- type TriggerExitEvent
- type TriggerStayEvent
- type WakeEvent
- type World
Constants ¶
const ( CONCRETE_COMPLIANCE = 0.04e-9 WOOD_COMPLIANCE = 0.16e-9 LEATHER_COMPLIANCE = 14e-8 TENDON_COMPLIANCE = 0.2e-7 RUBBER_COMPLIANCE = 1e-6 MUSCLE_COMPLIANCE = 0.2e-3 FAT_COMPLIANCE = 1e-3 )
const DEFAULT_WORKERS = 1
const STIFF_COMPLIANCE = CONCRETE_COMPLIANCE
Variables ¶
This section is empty.
Functions ¶
func BroadPhase ¶
func BroadPhase(spatialGrid *SpatialGrid, bodies []*actor.RigidBody, workersCount int) <-chan Pair
BroadPhase performs broad-phase collision detection using AABB overlap tests It returns pairs of bodies whose AABBs overlap and might be colliding This is an O(n²) brute-force approach suitable for small numbers of bodies
func EPA ¶
func EPA(p <-chan CollisionPair, workersCount int) <-chan *constraint.ContactConstraint
func GJK ¶
func GJK(pairChan <-chan Pair, workersCount int) <-chan CollisionPair
func NarrowPhase ¶
func NarrowPhase(pairs <-chan Pair, workersCount int) []*constraint.ContactConstraint
Types ¶
type Cell ¶
type Cell struct {
// contains filtered or unexported fields
}
Cell - Container of body indices in a cell
type CollisionEnterEvent ¶ added in v0.2.0
Collision events
func (CollisionEnterEvent) Type ¶ added in v0.2.0
func (e CollisionEnterEvent) Type() EventType
type CollisionExitEvent ¶ added in v0.2.0
func (CollisionExitEvent) Type ¶ added in v0.2.0
func (e CollisionExitEvent) Type() EventType
type CollisionPair ¶
type CollisionPair struct {
BodyA *actor.RigidBody
BodyB *actor.RigidBody
// contains filtered or unexported fields
}
CollisionPair represents a pair of rigid bodies that potentially collide
type CollisionStayEvent ¶ added in v0.2.0
func (CollisionStayEvent) Type ¶ added in v0.2.0
func (e CollisionStayEvent) Type() EventType
type Event ¶ added in v0.2.0
type Event interface {
Type() EventType
}
Event interface - all events implement this
type EventListener ¶ added in v0.2.0
type EventListener func(event Event)
EventListener - callback for events
type Events ¶ added in v0.2.0
type Events struct {
// contains filtered or unexported fields
}
Events manager
func (*Events) Subscribe ¶ added in v0.2.0
func (e *Events) Subscribe(eventType EventType, listener EventListener)
Subscribe adds a listener for an event type
type SleepEvent ¶ added in v0.2.0
Sleep/Wake events
func (SleepEvent) Type ¶ added in v0.2.0
func (e SleepEvent) Type() EventType
type SpatialGrid ¶
type SpatialGrid struct {
// contains filtered or unexported fields
}
SpatialGrid - Uniform spatial grid with hashing for broad phase
func NewSpatialGrid ¶
func NewSpatialGrid(cellSize float64, numCells int) *SpatialGrid
NewSpatialGrid - Creates a new spatial grid
func (*SpatialGrid) Clear ¶
func (sg *SpatialGrid) Clear()
Clear - Resets the spatial grid by clearing all body indices from cells and planes
func (*SpatialGrid) FindPairsParallel ¶
func (sg *SpatialGrid) FindPairsParallel(bodies []*actor.RigidBody, workersCount int) <-chan Pair
FindPairsParallel - Parallel version returning a channel
func (*SpatialGrid) Insert ¶
func (sg *SpatialGrid) Insert(bodyIndex int, body *actor.RigidBody)
Insert - Inserts a body into all cells it occupies
func (*SpatialGrid) SortCells ¶
func (sg *SpatialGrid) SortCells()
SortCells - Sorts body indices within each cell for optimized collision detection
type TriggerEnterEvent ¶ added in v0.2.0
Trigger events
func (TriggerEnterEvent) Type ¶ added in v0.2.0
func (e TriggerEnterEvent) Type() EventType
type TriggerExitEvent ¶ added in v0.2.0
func (TriggerExitEvent) Type ¶ added in v0.2.0
func (e TriggerExitEvent) Type() EventType
type TriggerStayEvent ¶ added in v0.2.0
func (TriggerStayEvent) Type ¶ added in v0.2.0
func (e TriggerStayEvent) Type() EventType
type World ¶
type World struct {
// List of all rigid bodies in the world
Bodies []*actor.RigidBody
// Gravity acceleration (m/s², or N/kg)
Gravity mgl64.Vec3
Substeps int
SpatialGrid *SpatialGrid
Workers int
Events Events
}
func (*World) RemoveBody ¶
RemoveBody removes a rigid body from the world
Directories
¶
| Path | Synopsis |
|---|---|
|
Package epa implements the Expanding Polytope Algorithm for computing penetration depth.
|
Package epa implements the Expanding Polytope Algorithm for computing penetration depth. |
|
Package gjk implements the Gilbert-Johnson-Keerthi (GJK) algorithm for collision detection.
|
Package gjk implements the Gilbert-Johnson-Keerthi (GJK) algorithm for collision detection. |