Documentation ¶
Index ¶
- Constants
- Variables
- func AlwaysCollide(_ *Arbiter, _ *Space, _ interface{}) bool
- func AreaForCircle(r1, r2 float64) float64
- func AreaForPoly(count int, verts []Vector, r float64) float64
- func AreaForSegment(a, b Vector, r float64) float64
- func BodyUpdatePosition(body *Body, dt float64)
- func BodyUpdateVelocity(body *Body, gravity Vector, damping, dt float64)
- func CachedArbitersFilter(arb *Arbiter, space *Space, shape *Shape, body *Body) bool
- func CircleSegmentQuery(shape *Shape, center Vector, r1 float64, a, b Vector, r2 float64, ...)
- func CircleToCircle(a, b *Shape, info *CollisionInfo)
- func CircleToPoly(a, b *Shape, info *CollisionInfo)
- func CircleToSegment(a, b *Shape, info *CollisionInfo)
- func Clamp(f, min, max float64) float64
- func Clamp01(f float64) float64
- func CollisionError(a, b *Shape, info *CollisionInfo)
- func ComponentActive(root *Body, threshold float64) bool
- func ContactPoints(e1, e2 *Edge, points ClosestPoints, info *CollisionInfo)
- func Contains(bodies []*Body, body *Body) bool
- func ConvexHull(count int, verts []Vector, first *int, tol float64) int
- func DebugInfo(space *Space) string
- func DefaultBegin(arb *Arbiter, space *Space, _ interface{}) bool
- func DefaultPostSolve(arb *Arbiter, space *Space, _ interface{})
- func DefaultPreSolve(arb *Arbiter, space *Space, _ interface{}) bool
- func DefaultSeparate(arb *Arbiter, space *Space, _ interface{})
- func DefaultSpringForce(spring *DampedSpring, dist float64) float64
- func DoNothing(_ *Arbiter, _ *Space, _ interface{})
- func DrawConstraint(constraint *Constraint, options Drawer)
- func DrawShape(shape *Shape, options Drawer)
- func DrawSpace(space *Space, options Drawer)
- func FloodFillComponent(root *Body, body *Body)
- func Lerp(f1, f2, t float64) float64
- func LerpConst(f1, f2, d float64) float64
- func LoopIndexes(verts []Vector, count int) (int, int)
- func MomentForBox(m, width, height float64) float64
- func MomentForBox2(m float64, box BB) float64
- func MomentForCircle(m, r1, r2 float64, offset Vector) float64
- func MomentForPoly(m float64, count int, verts []Vector, offset Vector, r float64) float64
- func MomentForSegment(m float64, a, b Vector, r float64) float64
- func NearestPointQueryNearest(obj interface{}, shape *Shape, collisionId uint32, out interface{}) uint32
- func NodeSetA(node, value *Node)
- func NodeSetB(node, value *Node)
- func PolySupportPointIndex(count int, planes []SplittingPlane, n Vector) int
- func PolyToPoly(a, b *Shape, info *CollisionInfo)
- func PostStepDoNothing(space *Space, key, data interface{})
- func QHullPartition(verts []Vector, count int, a, b Vector, tol float64) int
- func QHullReduce(tol float64, verts []Vector, count int, a, pivot, b Vector, result []Vector) int
- func QueryReject(a, b *Shape) bool
- func QueryRejectConstraints(a, b *Body) bool
- func SegmentToPoly(seg, poly *Shape, info *CollisionInfo)
- func SegmentToSegment(a, b *Shape, info *CollisionInfo)
- func SpaceArbiterSetFilter(arb *Arbiter, space *Space) bool
- func SpaceCollideShapesFunc(obj interface{}, b *Shape, collisionId uint32, vspace interface{}) uint32
- func VoidQueryFunc(obj1 interface{}, obj2 *Shape, collisionId uint32, data interface{}) uint32
- type Arbiter
- func (arbiter *Arbiter) ApplyCachedImpulse(dt_coef float64)
- func (arbiter *Arbiter) ApplyImpulse()
- func (arb *Arbiter) Bodies() (*Body, *Body)
- func (arb *Arbiter) CallWildcardBeginA(space *Space) bool
- func (arb *Arbiter) CallWildcardBeginB(space *Space) bool
- func (arb *Arbiter) CallWildcardPostSolveA(space *Space)
- func (arb *Arbiter) CallWildcardPostSolveB(space *Space)
- func (arb *Arbiter) CallWildcardPreSolveA(space *Space) bool
- func (arb *Arbiter) CallWildcardPreSolveB(space *Space) bool
- func (arb *Arbiter) CallWildcardSeparateA(space *Space)
- func (arb *Arbiter) CallWildcardSeparateB(space *Space)
- func (arb *Arbiter) ContactPointSet() ContactPointSet
- func (arb *Arbiter) Count() int
- func (arb *Arbiter) Ignore() bool
- func (arbiter *Arbiter) Init(a, b *Shape) *Arbiter
- func (arbiter *Arbiter) IsFirstContact() bool
- func (node *Arbiter) Next(body *Body) *Arbiter
- func (arb *Arbiter) Normal() Vector
- func (arb *Arbiter) PreStep(dt, slop, bias float64)
- func (arb *Arbiter) SetContactPointSet(set *ContactPointSet)
- func (arb *Arbiter) Shapes() (*Shape, *Shape)
- func (arbiter *Arbiter) ThreadForBody(body *Body) *ArbiterThread
- func (arb *Arbiter) TotalImpulse() Vector
- func (arbiter *Arbiter) Unthread()
- func (arb *Arbiter) Update(info *CollisionInfo, space *Space)
- type ArbiterThread
- type BB
- func (bb BB) Area() float64
- func (bb BB) Center() Vector
- func (bb BB) ClampVect(v *Vector) Vector
- func (bb BB) Contains(other BB) bool
- func (bb BB) ContainsVect(v Vector) bool
- func (bb BB) Expand(v Vector) BB
- func (a BB) Intersects(b BB) bool
- func (bb BB) IntersectsSegment(a, b Vector) bool
- func (a BB) Merge(b BB) BB
- func (a BB) MergedArea(b BB) float64
- func (bb BB) Offset(v Vector) BB
- func (a BB) Proximity(b BB) float64
- func (bb BB) SegmentQuery(a, b Vector) float64
- func (bb BB) String() string
- func (bb BB) WrapVect(v Vector) Vector
- type BBTree
- func (tree *BBTree) Contains(obj *Shape, hashId HashValue) bool
- func (tree *BBTree) Count() int
- func (tree *BBTree) Destroy()
- func (tree *BBTree) Each(f SpatialIndexIterator)
- func (tree *BBTree) GetBB(obj *Shape) BB
- func (tree *BBTree) GetMasterTree() *BBTree
- func (tree *BBTree) IncrementStamp()
- func (tree *BBTree) Insert(obj *Shape, hashId HashValue)
- func (tree *BBTree) LeafAddPairs(leaf *Node)
- func (tree *BBTree) LeafUpdate(leaf *Node) bool
- func (tree *BBTree) NewLeaf(obj *Shape) *Node
- func (tree *BBTree) NewNode(a, b *Node) *Node
- func (tree *BBTree) NodeFromPool() *Node
- func (subtree *BBTree) PairFromPool() *Pair
- func (tree *BBTree) PairInsert(a *Node, b *Node)
- func (tree *BBTree) PairsClear(leaf *Node)
- func (tree *BBTree) Query(obj interface{}, bb BB, f SpatialIndexQuery, data interface{})
- func (tree *BBTree) RecycleNode(node *Node)
- func (tree *BBTree) RecyclePair(pair *Pair)
- func (tree *BBTree) Reindex()
- func (tree *BBTree) ReindexObject(obj *Shape, hashId HashValue)
- func (tree *BBTree) ReindexQuery(f SpatialIndexQuery, data interface{})
- func (tree *BBTree) Remove(obj *Shape, hashId HashValue)
- func (tree *BBTree) ReplaceChild(parent, child, value *Node)
- func (tree *BBTree) SegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, ...)
- func (tree *BBTree) SubtreeInsert(subtree *Node, leaf *Node) *Node
- func (tree *BBTree) SubtreeRemove(subtree *Node, leaf *Node) *Node
- type BBTreeVelocityFunc
- type Body
- func (body *Body) AccumulateMassFromShapes()
- func (body *Body) Activate()
- func (body *Body) ActivateStatic(filter *Shape)
- func (body *Body) AddShape(shape *Shape) *Shape
- func (body *Body) Angle() float64
- func (body *Body) AngularVelocity() float64
- func (body *Body) ApplyForceAtLocalPoint(force, point Vector)
- func (body *Body) ApplyForceAtWorldPoint(force, point Vector)
- func (body *Body) ApplyImpulseAtLocalPoint(impulse, point Vector)
- func (body *Body) ApplyImpulseAtWorldPoint(impulse, point Vector)
- func (body Body) CenterOfGravity() Vector
- func (root *Body) ComponentAdd(body *Body)
- func (body *Body) ComponentRoot() *Body
- func (body *Body) EachArbiter(f func(*Arbiter))
- func (body *Body) EachConstraint(f func(*Constraint))
- func (body *Body) EachShape(f func(*Shape))
- func (body *Body) Force() Vector
- func (body *Body) GetType() int
- func (body *Body) IdleTime() float64
- func (body *Body) IsSleeping() bool
- func (body *Body) KineticEnergy() float64
- func (body *Body) LocalToWorld(point Vector) Vector
- func (body *Body) Mass() float64
- func (body Body) Moment() float64
- func (body *Body) Position() Vector
- func (body *Body) PushArbiter(arb *Arbiter)
- func (body *Body) RemoveConstraint(constraint *Constraint)
- func (body *Body) RemoveShape(shape *Shape)
- func (body *Body) Rotation() Vector
- func (body *Body) SetAngle(angle float64)
- func (body *Body) SetAngularVelocity(angularVelocity float64)
- func (body *Body) SetForce(force Vector)
- func (body *Body) SetMass(mass float64)
- func (body *Body) SetMoment(moment float64)
- func (body *Body) SetPosition(position Vector)
- func (body *Body) SetPositionUpdateFunc(f BodyPositionFunc)
- func (body *Body) SetTransform(p Vector, a float64)
- func (body *Body) SetType(newType int)
- func (body *Body) SetVelocity(x, y float64)
- func (body *Body) SetVelocityUpdateFunc(f BodyVelocityFunc)
- func (body *Body) SetVelocityVector(v Vector)
- func (b Body) String() string
- func (body *Body) UpdateVelocity(gravity Vector, damping, dt float64)
- func (body *Body) Velocity() Vector
- func (body *Body) VelocityAtLocalPoint(point Vector) Vector
- func (body *Body) VelocityAtWorldPoint(point Vector) Vector
- func (body *Body) WorldToLocal(point Vector) Vector
- type BodyPositionFunc
- type BodyVelocityFunc
- type Children
- type Circle
- func (circle *Circle) CacheData(transform Transform) BB
- func (*Circle) Destroy()
- func (circle *Circle) PointQuery(p Vector, info *PointQueryInfo)
- func (circle *Circle) Radius() float64
- func (circle *Circle) SegmentQuery(a, b Vector, radius float64, info *SegmentQueryInfo)
- func (circle *Circle) SetRadius(r float64)
- func (circle *Circle) TransformC() Vector
- type ClosestPoints
- func EPA(ctx *SupportContext, v0 MinkowskiPoint, v1 MinkowskiPoint, v2 MinkowskiPoint) ClosestPoints
- func EPARecurse(ctx *SupportContext, count int, hull []MinkowskiPoint, iteration int) ClosestPoints
- func GJK(ctx *SupportContext, collisionId *uint32) ClosestPoints
- func GJKRecurse(ctx *SupportContext, v0, v1 MinkowskiPoint, iteration int) ClosestPoints
- type CollisionBeginFunc
- type CollisionFunc
- type CollisionHandler
- type CollisionInfo
- type CollisionPostSolveFunc
- type CollisionPreSolveFunc
- type CollisionSeparateFunc
- type CollisionType
- type Constrainer
- type Constraint
- func NewConstraint(class Constrainer, a, b *Body) *Constraint
- func NewDampedRotarySpring(a, b *Body, restAngle, stiffness, damping float64) *Constraint
- func NewDampedSpring(a, b *Body, anchorA, anchorB Vector, restLength, stiffness, damping float64) *Constraint
- func NewGearJoint(a, b *Body, phase, ratio float64) *Constraint
- func NewGrooveJoint(a, b *Body, grooveA, grooveB, anchorB Vector) *Constraint
- func NewPinJoint(a, b *Body, anchorA, anchorB Vector) *Constraint
- func NewPivotJoint(a, b *Body, pivot Vector) *Constraint
- func NewPivotJoint2(a, b *Body, anchorA, anchorB Vector) *Constraint
- func NewRatchetJoint(a, b *Body, phase, ratchet float64) *Constraint
- func NewRotaryLimitJoint(a, b *Body, min, max float64) *Constraint
- func NewSimpleMotor(a, b *Body, rate float64) *Constraint
- func NewSlideJoint(a, b *Body, anchorA, anchorB Vector, min, max float64) *Constraint
- func (c *Constraint) ActivateBodies()
- func (c Constraint) ErrorBias() float64
- func (c Constraint) MaxBias() float64
- func (c Constraint) MaxForce() float64
- func (c *Constraint) Next(body *Body) *Constraint
- func (c *Constraint) SetCollideBodies(collideBodies bool)
- func (c *Constraint) SetErrorBias(errorBias float64)
- func (c *Constraint) SetMaxBias(max float64)
- func (c *Constraint) SetMaxForce(max float64)
- type ConstraintPostSolveFunc
- type ConstraintPreSolveFunc
- type Contact
- type ContactBuffer
- type ContactPointSet
- type DampedRotarySpring
- type DampedSpring
- type DampedSpringForceFunc
- type Drawer
- type Edge
- type EdgePoint
- type FColor
- type GearJoint
- type GrooveJoint
- type Handle
- type HashSet
- func (set *HashSet) Count() uint
- func (set *HashSet) Each(f HashSetIterator)
- func (set *HashSet) Filter(f HashSetFilter, data interface{})
- func (set *HashSet) Find(hash HashValue, ptr interface{}) interface{}
- func (set *HashSet) Free()
- func (set *HashSet) GetUnusedBin() *HashSetBin
- func (set *HashSet) Insert(hash HashValue, ptr interface{}, trans HashSetTrans, data interface{}) interface{}
- func (set *HashSet) Recycle(bin *HashSetBin)
- func (set *HashSet) Remove(hash HashValue, ptr interface{}) interface{}
- func (set *HashSet) Resize()
- type HashSetArbiter
- func (set *HashSetArbiter) Count() uint
- func (set *HashSetArbiter) Each(f HashSetIteratorArbiter)
- func (set *HashSetArbiter) Filter(filter func(arb *Arbiter) bool)
- func (set *HashSetArbiter) Find(hash HashValue, ptr []*Shape) interface{}
- func (set *HashSetArbiter) Free()
- func (set *HashSetArbiter) GetUnusedBin() *HashSetBinArbiter
- func (set *HashSetArbiter) Insert(hash HashValue, ptr []*Shape, trans HashSetTransArbiter, space *Space) *Arbiter
- func (set *HashSetArbiter) InsertArb(hash HashValue, ptr []*Shape, arb *Arbiter) interface{}
- func (set *HashSetArbiter) Recycle(bin *HashSetBinArbiter)
- func (set *HashSetArbiter) Remove(hash HashValue, ptr []*Shape) *Arbiter
- func (set *HashSetArbiter) Resize()
- type HashSetBin
- type HashSetBinArbiter
- type HashSetBinCollisionHandler
- type HashSetBinHandle
- type HashSetCollisionHandler
- func (set *HashSetCollisionHandler) Count() uint
- func (set *HashSetCollisionHandler) Each(f HashSetIterator)
- func (set *HashSetCollisionHandler) Find(hash HashValue, ptr *CollisionHandler) *CollisionHandler
- func (set *HashSetCollisionHandler) Insert(hash HashValue, ptr *CollisionHandler) *CollisionHandler
- func (set *HashSetCollisionHandler) Resize()
- type HashSetEqual
- type HashSetEqualArbiter
- type HashSetEqualCollisionHandler
- type HashSetEqualHandle
- type HashSetFilter
- type HashSetFilterArbiter
- type HashSetFilterCollisionHandler
- type HashSetFilterHandle
- type HashSetHandle
- func (set *HashSetHandle) Count() uint
- func (set *HashSetHandle) Each(f HashSetIteratorHandle)
- func (set *HashSetHandle) Find(hash HashValue, ptr *Shape) interface{}
- func (set *HashSetHandle) Free()
- func (set *HashSetHandle) GetUnusedBin() *HashSetBinHandle
- func (set *HashSetHandle) Insert(hash HashValue, ptr *Shape, trans HashSetTransHandle, spaceHash *SpaceHash) *Handle
- func (set *HashSetHandle) InsertArb(hash HashValue, ptr *Shape, arb *Handle) interface{}
- func (set *HashSetHandle) Recycle(bin *HashSetBinHandle)
- func (set *HashSetHandle) Remove(hash HashValue, ptr *Shape) *Handle
- func (set *HashSetHandle) Resize()
- type HashSetIterator
- type HashSetIteratorArbiter
- type HashSetIteratorCollisionHandler
- type HashSetIteratorHandle
- type HashSetTrans
- type HashSetTransArbiter
- type HashSetTransCollisionHandler
- type HashSetTransHandle
- type HashValue
- type Leaf
- type MarkContext
- type Mat2x2
- type MinkowskiPoint
- type Node
- func (node *Node) IsLeaf() bool
- func (leaf *Node) MarkLeaf(context *MarkContext)
- func (subtree *Node) MarkLeafQuery(leaf *Node, left bool, context *MarkContext)
- func (subtree *Node) MarkSubtree(context *MarkContext)
- func (node *Node) Other(child *Node) *Node
- func (subtree *Node) SubtreeQuery(obj interface{}, bb BB, query SpatialIndexQuery, data interface{})
- func (subtree *Node) SubtreeSegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, ...) float64
- type Pair
- type PinJoint
- type PivotJoint
- type PointQueryContext
- type PointQueryInfo
- type PolyShape
- func (poly *PolyShape) CacheData(transform Transform) BB
- func (poly PolyShape) Count() int
- func (poly *PolyShape) Destroy()
- func (poly *PolyShape) PointQuery(p Vector, info *PointQueryInfo)
- func (poly PolyShape) Radius() float64
- func (poly *PolyShape) SegmentQuery(a, b Vector, r2 float64, info *SegmentQueryInfo)
- func (poly PolyShape) SetRadius(r float64)
- func (p *PolyShape) SetVerts(count int, verts []Vector)
- func (p *PolyShape) SetVertsRaw(count int, verts []Vector)
- func (p *PolyShape) SetVertsUnsafe(count int, verts []Vector, transform Transform)
- func (poly PolyShape) TransformVert(i int) Vector
- func (poly PolyShape) Vert(i int) Vector
- type PostStepCallback
- type PostStepCallbackFunc
- type RatchetJoint
- type RotaryLimitJoint
- type Segment
- func (seg *Segment) A() Vector
- func (seg *Segment) B() Vector
- func (seg *Segment) CacheData(transform Transform) BB
- func (seg *Segment) Destroy()
- func (seg *Segment) Normal() Vector
- func (seg *Segment) PointQuery(p Vector, info *PointQueryInfo)
- func (seg *Segment) Radius() float64
- func (seg *Segment) SegmentQuery(a, b Vector, r2 float64, info *SegmentQueryInfo)
- func (seg *Segment) SetEndpoints(a, b Vector)
- func (seg *Segment) SetRadius(r float64)
- func (seg *Segment) TransformA() Vector
- func (seg *Segment) TransformB() Vector
- type SegmentQueryContext
- type SegmentQueryInfo
- type Shape
- func NewBox(body *Body, w, h, r float64) *Shape
- func NewBox2(body *Body, bb BB, r float64) *Shape
- func NewCircle(body *Body, radius float64, offset Vector) *Shape
- func NewPolyShape(body *Body, vectCount int, verts []Vector, transform Transform, radius float64) *Shape
- func NewPolyShapeRaw(body *Body, count int, verts []Vector, radius float64) *Shape
- func NewSegment(body *Body, a, b Vector, r float64) *Shape
- func NewShape(class ShapeClass, body *Body, massInfo *ShapeMassInfo) *Shape
- func (s *Shape) BB() BB
- func (s *Shape) Body() *Body
- func (s *Shape) CacheBB() BB
- func (s *Shape) Elasticity() float64
- func (s *Shape) Friction() float64
- func (s *Shape) HashId() HashValue
- func (s *Shape) MassInfo() *ShapeMassInfo
- func (s *Shape) Order() int
- func (s *Shape) Point(i uint32) *SupportPoint
- func (s *Shape) PointQuery(p Vector) PointQueryInfo
- func (shape *Shape) SegmentQuery(a, b Vector, radius float64, info *SegmentQueryInfo) bool
- func (s *Shape) Sensor() bool
- func (s *Shape) SetBB(bb BB)
- func (s *Shape) SetCollisionType(collisionType CollisionType)
- func (s *Shape) SetElasticity(e float64)
- func (s *Shape) SetFilter(filter ShapeFilter)
- func (s *Shape) SetFriction(u float64)
- func (s *Shape) SetHashId(hashid HashValue)
- func (s *Shape) SetSensor(sensor bool)
- func (s *Shape) SetSpace(space *Space)
- func (s *Shape) SetSurfaceV(surfaceV Vector)
- func (s *Shape) Space() *Space
- func (s Shape) String() string
- func (s *Shape) Update(transform Transform) BB
- type ShapeClass
- type ShapeFilter
- type ShapeMassInfo
- type Shaper
- type SimpleMotor
- type SlideJoint
- type Space
- func (space *Space) Activate(body *Body)
- func (space *Space) AddBody(body *Body) *Body
- func (space *Space) AddConstraint(constraint *Constraint) *Constraint
- func (space *Space) AddPostStepCallback(f PostStepCallbackFunc, key, data interface{}) bool
- func (space *Space) AddShape(shape *Shape) *Shape
- func (space *Space) ArrayForBodyType(bodyType int) *[]*Body
- func (space *Space) ContactBufferGetArray() []Contact
- func (space *Space) ContainsBody(body *Body) bool
- func (space *Space) ContainsConstraint(constraint *Constraint) bool
- func (space *Space) ContainsShape(shape *Shape) bool
- func (space *Space) Damping() float64
- func (space *Space) Deactivate(body *Body)
- func (space *Space) EachBody(f func(body *Body))
- func (space *Space) EachConstraint(f func(*Constraint))
- func (space *Space) EachShape(f func(*Shape))
- func (space *Space) FilterArbiters(body *Body, filter *Shape)
- func (space *Space) Gravity() Vector
- func (space *Space) Lock()
- func (space *Space) LookupHandler(a, b CollisionType, defaultHandler *CollisionHandler) *CollisionHandler
- func (space *Space) NewCollisionHandler(collisionTypeA, collisionTypeB CollisionType) *CollisionHandler
- func (space *Space) NewWildcardCollisionHandler(collisionType CollisionType) *CollisionHandler
- func (space *Space) PointQueryNearest(point Vector, maxDistance float64, filter ShapeFilter) *PointQueryInfo
- func (space *Space) PopContacts(count int)
- func (space *Space) PostStepCallback(key interface{}) *PostStepCallback
- func (space *Space) ProcessComponents(dt float64)
- func (space *Space) PushContacts(count int)
- func (space *Space) PushFreshContactBuffer()
- func (space *Space) RemoveBody(body *Body)
- func (space *Space) RemoveConstraint(constraint *Constraint)
- func (space *Space) RemoveShape(shape *Shape)
- func (space *Space) SegmentQuery(start, end Vector, radius float64, filter ShapeFilter, f SpaceSegmentQueryFunc, ...)
- func (space *Space) SegmentQueryFirst(start, end Vector, radius float64, filter ShapeFilter) SegmentQueryInfo
- func (space *Space) SetCollisionSlop(slop float64)
- func (space *Space) SetDamping(damping float64)
- func (space *Space) SetGravity(gravity Vector)
- func (space *Space) SetStaticBody(body *Body)
- func (space *Space) Step(dt float64)
- func (space *Space) TimeStep() float64
- func (space *Space) UncacheArbiter(arb *Arbiter)
- func (space *Space) Unlock(runPostStep bool)
- func (space *Space) UseSpatialHash(dim float64, count int)
- func (space *Space) UseWildcardDefaultHandler()
- type SpaceHash
- func (hash *SpaceHash) Contains(obj *Shape, hashId HashValue) bool
- func (hash *SpaceHash) Count() int
- func (hash *SpaceHash) Destroy()
- func (hash *SpaceHash) Each(f SpatialIndexIterator)
- func (hash *SpaceHash) Insert(obj *Shape, hashId HashValue)
- func (hash *SpaceHash) Query(obj interface{}, bb BB, f SpatialIndexQuery, data interface{})
- func (hash *SpaceHash) Reindex()
- func (hash *SpaceHash) ReindexObject(obj *Shape, hashId HashValue)
- func (hash *SpaceHash) ReindexQuery(f SpatialIndexQuery, data interface{})
- func (hash *SpaceHash) Remove(obj *Shape, hashId HashValue)
- func (hash *SpaceHash) SegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, ...)
- type SpaceHashBin
- type SpacePointQueryFunc
- type SpaceSegmentQueryFunc
- type SpatialIndex
- type SpatialIndexBB
- type SpatialIndexIterator
- type SpatialIndexQuery
- type SpatialIndexSegmentQuery
- type SpatialIndexer
- type SplittingPlane
- type SupportContext
- type SupportPoint
- type SupportPointFunc
- type Thread
- type Transform
- func NewTransform(a, c, tx, b, d, ty float64) Transform
- func NewTransformIdentity() Transform
- func NewTransformRigid(translate Vector, radians float64) Transform
- func NewTransformRigidInverse(t Transform) Transform
- func NewTransformRotate(radians float64) Transform
- func NewTransformScale(scaleX, scaleY float64) Transform
- func NewTransformTranslate(translate Vector) Transform
- func NewTransformTranspose(a, c, tx, b, d, ty float64) Transform
- func (outer Transform) AxialScale(axis, pivot Vector, scale float64) Transform
- func (t Transform) BB(bb BB) BB
- func (outer Transform) BoneScale(v0, v1 Vector) Transform
- func (t Transform) Inverse() Transform
- func (t Transform) Mult(t2 Transform) Transform
- func (outer Transform) Ortho(bb BB) Transform
- func (t Transform) Point(p Vector) Vector
- func (t Transform) Vect(v Vector) Vector
- func (outer Transform) Wrap(inner Transform) Transform
- type Vector
- func (v Vector) Add(other Vector) Vector
- func (v0 Vector) CheckAxis(v1, p, n Vector) bool
- func (v Vector) Clamp(length float64) Vector
- func (p Vector) Clone() Vector
- func (v0 Vector) ClosestDist(v1 Vector) float64
- func (p Vector) ClosestPointOnSegment(a, b Vector) Vector
- func (a Vector) ClosestT(b Vector) float64
- func (v Vector) Cross(other Vector) float64
- func (v Vector) Distance(other Vector) float64
- func (v Vector) DistanceSq(other Vector) float64
- func (v Vector) Dot(other Vector) float64
- func (v Vector) Equal(other Vector) bool
- func (v Vector) Length() float64
- func (v Vector) LengthSq() float64
- func (v Vector) Lerp(other Vector, t float64) Vector
- func (v Vector) LerpConst(other Vector, d float64) Vector
- func (a Vector) LerpT(b Vector, t float64) Vector
- func (v Vector) Mult(s float64) Vector
- func (v Vector) Near(other Vector, d float64) bool
- func (v Vector) Neg() Vector
- func (v Vector) Normalize() Vector
- func (v Vector) Perp() Vector
- func (a Vector) PointGreater(b, c Vector) bool
- func (v Vector) Project(other Vector) Vector
- func (v Vector) ReversePerp() Vector
- func (v Vector) Rotate(other Vector) Vector
- func (v Vector) SLerp(other Vector, t float64) Vector
- func (v Vector) SlerpConst(other Vector, a float64) Vector
- func (v Vector) String() string
- func (v Vector) Sub(other Vector) Vector
- func (v Vector) ToAngle() float64
- func (v Vector) Unrotate(other Vector) Vector
Constants ¶
const ( BODY_DYNAMIC = iota BODY_KINEMATIC BODY_STATIC )
body types
const ( MAX_GJK_ITERATIONS = 30 MAX_EPA_ITERATIONS = 30 WARN_GJK_ITERATIONS = 20 WARN_EPA_ITERATIONS = 20 )
const ( DRAW_SHAPES = 1 << 0 DRAW_CONSTRAINTS = 1 << 1 DRAW_COLLISION_POINTS = 1 << 2 )
Draw flags
const ( INFINITY = math.MaxFloat64 MAGIC_EPSILON = 1e-5 RadianConst = math.Pi / 180 DegreeConst = 180 / math.Pi POOLED_BUFFER_SIZE = 1024 )
const ( // Arbiter is active and its the first collision. CP_ARBITER_STATE_FIRST_COLLISION = iota // Arbiter is active and its not the first collision. CP_ARBITER_STATE_NORMAL // Collision has been explicitly ignored. // Either by returning false from a begin collision handler or calling cpArbiterIgnore(). CP_ARBITER_STATE_IGNORE // Collison is no longer active. A space will cache an arbiter for up to cpSpace.collisionPersistence more steps. CP_ARBITER_STATE_CACHED // Collison arbiter is invalid because one of the shapes was removed. CP_ARBITER_STATE_INVALIDATED )
Arbiter states
const CONTACTS_BUFFER_SIZE = 1024
const HASH_COEF = 3344921057
const MAX_CONTACTS_PER_ARBITER = 2
const (
SHAPE_TYPE_NUM = 3
)
Variables ¶
var ( NO_GROUP uint = 0 ALL_CATEGORIES uint = ^uint(0) )
var BuiltinCollisionFuncs [9]CollisionFunc = [9]CollisionFunc{ CircleToCircle, CollisionError, CollisionError, CircleToSegment, SegmentToSegment, CollisionError, CircleToPoly, SegmentToPoly, PolyToPoly, }
var SHAPE_FILTER_ALL = ShapeFilter{NO_GROUP, ALL_CATEGORIES, ALL_CATEGORIES}
var SHAPE_FILTER_NONE = ShapeFilter{NO_GROUP, ^ALL_CATEGORIES, ^ALL_CATEGORIES}
var ShapeUpdateFunc = func(shape *Shape) {
shape.CacheBB()
}
var ShapeVelocityFunc = func(obj interface{}) Vector { return obj.(*Shape).body.v }
Functions ¶
func AlwaysCollide ¶
func AreaForCircle ¶
func AreaForSegment ¶
func BodyUpdatePosition ¶
func BodyUpdateVelocity ¶
func CachedArbitersFilter ¶
func CircleSegmentQuery ¶
func CircleToCircle ¶
func CircleToCircle(a, b *Shape, info *CollisionInfo)
func CircleToPoly ¶
func CircleToPoly(a, b *Shape, info *CollisionInfo)
func CircleToSegment ¶
func CircleToSegment(a, b *Shape, info *CollisionInfo)
func CollisionError ¶
func CollisionError(a, b *Shape, info *CollisionInfo)
func ComponentActive ¶
func ContactPoints ¶
func ContactPoints(e1, e2 *Edge, points ClosestPoints, info *CollisionInfo)
Given two support edges, find contact point pairs on their surfaces.
func ConvexHull ¶
QuickHull seemed like a neat algorithm, and efficient-ish for large input sets. My implementation performs an in place reduction using the result array as scratch space.
func DefaultBegin ¶
func DefaultPostSolve ¶
func DefaultPreSolve ¶
func DefaultSeparate ¶
func DefaultSpringForce ¶
func DefaultSpringForce(spring *DampedSpring, dist float64) float64
func DrawConstraint ¶
func DrawConstraint(constraint *Constraint, options Drawer)
func FloodFillComponent ¶
func MomentForBox ¶
func MomentForBox2 ¶
func MomentForCircle ¶
func MomentForPoly ¶
func PolySupportPointIndex ¶
func PolySupportPointIndex(count int, planes []SplittingPlane, n Vector) int
func PolyToPoly ¶
func PolyToPoly(a, b *Shape, info *CollisionInfo)
func PostStepDoNothing ¶
func PostStepDoNothing(space *Space, key, data interface{})
func QHullReduce ¶
func QueryReject ¶
func QueryRejectConstraints ¶
func SegmentToPoly ¶
func SegmentToPoly(seg, poly *Shape, info *CollisionInfo)
func SegmentToSegment ¶
func SegmentToSegment(a, b *Shape, info *CollisionInfo)
func SpaceArbiterSetFilter ¶
Hashset filter func to throw away old arbiters.
func SpaceCollideShapesFunc ¶
func VoidQueryFunc ¶
Types ¶
type Arbiter ¶
type Arbiter struct { UserData interface{} // contains filtered or unexported fields }
func ArbiterNext ¶
func SpaceArbiterSetTrans ¶
func (*Arbiter) ApplyCachedImpulse ¶
func (*Arbiter) ApplyImpulse ¶
func (arbiter *Arbiter) ApplyImpulse()
func (*Arbiter) CallWildcardBeginA ¶
func (*Arbiter) CallWildcardBeginB ¶
func (*Arbiter) CallWildcardPostSolveA ¶
func (*Arbiter) CallWildcardPostSolveB ¶
func (*Arbiter) CallWildcardPreSolveA ¶
func (*Arbiter) CallWildcardPreSolveB ¶
func (*Arbiter) CallWildcardSeparateA ¶
func (*Arbiter) CallWildcardSeparateB ¶
func (*Arbiter) ContactPointSet ¶
func (arb *Arbiter) ContactPointSet() ContactPointSet
func (*Arbiter) IsFirstContact ¶
func (*Arbiter) SetContactPointSet ¶
func (arb *Arbiter) SetContactPointSet(set *ContactPointSet)
func (*Arbiter) ThreadForBody ¶
func (arbiter *Arbiter) ThreadForBody(body *Body) *ArbiterThread
func (*Arbiter) TotalImpulse ¶
func (*Arbiter) Update ¶
func (arb *Arbiter) Update(info *CollisionInfo, space *Space)
type ArbiterThread ¶
type ArbiterThread struct {
// contains filtered or unexported fields
}
type BB ¶
type BB struct {
L, B, R, T float64
}
func NewBBForCircle ¶
func NewBBForExtents ¶
func ShapeGetBB ¶
func (BB) ContainsVect ¶
func (BB) Intersects ¶
func (BB) IntersectsSegment ¶
func (BB) MergedArea ¶
func (BB) SegmentQuery ¶
type BBTree ¶
type BBTree struct {
// contains filtered or unexported fields
}
func (*BBTree) Each ¶
func (tree *BBTree) Each(f SpatialIndexIterator)
func (*BBTree) GetMasterTree ¶
func (*BBTree) IncrementStamp ¶
func (tree *BBTree) IncrementStamp()
func (*BBTree) LeafAddPairs ¶
func (*BBTree) LeafUpdate ¶
func (*BBTree) NodeFromPool ¶
func (*BBTree) PairFromPool ¶
func (*BBTree) PairInsert ¶
func (*BBTree) PairsClear ¶
func (*BBTree) Query ¶
func (tree *BBTree) Query(obj interface{}, bb BB, f SpatialIndexQuery, data interface{})
func (*BBTree) RecycleNode ¶
func (*BBTree) RecyclePair ¶
func (*BBTree) ReindexObject ¶
func (*BBTree) ReindexQuery ¶
func (tree *BBTree) ReindexQuery(f SpatialIndexQuery, data interface{})
func (*BBTree) ReplaceChild ¶
func (*BBTree) SegmentQuery ¶
func (tree *BBTree) SegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, data interface{})
type BBTreeVelocityFunc ¶
type BBTreeVelocityFunc func(obj interface{}) Vector
type Body ¶
type Body struct { UserData interface{} // contains filtered or unexported fields }
func NewKinematicBody ¶
func NewKinematicBody() *Body
func NewStaticBody ¶
func NewStaticBody() *Body
func (*Body) AccumulateMassFromShapes ¶
func (body *Body) AccumulateMassFromShapes()
Should *only* be called when shapes with mass info are modified, added or removed.
func (*Body) ActivateStatic ¶
func (*Body) AngularVelocity ¶
func (*Body) ApplyForceAtLocalPoint ¶
func (*Body) ApplyForceAtWorldPoint ¶
func (*Body) ApplyImpulseAtLocalPoint ¶
func (*Body) ApplyImpulseAtWorldPoint ¶
func (Body) CenterOfGravity ¶
func (*Body) ComponentAdd ¶
func (*Body) ComponentRoot ¶
func (*Body) EachArbiter ¶
func (*Body) EachConstraint ¶
func (body *Body) EachConstraint(f func(*Constraint))
func (*Body) IsSleeping ¶
func (*Body) KineticEnergy ¶
func (*Body) LocalToWorld ¶
func (*Body) PushArbiter ¶
func (*Body) RemoveConstraint ¶
func (body *Body) RemoveConstraint(constraint *Constraint)
func (*Body) RemoveShape ¶
func (*Body) SetAngularVelocity ¶
func (*Body) SetPosition ¶
func (*Body) SetPositionUpdateFunc ¶
func (body *Body) SetPositionUpdateFunc(f BodyPositionFunc)
func (*Body) SetTransform ¶
func (*Body) SetVelocity ¶
func (*Body) SetVelocityUpdateFunc ¶
func (body *Body) SetVelocityUpdateFunc(f BodyVelocityFunc)
func (*Body) SetVelocityVector ¶
func (*Body) UpdateVelocity ¶
func (*Body) VelocityAtLocalPoint ¶
func (*Body) VelocityAtWorldPoint ¶
func (*Body) WorldToLocal ¶
type BodyPositionFunc ¶
/ Rigid body position update function type.
type BodyVelocityFunc ¶
/ Rigid body velocity update function type.
type Circle ¶
type Circle struct { *Shape // contains filtered or unexported fields }
func (*Circle) PointQuery ¶
func (circle *Circle) PointQuery(p Vector, info *PointQueryInfo)
func (*Circle) SegmentQuery ¶
func (circle *Circle) SegmentQuery(a, b Vector, radius float64, info *SegmentQueryInfo)
func (*Circle) TransformC ¶
type ClosestPoints ¶
type ClosestPoints struct {
// contains filtered or unexported fields
}
func EPA ¶
func EPA(ctx *SupportContext, v0 MinkowskiPoint, v1 MinkowskiPoint, v2 MinkowskiPoint) ClosestPoints
Find the closest points on the surface of two overlapping shapes using the EPA algorithm. EPA is called from GJK when two shapes overlap. This is a moderately expensive step! Avoid it by adding radii to your shapes so their inner polygons won't overlap.
func EPARecurse ¶
func EPARecurse(ctx *SupportContext, count int, hull []MinkowskiPoint, iteration int) ClosestPoints
Recursive implementation of the EPA loop. Each recursion adds a point to the convex hull until it's known that we have the closest point on the surface.
func GJK ¶
func GJK(ctx *SupportContext, collisionId *uint32) ClosestPoints
Find the closest points between two shapes using the GJK algorithm.
func GJKRecurse ¶
func GJKRecurse(ctx *SupportContext, v0, v1 MinkowskiPoint, iteration int) ClosestPoints
Recursive implementation of the GJK loop.
type CollisionBeginFunc ¶
type CollisionFunc ¶
type CollisionFunc func(a, b *Shape, info *CollisionInfo)
type CollisionHandler ¶
type CollisionHandler struct { /// Collision type identifier of the first shape that this handler recognizes. /// In the collision handler callback, the shape with this type will be the first argument. Read only. TypeA CollisionType /// Collision type identifier of the second shape that this handler recognizes. /// In the collision handler callback, the shape with this type will be the second argument. Read only. TypeB CollisionType /// This function is called when two shapes with types that match this collision handler begin colliding. BeginFunc CollisionBeginFunc /// This function is called each step when two shapes with types that match this collision handler are colliding. /// It's called before the collision solver runs so that you can affect a collision's outcome. PreSolveFunc CollisionPreSolveFunc /// This function is called each step when two shapes with types that match this collision handler are colliding. /// It's called after the collision solver runs so that you can read back information about the collision to trigger events in your game. PostSolveFunc CollisionPostSolveFunc /// This function is called when two shapes with types that match this collision handler stop colliding. SeparateFunc CollisionSeparateFunc /// This is a user definable context pointer that is passed to all of the collision handler functions. UserData interface{} }
/ Struct that holds function callback pointers to configure custom collision handling. / Collision handlers have a pair of types; when a collision occurs between two shapes that have these types, the collision handler functions are triggered.
var CollisionHandlerDefault CollisionHandler = CollisionHandler{ WILDCARD_COLLISION_TYPE, WILDCARD_COLLISION_TYPE, DefaultBegin, DefaultPreSolve, DefaultPostSolve, DefaultSeparate, nil, }
var CollisionHandlerDoNothing CollisionHandler = CollisionHandler{ WILDCARD_COLLISION_TYPE, WILDCARD_COLLISION_TYPE, AlwaysCollide, AlwaysCollide, DoNothing, DoNothing, nil, }
type CollisionInfo ¶
type CollisionInfo struct {
// contains filtered or unexported fields
}
func (*CollisionInfo) PushContact ¶
func (info *CollisionInfo) PushContact(p1, p2 Vector, hash HashValue)
type CollisionPostSolveFunc ¶
type CollisionPreSolveFunc ¶
type CollisionSeparateFunc ¶
type CollisionType ¶
type CollisionType uintptr
var WILDCARD_COLLISION_TYPE CollisionType = ^CollisionType(0)
type Constrainer ¶
type Constraint ¶
type Constraint struct { Class Constrainer PreSolve ConstraintPreSolveFunc PostSolve ConstraintPostSolveFunc // contains filtered or unexported fields }
func NewConstraint ¶
func NewConstraint(class Constrainer, a, b *Body) *Constraint
func NewDampedRotarySpring ¶
func NewDampedRotarySpring(a, b *Body, restAngle, stiffness, damping float64) *Constraint
func NewDampedSpring ¶
func NewDampedSpring(a, b *Body, anchorA, anchorB Vector, restLength, stiffness, damping float64) *Constraint
func NewGearJoint ¶
func NewGearJoint(a, b *Body, phase, ratio float64) *Constraint
func NewGrooveJoint ¶
func NewGrooveJoint(a, b *Body, grooveA, grooveB, anchorB Vector) *Constraint
func NewPinJoint ¶
func NewPinJoint(a, b *Body, anchorA, anchorB Vector) *Constraint
func NewPivotJoint ¶
func NewPivotJoint(a, b *Body, pivot Vector) *Constraint
func NewPivotJoint2 ¶
func NewPivotJoint2(a, b *Body, anchorA, anchorB Vector) *Constraint
func NewRatchetJoint ¶
func NewRatchetJoint(a, b *Body, phase, ratchet float64) *Constraint
func NewRotaryLimitJoint ¶
func NewRotaryLimitJoint(a, b *Body, min, max float64) *Constraint
func NewSimpleMotor ¶
func NewSimpleMotor(a, b *Body, rate float64) *Constraint
func NewSlideJoint ¶
func NewSlideJoint(a, b *Body, anchorA, anchorB Vector, min, max float64) *Constraint
func (*Constraint) ActivateBodies ¶
func (c *Constraint) ActivateBodies()
func (Constraint) ErrorBias ¶
func (c Constraint) ErrorBias() float64
func (Constraint) MaxBias ¶
func (c Constraint) MaxBias() float64
func (Constraint) MaxForce ¶
func (c Constraint) MaxForce() float64
func (*Constraint) Next ¶
func (c *Constraint) Next(body *Body) *Constraint
func (*Constraint) SetCollideBodies ¶
func (c *Constraint) SetCollideBodies(collideBodies bool)
func (*Constraint) SetErrorBias ¶
func (c *Constraint) SetErrorBias(errorBias float64)
func (*Constraint) SetMaxBias ¶
func (c *Constraint) SetMaxBias(max float64)
func (*Constraint) SetMaxForce ¶
func (c *Constraint) SetMaxForce(max float64)
type ConstraintPostSolveFunc ¶
type ConstraintPostSolveFunc func(*Constraint, *Space)
type ConstraintPreSolveFunc ¶
type ConstraintPreSolveFunc func(*Constraint, *Space)
type ContactBuffer ¶
type ContactBuffer struct {
// contains filtered or unexported fields
}
func NewContactBuffer ¶
func NewContactBuffer(stamp uint, slice *ContactBuffer) *ContactBuffer
func (*ContactBuffer) InitHeader ¶
func (c *ContactBuffer) InitHeader(stamp uint, splice *ContactBuffer) *ContactBuffer
type ContactPointSet ¶
type ContactPointSet struct { Count int Normal Vector Points [MAX_CONTACTS_PER_ARBITER]struct { /// The position of the contact on the surface of each shape. PointA, PointB Vector /// Penetration distance of the two shapes. Overlapping means it will be negative. /// This value is calculated as cpvdot(cpvsub(point2, point1), normal) and is ignored by cpArbiterSetContactPointSet(). Distance float64 } }
type DampedRotarySpring ¶
type DampedRotarySpring struct { *Constraint RestAngle, Stiffness, Damping float64 SpringTorqueFunc func(spring *DampedRotarySpring, relativeAngle float64) float64 // contains filtered or unexported fields }
func (*DampedRotarySpring) ApplyCachedImpulse ¶
func (joint *DampedRotarySpring) ApplyCachedImpulse(dt_coef float64)
func (*DampedRotarySpring) ApplyImpulse ¶
func (spring *DampedRotarySpring) ApplyImpulse(dt float64)
func (*DampedRotarySpring) GetImpulse ¶
func (joint *DampedRotarySpring) GetImpulse() float64
func (*DampedRotarySpring) PreStep ¶
func (spring *DampedRotarySpring) PreStep(dt float64)
type DampedSpring ¶
type DampedSpring struct { *Constraint AnchorA, AnchorB Vector RestLength, Stiffness, Damping float64 SpringForceFunc DampedSpringForceFunc // contains filtered or unexported fields }
func (*DampedSpring) ApplyCachedImpulse ¶
func (spring *DampedSpring) ApplyCachedImpulse(dt_coef float64)
func (*DampedSpring) ApplyImpulse ¶
func (spring *DampedSpring) ApplyImpulse(dt float64)
func (*DampedSpring) GetImpulse ¶
func (spring *DampedSpring) GetImpulse() float64
func (*DampedSpring) PreStep ¶
func (spring *DampedSpring) PreStep(dt float64)
type DampedSpringForceFunc ¶
type DampedSpringForceFunc func(spring *DampedSpring, dist float64) float64
type Drawer ¶
type Drawer interface { DrawCircle(pos Vector, angle, radius float64, outline, fill FColor, data interface{}) DrawSegment(a, b Vector, fill FColor, data interface{}) DrawFatSegment(a, b Vector, radius float64, outline, fill FColor, data interface{}) DrawPolygon(count int, verts []Vector, radius float64, outline, fill FColor, data interface{}) DrawDot(size float64, pos Vector, fill FColor, data interface{}) Flags() uint OutlineColor() FColor ShapeColor(shape *Shape, data interface{}) FColor ConstraintColor() FColor CollisionPointColor() FColor Data() interface{} }
type Edge ¶
type Edge struct {
// contains filtered or unexported fields
}
func SupportEdgeForPoly ¶
func SupportEdgeForSegment ¶
type GearJoint ¶
type GearJoint struct { *Constraint // contains filtered or unexported fields }
func (*GearJoint) ApplyCachedImpulse ¶
func (*GearJoint) ApplyImpulse ¶
func (*GearJoint) GetImpulse ¶
type GrooveJoint ¶
type GrooveJoint struct { *Constraint GrooveN, GrooveA, GrooveB Vector AnchorB Vector // contains filtered or unexported fields }
func (*GrooveJoint) ApplyCachedImpulse ¶
func (joint *GrooveJoint) ApplyCachedImpulse(dt_coef float64)
func (*GrooveJoint) ApplyImpulse ¶
func (joint *GrooveJoint) ApplyImpulse(dt float64)
func (*GrooveJoint) GetImpulse ¶
func (joint *GrooveJoint) GetImpulse() float64
func (*GrooveJoint) PreStep ¶
func (joint *GrooveJoint) PreStep(dt float64)
type HashSet ¶
type HashSet struct {
// contains filtered or unexported fields
}
func NewHashSet ¶
func NewHashSet(eql HashSetEqual) *HashSet
func (*HashSet) Each ¶
func (set *HashSet) Each(f HashSetIterator)
func (*HashSet) Filter ¶
func (set *HashSet) Filter(f HashSetFilter, data interface{})
func (*HashSet) GetUnusedBin ¶
func (set *HashSet) GetUnusedBin() *HashSetBin
func (*HashSet) Insert ¶
func (set *HashSet) Insert(hash HashValue, ptr interface{}, trans HashSetTrans, data interface{}) interface{}
func (*HashSet) Recycle ¶
func (set *HashSet) Recycle(bin *HashSetBin)
type HashSetArbiter ¶
type HashSetArbiter struct {
// contains filtered or unexported fields
}
func NewHashSetArbiter ¶
func NewHashSetArbiter(eql HashSetEqualArbiter) *HashSetArbiter
func (*HashSetArbiter) Count ¶
func (set *HashSetArbiter) Count() uint
func (*HashSetArbiter) Each ¶
func (set *HashSetArbiter) Each(f HashSetIteratorArbiter)
func (*HashSetArbiter) Filter ¶
func (set *HashSetArbiter) Filter(filter func(arb *Arbiter) bool)
func (*HashSetArbiter) Find ¶
func (set *HashSetArbiter) Find(hash HashValue, ptr []*Shape) interface{}
func (*HashSetArbiter) Free ¶
func (set *HashSetArbiter) Free()
func (*HashSetArbiter) GetUnusedBin ¶
func (set *HashSetArbiter) GetUnusedBin() *HashSetBinArbiter
func (*HashSetArbiter) Insert ¶
func (set *HashSetArbiter) Insert(hash HashValue, ptr []*Shape, trans HashSetTransArbiter, space *Space) *Arbiter
func (*HashSetArbiter) InsertArb ¶
func (set *HashSetArbiter) InsertArb(hash HashValue, ptr []*Shape, arb *Arbiter) interface{}
func (*HashSetArbiter) Recycle ¶
func (set *HashSetArbiter) Recycle(bin *HashSetBinArbiter)
func (*HashSetArbiter) Remove ¶
func (set *HashSetArbiter) Remove(hash HashValue, ptr []*Shape) *Arbiter
func (*HashSetArbiter) Resize ¶
func (set *HashSetArbiter) Resize()
type HashSetBin ¶
type HashSetBin struct {
// contains filtered or unexported fields
}
type HashSetBinArbiter ¶
type HashSetBinArbiter struct {
// contains filtered or unexported fields
}
type HashSetBinCollisionHandler ¶
type HashSetBinCollisionHandler struct {
// contains filtered or unexported fields
}
type HashSetBinHandle ¶
type HashSetBinHandle struct {
// contains filtered or unexported fields
}
type HashSetCollisionHandler ¶
type HashSetCollisionHandler struct {
// contains filtered or unexported fields
}
func NewHashSetCollisionHandler ¶
func NewHashSetCollisionHandler() *HashSetCollisionHandler
func (*HashSetCollisionHandler) Count ¶
func (set *HashSetCollisionHandler) Count() uint
func (*HashSetCollisionHandler) Each ¶
func (set *HashSetCollisionHandler) Each(f HashSetIterator)
func (*HashSetCollisionHandler) Find ¶
func (set *HashSetCollisionHandler) Find(hash HashValue, ptr *CollisionHandler) *CollisionHandler
func (*HashSetCollisionHandler) Insert ¶
func (set *HashSetCollisionHandler) Insert(hash HashValue, ptr *CollisionHandler) *CollisionHandler
func (*HashSetCollisionHandler) Resize ¶
func (set *HashSetCollisionHandler) Resize()
type HashSetEqual ¶
type HashSetEqual func(ptr, elt interface{}) bool
type HashSetEqualArbiter ¶
type HashSetEqualCollisionHandler ¶
type HashSetEqualCollisionHandler func(ptr, elt interface{}) bool
type HashSetEqualHandle ¶
type HashSetFilter ¶
type HashSetFilter func(elt, data interface{}) bool
type HashSetFilterArbiter ¶
type HashSetFilterCollisionHandler ¶
type HashSetFilterCollisionHandler func(elt, data interface{}) bool
type HashSetFilterHandle ¶
type HashSetHandle ¶
type HashSetHandle struct {
// contains filtered or unexported fields
}
func NewHashSetHandle ¶
func NewHashSetHandle(eql HashSetEqualHandle) *HashSetHandle
func (*HashSetHandle) Count ¶
func (set *HashSetHandle) Count() uint
func (*HashSetHandle) Each ¶
func (set *HashSetHandle) Each(f HashSetIteratorHandle)
func (*HashSetHandle) Find ¶
func (set *HashSetHandle) Find(hash HashValue, ptr *Shape) interface{}
func (*HashSetHandle) Free ¶
func (set *HashSetHandle) Free()
func (*HashSetHandle) GetUnusedBin ¶
func (set *HashSetHandle) GetUnusedBin() *HashSetBinHandle
func (*HashSetHandle) Insert ¶
func (set *HashSetHandle) Insert(hash HashValue, ptr *Shape, trans HashSetTransHandle, spaceHash *SpaceHash) *Handle
func (*HashSetHandle) InsertArb ¶
func (set *HashSetHandle) InsertArb(hash HashValue, ptr *Shape, arb *Handle) interface{}
func (*HashSetHandle) Recycle ¶
func (set *HashSetHandle) Recycle(bin *HashSetBinHandle)
func (*HashSetHandle) Resize ¶
func (set *HashSetHandle) Resize()
type HashSetIterator ¶
type HashSetIterator func(elt interface{})
type HashSetIteratorArbiter ¶
type HashSetIteratorArbiter func(elt *Arbiter)
type HashSetIteratorCollisionHandler ¶
type HashSetIteratorCollisionHandler func(elt interface{})
type HashSetIteratorHandle ¶
type HashSetIteratorHandle func(elt *Handle)
type HashSetTrans ¶
type HashSetTrans func(ptr, data interface{}) interface{}
type HashSetTransArbiter ¶
type HashSetTransCollisionHandler ¶
type HashSetTransCollisionHandler func(ptr, data interface{}) interface{}
type HashSetTransHandle ¶
type MarkContext ¶
type MarkContext struct {
// contains filtered or unexported fields
}
type MinkowskiPoint ¶
type MinkowskiPoint struct {
// contains filtered or unexported fields
}
A point on the surface of two shape's minkowski difference.
func NewMinkowskiPoint ¶
func NewMinkowskiPoint(a, b *SupportPoint) MinkowskiPoint
func (MinkowskiPoint) ClosestPoints ¶
func (v0 MinkowskiPoint) ClosestPoints(v1 MinkowskiPoint) ClosestPoints
Calculate the closest points on two shapes given the closest edge on their minkowski difference to (0, 0)
type Node ¶
func (*Node) MarkLeaf ¶
func (leaf *Node) MarkLeaf(context *MarkContext)
func (*Node) MarkLeafQuery ¶
func (subtree *Node) MarkLeafQuery(leaf *Node, left bool, context *MarkContext)
func (*Node) MarkSubtree ¶
func (subtree *Node) MarkSubtree(context *MarkContext)
func (*Node) SubtreeQuery ¶
func (subtree *Node) SubtreeQuery(obj interface{}, bb BB, query SpatialIndexQuery, data interface{})
func (*Node) SubtreeSegmentQuery ¶
func (subtree *Node) SubtreeSegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, data interface{}) float64
type PinJoint ¶
type PinJoint struct { *Constraint AnchorA, AnchorB Vector Dist float64 // contains filtered or unexported fields }
func (*PinJoint) ApplyCachedImpulse ¶
func (*PinJoint) ApplyImpulse ¶
func (*PinJoint) GetImpulse ¶
type PivotJoint ¶
type PivotJoint struct { *Constraint AnchorA, AnchorB Vector // contains filtered or unexported fields }
func (*PivotJoint) ApplyCachedImpulse ¶
func (joint *PivotJoint) ApplyCachedImpulse(dt_coef float64)
func (*PivotJoint) ApplyImpulse ¶
func (joint *PivotJoint) ApplyImpulse(dt float64)
func (*PivotJoint) GetImpulse ¶
func (joint *PivotJoint) GetImpulse() float64
func (*PivotJoint) PreStep ¶
func (joint *PivotJoint) PreStep(dt float64)
type PointQueryContext ¶
type PointQueryContext struct {
// contains filtered or unexported fields
}
type PointQueryInfo ¶
type PointQueryInfo struct { /// The nearest shape, NULL if no shape was within range. Shape *Shape /// The closest point on the shape's surface. (in world space coordinates) Point Vector /// The distance to the point. The distance is negative if the point is inside the shape. Distance float64 /// The gradient of the signed distance function. /// The value should be similar to info.p/info.d, but accurate even for very small values of info.d. Gradient Vector }
type PolyShape ¶
type PolyShape struct { *Shape // contains filtered or unexported fields }
func (*PolyShape) PointQuery ¶
func (poly *PolyShape) PointQuery(p Vector, info *PointQueryInfo)
func (*PolyShape) SegmentQuery ¶
func (poly *PolyShape) SegmentQuery(a, b Vector, r2 float64, info *SegmentQueryInfo)
func (*PolyShape) SetVertsRaw ¶
func (*PolyShape) SetVertsUnsafe ¶
func (PolyShape) TransformVert ¶
type PostStepCallback ¶
type PostStepCallback struct {
// contains filtered or unexported fields
}
type PostStepCallbackFunc ¶
type PostStepCallbackFunc func(space *Space, key interface{}, data interface{})
type RatchetJoint ¶
type RatchetJoint struct { *Constraint Angle, Phase, Ratchet float64 // contains filtered or unexported fields }
func (*RatchetJoint) ApplyCachedImpulse ¶
func (joint *RatchetJoint) ApplyCachedImpulse(dt_coef float64)
func (*RatchetJoint) ApplyImpulse ¶
func (joint *RatchetJoint) ApplyImpulse(dt float64)
func (*RatchetJoint) GetImpulse ¶
func (joint *RatchetJoint) GetImpulse() float64
func (*RatchetJoint) PreStep ¶
func (joint *RatchetJoint) PreStep(dt float64)
type RotaryLimitJoint ¶
type RotaryLimitJoint struct { *Constraint Min, Max float64 // contains filtered or unexported fields }
func (*RotaryLimitJoint) ApplyCachedImpulse ¶
func (joint *RotaryLimitJoint) ApplyCachedImpulse(dt_coef float64)
func (*RotaryLimitJoint) ApplyImpulse ¶
func (joint *RotaryLimitJoint) ApplyImpulse(dt float64)
func (*RotaryLimitJoint) GetImpulse ¶
func (joint *RotaryLimitJoint) GetImpulse() float64
func (*RotaryLimitJoint) PreStep ¶
func (joint *RotaryLimitJoint) PreStep(dt float64)
type Segment ¶
type Segment struct { *Shape // contains filtered or unexported fields }
func (*Segment) PointQuery ¶
func (seg *Segment) PointQuery(p Vector, info *PointQueryInfo)
func (*Segment) SegmentQuery ¶
func (seg *Segment) SegmentQuery(a, b Vector, r2 float64, info *SegmentQueryInfo)
func (*Segment) SetEndpoints ¶
func (*Segment) TransformA ¶
func (*Segment) TransformB ¶
type SegmentQueryContext ¶
type SegmentQueryContext struct {
// contains filtered or unexported fields
}
type SegmentQueryInfo ¶
type Shape ¶
type Shape struct { Class ShapeClass UserData interface{} Filter ShapeFilter // contains filtered or unexported fields }
func NewPolyShape ¶
func NewPolyShapeRaw ¶
func NewShape ¶
func NewShape(class ShapeClass, body *Body, massInfo *ShapeMassInfo) *Shape
func (*Shape) Elasticity ¶
func (*Shape) MassInfo ¶
func (s *Shape) MassInfo() *ShapeMassInfo
func (*Shape) Point ¶
func (s *Shape) Point(i uint32) *SupportPoint
func (*Shape) PointQuery ¶
func (s *Shape) PointQuery(p Vector) PointQueryInfo
func (*Shape) SegmentQuery ¶
func (shape *Shape) SegmentQuery(a, b Vector, radius float64, info *SegmentQueryInfo) bool
func (*Shape) SetCollisionType ¶
func (s *Shape) SetCollisionType(collisionType CollisionType)
func (*Shape) SetElasticity ¶
func (*Shape) SetFilter ¶
func (s *Shape) SetFilter(filter ShapeFilter)
func (*Shape) SetFriction ¶
func (*Shape) SetSurfaceV ¶
type ShapeClass ¶
type ShapeClass interface { CacheData(transform Transform) BB Destroy() PointQuery(p Vector, info *PointQueryInfo) SegmentQuery(a, b Vector, radius float64, info *SegmentQueryInfo) }
type ShapeFilter ¶
type ShapeFilter struct { /// Two objects with the same non-zero group value do not collide. /// This is generally used to group objects in a composite object together to disable self collisions. Group uint /// A bitmask of user definable categories that this object belongs to. /// The category/mask combinations of both objects in a collision must agree for a collision to occur. Categories uint /// A bitmask of user definable category types that this object object collides with. /// The category/mask combinations of both objects in a collision must agree for a collision to occur. Mask uint }
func NewShapeFilter ¶
func NewShapeFilter(group, categories, mask uint) ShapeFilter
func (ShapeFilter) Reject ¶
func (a ShapeFilter) Reject(b ShapeFilter) bool
type ShapeMassInfo ¶
type ShapeMassInfo struct {
// contains filtered or unexported fields
}
func CircleShapeMassInfo ¶
func CircleShapeMassInfo(mass, radius float64, center Vector) *ShapeMassInfo
func NewSegmentMassInfo ¶
func NewSegmentMassInfo(mass float64, a, b Vector, r float64) *ShapeMassInfo
func PolyShapeMassInfo ¶
func PolyShapeMassInfo(mass float64, count int, verts []Vector, r float64) *ShapeMassInfo
type SimpleMotor ¶
type SimpleMotor struct { *Constraint Rate float64 // contains filtered or unexported fields }
func (*SimpleMotor) ApplyCachedImpulse ¶
func (motor *SimpleMotor) ApplyCachedImpulse(dt_coef float64)
func (*SimpleMotor) ApplyImpulse ¶
func (motor *SimpleMotor) ApplyImpulse(dt float64)
func (*SimpleMotor) GetImpulse ¶
func (motor *SimpleMotor) GetImpulse() float64
func (*SimpleMotor) PreStep ¶
func (motor *SimpleMotor) PreStep(dt float64)
type SlideJoint ¶
type SlideJoint struct { *Constraint AnchorA, AnchorB Vector Min, Max float64 // contains filtered or unexported fields }
func (*SlideJoint) ApplyCachedImpulse ¶
func (joint *SlideJoint) ApplyCachedImpulse(dt_coef float64)
func (*SlideJoint) ApplyImpulse ¶
func (joint *SlideJoint) ApplyImpulse(dt float64)
func (*SlideJoint) GetImpulse ¶
func (joint *SlideJoint) GetImpulse() float64
func (*SlideJoint) PreStep ¶
func (joint *SlideJoint) PreStep(dt float64)
type Space ¶
type Space struct { Iterations uint // must be non-zero SleepTimeThreshold float64 StaticBody *Body // contains filtered or unexported fields }
func (*Space) AddConstraint ¶
func (space *Space) AddConstraint(constraint *Constraint) *Constraint
func (*Space) AddPostStepCallback ¶
func (space *Space) AddPostStepCallback(f PostStepCallbackFunc, key, data interface{}) bool
func (*Space) ArrayForBodyType ¶
func (*Space) ContactBufferGetArray ¶
func (*Space) ContainsBody ¶
func (*Space) ContainsConstraint ¶
func (space *Space) ContainsConstraint(constraint *Constraint) bool
func (*Space) ContainsShape ¶
func (*Space) Deactivate ¶
func (*Space) EachConstraint ¶
func (space *Space) EachConstraint(f func(*Constraint))
func (*Space) FilterArbiters ¶
func (*Space) LookupHandler ¶
func (space *Space) LookupHandler(a, b CollisionType, defaultHandler *CollisionHandler) *CollisionHandler
func (*Space) NewCollisionHandler ¶
func (space *Space) NewCollisionHandler(collisionTypeA, collisionTypeB CollisionType) *CollisionHandler
func (*Space) NewWildcardCollisionHandler ¶
func (space *Space) NewWildcardCollisionHandler(collisionType CollisionType) *CollisionHandler
func (*Space) PointQueryNearest ¶
func (space *Space) PointQueryNearest(point Vector, maxDistance float64, filter ShapeFilter) *PointQueryInfo
func (*Space) PopContacts ¶
func (*Space) PostStepCallback ¶
func (space *Space) PostStepCallback(key interface{}) *PostStepCallback
func (*Space) ProcessComponents ¶
func (*Space) PushContacts ¶
func (*Space) PushFreshContactBuffer ¶
func (space *Space) PushFreshContactBuffer()
func (*Space) RemoveBody ¶
func (*Space) RemoveConstraint ¶
func (space *Space) RemoveConstraint(constraint *Constraint)
func (*Space) RemoveShape ¶
func (*Space) SegmentQuery ¶
func (space *Space) SegmentQuery(start, end Vector, radius float64, filter ShapeFilter, f SpaceSegmentQueryFunc, data interface{})
func (*Space) SegmentQueryFirst ¶
func (space *Space) SegmentQueryFirst(start, end Vector, radius float64, filter ShapeFilter) SegmentQueryInfo
func (*Space) SetCollisionSlop ¶
func (*Space) SetDamping ¶
func (*Space) SetGravity ¶
func (*Space) SetStaticBody ¶
func (*Space) UncacheArbiter ¶
func (*Space) UseSpatialHash ¶
func (*Space) UseWildcardDefaultHandler ¶
func (space *Space) UseWildcardDefaultHandler()
type SpaceHash ¶
type SpaceHash struct { *SpatialIndex // contains filtered or unexported fields }
func (*SpaceHash) Each ¶
func (hash *SpaceHash) Each(f SpatialIndexIterator)
func (*SpaceHash) Query ¶
func (hash *SpaceHash) Query(obj interface{}, bb BB, f SpatialIndexQuery, data interface{})
func (*SpaceHash) ReindexObject ¶
func (*SpaceHash) ReindexQuery ¶
func (hash *SpaceHash) ReindexQuery(f SpatialIndexQuery, data interface{})
func (*SpaceHash) SegmentQuery ¶
func (hash *SpaceHash) SegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, data interface{})
modified from http://playtechs.blogspot.com/2007/03/raytracing-on-grid.html
type SpaceHashBin ¶
type SpaceHashBin struct {
// contains filtered or unexported fields
}
type SpacePointQueryFunc ¶
type SpaceSegmentQueryFunc ¶
type SpatialIndex ¶
type SpatialIndex struct {
// contains filtered or unexported fields
}
func NewBBTree ¶
func NewBBTree(bbfunc SpatialIndexBB, staticIndex *SpatialIndex) *SpatialIndex
func NewSpaceHash ¶
func NewSpaceHash(celldim float64, num int, bbfunc SpatialIndexBB, staticIndex *SpatialIndex) *SpatialIndex
func NewSpatialIndex ¶
func NewSpatialIndex(klass SpatialIndexer, bbfunc SpatialIndexBB, staticIndex *SpatialIndex) *SpatialIndex
func (*SpatialIndex) CollideStatic ¶
func (dynamicIndex *SpatialIndex) CollideStatic(staticIndex *SpatialIndex, f SpatialIndexQuery, data interface{})
func (*SpatialIndex) GetRootIfTree ¶
func (index *SpatialIndex) GetRootIfTree() *Node
func (*SpatialIndex) GetTree ¶
func (index *SpatialIndex) GetTree() *BBTree
type SpatialIndexBB ¶
type SpatialIndexIterator ¶
type SpatialIndexIterator func(obj *Shape)
type SpatialIndexQuery ¶
type SpatialIndexer ¶
type SpatialIndexer interface { Destroy() Count() int Each(f SpatialIndexIterator) Contains(obj *Shape, hashId HashValue) bool Insert(obj *Shape, hashId HashValue) Remove(obj *Shape, hashId HashValue) Reindex() ReindexObject(obj *Shape, hashId HashValue) ReindexQuery(f SpatialIndexQuery, data interface{}) Query(obj interface{}, bb BB, f SpatialIndexQuery, data interface{}) SegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, data interface{}) }
implemented by BBTree
type SplittingPlane ¶
type SplittingPlane struct {
// contains filtered or unexported fields
}
type SupportContext ¶
type SupportContext struct {
// contains filtered or unexported fields
}
func (*SupportContext) Support ¶
func (ctx *SupportContext) Support(n Vector) MinkowskiPoint
Calculate the maximal point on the minkowski difference of two shapes along a particular axis.
type SupportPoint ¶
type SupportPoint struct {
// contains filtered or unexported fields
}
func CircleSupportPoint ¶
func CircleSupportPoint(shape *Shape, n Vector) *SupportPoint
func NewSupportPoint ¶
func NewSupportPoint(p Vector, index uint32) *SupportPoint
func PolySupportPoint ¶
func PolySupportPoint(shape *Shape, n Vector) *SupportPoint
func SegmentSupportPoint ¶
func SegmentSupportPoint(shape *Shape, n Vector) *SupportPoint
type SupportPointFunc ¶
type SupportPointFunc func(shape *Shape, n Vector) *SupportPoint
type Transform ¶
type Transform struct {
// contains filtered or unexported fields
}
func NewTransform ¶
func NewTransformIdentity ¶
func NewTransformIdentity() Transform
func NewTransformRigid ¶
func NewTransformRotate ¶
func NewTransformScale ¶
func NewTransformTranslate ¶
func NewTransformTranspose ¶
func (Transform) AxialScale ¶
type Vector ¶
type Vector struct {
X, Y float64
}
func CentroidForPoly ¶
func (Vector) ClosestDist ¶
func (Vector) ClosestPointOnSegment ¶
func (Vector) Cross ¶
/ 2D vector cross product analog. / The cross product of 2D vectors results in a 3D vector with only a z component. / This function returns the magnitude of the z value.
func (Vector) DistanceSq ¶
func (Vector) PointGreater ¶
func (Vector) ReversePerp ¶
Source Files ¶
- arbiter.go
- bb.go
- bbtree.go
- body.go
- circle.go
- collision.go
- constraint.go
- contactbuffer.go
- dampedrotaryspring.go
- dampedspring.go
- draw.go
- everything.go
- gearjoint.go
- groovejoint.go
- hashset.go
- hashset_arbiter.go
- hashset_collisionhandler.go
- hashset_handle.go
- pinjoint.go
- pivotjoint.go
- poly.go
- ratchetjoint.go
- rotarylimitjoint.go
- segment.go
- shape.go
- simplemotor.go
- slidejoint.go
- space.go
- spacehash.go
- spatialindex.go
- transform.go
- vector.go