Documentation ¶
Overview ¶
Package chipmunk is an interface to Chipmunk Physics library.
Usage example: https://github.com/ftrvxmtrx/gochipmunk/blob/master/chipmunk-demo/main.go
Index ¶
- Constants
- func AreaForCircle(r1, r2 float64) float64
- func AreaForPoly(verts []Vect) float64
- func AreaForSegment(a, b Vect, r float64) float64
- func MomentForBox(m, width, height float64) float64
- func MomentForBox2(m float64, box BB) float64
- func MomentForCircle(m, r1, r2 float64, offset Vect) float64
- func MomentForPoly(m float64, verts []Vect, offset Vect) float64
- func MomentForSegment(m float64, a, b Vect) float64
- func PolyValidate(verts []Vect) bool
- func RecenterPoly(verts []Vect)
- func ResetShapeIDCounter()
- func Version() string
- func VertsEqual(a, b []Vect) bool
- type Arbiter
- func (arb Arbiter) Bodies() (Body, Body)
- func (a Arbiter) ContactPoints() []ContactPoint
- func (a Arbiter) Count() int
- func (a Arbiter) Depth(i int) float64
- func (a Arbiter) Elasticity() float64
- func (a Arbiter) Friction() float64
- func (a Arbiter) Ignore()
- func (a Arbiter) IsFirstContact() bool
- func (a Arbiter) Normal(i int) Vect
- func (a Arbiter) Point(i int) Vect
- func (a Arbiter) SetContactPoints(cp []ContactPoint)
- func (a Arbiter) SetElasticity(e float64)
- func (a Arbiter) SetFriction(f float64)
- func (a Arbiter) SetSurfaceVelocity(v Vect)
- func (arb Arbiter) Shapes() (Shape, Shape)
- func (a Arbiter) String() string
- func (a Arbiter) SurfaceVelocity() Vect
- func (a Arbiter) TotalImpulse() Vect
- func (a Arbiter) TotalImpulseWithFriction() Vect
- func (a Arbiter) TotalKE() float64
- type BB
- func (b BB) Area() float64
- func (bb BB) Center() Vect
- func (bb BB) ClampVect(v Vect) Vect
- func (b BB) Contains(other BB) bool
- func (b BB) ContainsVect(v Vect) bool
- func (b BB) Expand(v Vect) BB
- func (a BB) Intersects(b BB) bool
- func (bb BB) IntersectsSegment(a, b Vect) bool
- func (a BB) Merge(b BB) BB
- func (a BB) MergedArea(b BB) float64
- func (bb BB) SegmentQuery(a, b Vect) float64
- func (b BB) String() string
- func (bb BB) WrapVect(v Vect) Vect
- type BBQuery
- type Body
- func (b Body) Activate()
- func (b Body) ActivateStatic(s Shape)
- func (b Body) Angle() float64
- func (b Body) AngularVelocity() float64
- func (b Body) AngularVelocityLimit() float64
- func (b Body) ApplyForce(f, r Vect)
- func (b Body) ApplyImpulse(j, r Vect)
- func (b Body) EachArbiter(iter func(Body, Arbiter))
- func (b Body) EachConstraint(iter func(Body, Constraint))
- func (b Body) EachShape(iter func(Body, Shape))
- func (b Body) Force() Vect
- func (b Body) Free()
- func (b Body) IsRogue() bool
- func (b Body) IsSleeping() bool
- func (b Body) IsStatic() bool
- func (b Body) KineticEnergy() float64
- func (b Body) LocalToWorld(v Vect) Vect
- func (b Body) Mass() float64
- func (b Body) Moment() float64
- func (b Body) Position() Vect
- func (b Body) ResetForces()
- func (b Body) Rotation() Vect
- func (b Body) SetAngle(angle float64)
- func (b Body) SetAngularVelocity(vel float64)
- func (b Body) SetAngularVelocityLimit(limit float64)
- func (b Body) SetForce(force Vect)
- func (b Body) SetMass(mass float64)
- func (b Body) SetMoment(moment float64)
- func (b Body) SetPosition(pos Vect)
- func (b Body) SetPositionFunc(f func(b Body, dt float64))
- func (b Body) SetTorque(torq float64)
- func (b Body) SetUserData(data interface{})
- func (b Body) SetVelocity(vel Vect)
- func (b Body) SetVelocityFunc(f func(b Body, gravity Vect, damping, dt float64))
- func (b Body) SetVelocityLimit(limit float64)
- func (b Body) Sleep()
- func (b Body) SleepWithGroup(g Body)
- func (b Body) Space() Space
- func (b Body) String() string
- func (b Body) Torque() float64
- func (b Body) UpdatePosition(dt float64)
- func (b Body) UpdateVelocity(gravity Vect, damping float64, dt float64)
- func (b Body) UserData() interface{}
- func (b Body) Velocity() Vect
- func (b Body) VelocityAtLocalPoint(point Vect) Vect
- func (b Body) VelocityAtWorldPoint(point Vect) Vect
- func (b Body) VelocityLimit() float64
- func (b Body) WorldToLocal(v Vect) Vect
- type CircleShape
- func (s CircleShape) BB() BB
- func (s CircleShape) Body() Body
- func (s CircleShape) CacheBB() BB
- func (s CircleShape) Center() Vect
- func (s CircleShape) CollisionType() CollisionType
- func (s CircleShape) Elasticity() float64
- func (s CircleShape) Free()
- func (s CircleShape) Friction() float64
- func (s CircleShape) Group() Group
- func (s CircleShape) Layers() Layers
- func (s CircleShape) NearestPointQuery(p Vect) (float64, NearestPointQueryInfo)
- func (s CircleShape) Offset() Vect
- func (s CircleShape) PointQuery(p Vect) bool
- func (s CircleShape) Radius() float64
- func (s CircleShape) SegmentQuery(a, b Vect) (bool, SegmentQueryInfo)
- func (s CircleShape) Sensor() bool
- func (s CircleShape) SetBody(b Body)
- func (s CircleShape) SetCollisionType(t CollisionType)
- func (s CircleShape) SetElasticity(e float64)
- func (s CircleShape) SetFriction(f float64)
- func (s CircleShape) SetGroup(g Group)
- func (s CircleShape) SetLayers(l Layers)
- func (s CircleShape) SetOffset(offset Vect)
- func (s CircleShape) SetRadius(radius float64)
- func (s CircleShape) SetSensor(b bool)
- func (s CircleShape) SetSurfaceVelocity(v Vect)
- func (s CircleShape) SetUserData(data interface{})
- func (s CircleShape) Space() Space
- func (s CircleShape) String() string
- func (s CircleShape) SurfaceVelocity() Vect
- func (s CircleShape) Update(pos, rot Vect) BB
- func (s CircleShape) UserData() interface{}
- type CollisionType
- type Constraint
- type ContactPoint
- type DampedRotarySpring
- func (c DampedRotarySpring) A() Body
- func (c DampedRotarySpring) ActivateBodies()
- func (c DampedRotarySpring) B() Body
- func (c DampedRotarySpring) Damping() float64
- func (c DampedRotarySpring) ErrorBias() float64
- func (c DampedRotarySpring) Free()
- func (c DampedRotarySpring) Impulse() float64
- func (c DampedRotarySpring) MaxBias() float64
- func (c DampedRotarySpring) MaxForce() float64
- func (c DampedRotarySpring) RestAngle() float64
- func (c DampedRotarySpring) SetDamping(damping float64)
- func (c DampedRotarySpring) SetErrorBias(b float64)
- func (c DampedRotarySpring) SetMaxBias(b float64)
- func (c DampedRotarySpring) SetMaxForce(f float64)
- func (c DampedRotarySpring) SetPostSolveFunc(f func(c Constraint, s Space))
- func (c DampedRotarySpring) SetPreSolveFunc(f func(c Constraint, s Space))
- func (c DampedRotarySpring) SetRestAngle(restAngle float64)
- func (c DampedRotarySpring) SetStiffness(stiffness float64)
- func (c DampedRotarySpring) SetUserData(data interface{})
- func (c DampedRotarySpring) Space() Space
- func (c DampedRotarySpring) Stiffness() float64
- func (c DampedRotarySpring) UserData() interface{}
- type DampedSpring
- func (c DampedSpring) A() Body
- func (c DampedSpring) ActivateBodies()
- func (c DampedSpring) Anchr1() Vect
- func (c DampedSpring) Anchr2() Vect
- func (c DampedSpring) B() Body
- func (c DampedSpring) Damping() float64
- func (c DampedSpring) ErrorBias() float64
- func (c DampedSpring) Free()
- func (c DampedSpring) Impulse() float64
- func (c DampedSpring) MaxBias() float64
- func (c DampedSpring) MaxForce() float64
- func (c DampedSpring) RestLength() float64
- func (c DampedSpring) SetAnchr1(v Vect)
- func (c DampedSpring) SetAnchr2(v Vect)
- func (c DampedSpring) SetDamping(damping float64)
- func (c DampedSpring) SetErrorBias(b float64)
- func (c DampedSpring) SetMaxBias(b float64)
- func (c DampedSpring) SetMaxForce(f float64)
- func (c DampedSpring) SetPostSolveFunc(f func(c Constraint, s Space))
- func (c DampedSpring) SetPreSolveFunc(f func(c Constraint, s Space))
- func (c DampedSpring) SetRestLength(restLength float64)
- func (c DampedSpring) SetStiffness(stiffness float64)
- func (c DampedSpring) SetUserData(data interface{})
- func (c DampedSpring) Space() Space
- func (c DampedSpring) Stiffness() float64
- func (c DampedSpring) UserData() interface{}
- type GearJoint
- func (c GearJoint) A() Body
- func (c GearJoint) ActivateBodies()
- func (c GearJoint) B() Body
- func (c GearJoint) ErrorBias() float64
- func (c GearJoint) Free()
- func (c GearJoint) Impulse() float64
- func (c GearJoint) MaxBias() float64
- func (c GearJoint) MaxForce() float64
- func (c GearJoint) Phase() float64
- func (c GearJoint) Ratio() float64
- func (c GearJoint) SetErrorBias(b float64)
- func (c GearJoint) SetMaxBias(b float64)
- func (c GearJoint) SetMaxForce(f float64)
- func (c GearJoint) SetPhase(m float64)
- func (c GearJoint) SetPostSolveFunc(f func(c Constraint, s Space))
- func (c GearJoint) SetPreSolveFunc(f func(c Constraint, s Space))
- func (c GearJoint) SetRatio(m float64)
- func (c GearJoint) SetUserData(data interface{})
- func (c GearJoint) Space() Space
- func (c GearJoint) UserData() interface{}
- type GrooveJoint
- func (c GrooveJoint) A() Body
- func (c GrooveJoint) ActivateBodies()
- func (c GrooveJoint) Anchr2() Vect
- func (c GrooveJoint) B() Body
- func (c GrooveJoint) ErrorBias() float64
- func (c GrooveJoint) Free()
- func (c GrooveJoint) GrooveA() Vect
- func (c GrooveJoint) GrooveB() Vect
- func (c GrooveJoint) Impulse() float64
- func (c GrooveJoint) MaxBias() float64
- func (c GrooveJoint) MaxForce() float64
- func (c GrooveJoint) SetAnchr2(v Vect)
- func (c GrooveJoint) SetErrorBias(b float64)
- func (c GrooveJoint) SetGrooveA(v Vect)
- func (c GrooveJoint) SetGrooveB(v Vect)
- func (c GrooveJoint) SetMaxBias(b float64)
- func (c GrooveJoint) SetMaxForce(f float64)
- func (c GrooveJoint) SetPostSolveFunc(f func(c Constraint, s Space))
- func (c GrooveJoint) SetPreSolveFunc(f func(c Constraint, s Space))
- func (c GrooveJoint) SetUserData(data interface{})
- func (c GrooveJoint) Space() Space
- func (c GrooveJoint) UserData() interface{}
- type Group
- type Layers
- type NearestPointQuery
- type NearestPointQueryInfo
- type PinJoint
- func (c PinJoint) A() Body
- func (c PinJoint) ActivateBodies()
- func (c PinJoint) Anchr1() Vect
- func (c PinJoint) Anchr2() Vect
- func (c PinJoint) B() Body
- func (c PinJoint) Dist() float64
- func (c PinJoint) ErrorBias() float64
- func (c PinJoint) Free()
- func (c PinJoint) Impulse() float64
- func (c PinJoint) MaxBias() float64
- func (c PinJoint) MaxForce() float64
- func (c PinJoint) SetAnchr1(v Vect)
- func (c PinJoint) SetAnchr2(v Vect)
- func (c PinJoint) SetDist(d float64)
- func (c PinJoint) SetErrorBias(b float64)
- func (c PinJoint) SetMaxBias(b float64)
- func (c PinJoint) SetMaxForce(f float64)
- func (c PinJoint) SetPostSolveFunc(f func(c Constraint, s Space))
- func (c PinJoint) SetPreSolveFunc(f func(c Constraint, s Space))
- func (c PinJoint) SetUserData(data interface{})
- func (c PinJoint) Space() Space
- func (c PinJoint) UserData() interface{}
- type PivotJoint
- func (c PivotJoint) A() Body
- func (c PivotJoint) ActivateBodies()
- func (c PivotJoint) Anchr1() Vect
- func (c PivotJoint) Anchr2() Vect
- func (c PivotJoint) B() Body
- func (c PivotJoint) ErrorBias() float64
- func (c PivotJoint) Free()
- func (c PivotJoint) Impulse() float64
- func (c PivotJoint) MaxBias() float64
- func (c PivotJoint) MaxForce() float64
- func (c PivotJoint) SetAnchr1(v Vect)
- func (c PivotJoint) SetAnchr2(v Vect)
- func (c PivotJoint) SetErrorBias(b float64)
- func (c PivotJoint) SetMaxBias(b float64)
- func (c PivotJoint) SetMaxForce(f float64)
- func (c PivotJoint) SetPostSolveFunc(f func(c Constraint, s Space))
- func (c PivotJoint) SetPreSolveFunc(f func(c Constraint, s Space))
- func (c PivotJoint) SetUserData(data interface{})
- func (c PivotJoint) Space() Space
- func (c PivotJoint) UserData() interface{}
- type PointQuery
- type PolyShape
- func (s PolyShape) BB() BB
- func (s PolyShape) Body() Body
- func (s PolyShape) CacheBB() BB
- func (s PolyShape) CollisionType() CollisionType
- func (s PolyShape) Elasticity() float64
- func (s PolyShape) Free()
- func (s PolyShape) Friction() float64
- func (s PolyShape) Group() Group
- func (s PolyShape) Layers() Layers
- func (s PolyShape) NearestPointQuery(p Vect) (float64, NearestPointQueryInfo)
- func (s PolyShape) NumVerts() int
- func (s PolyShape) PointQuery(p Vect) bool
- func (s PolyShape) Radius() float64
- func (s PolyShape) SegmentQuery(a, b Vect) (bool, SegmentQueryInfo)
- func (s PolyShape) Sensor() bool
- func (s PolyShape) SetBody(b Body)
- func (s PolyShape) SetCollisionType(t CollisionType)
- func (s PolyShape) SetElasticity(e float64)
- func (s PolyShape) SetFriction(f float64)
- func (s PolyShape) SetGroup(g Group)
- func (s PolyShape) SetLayers(l Layers)
- func (s PolyShape) SetRadius(radius float64)
- func (s PolyShape) SetSensor(b bool)
- func (s PolyShape) SetSurfaceVelocity(v Vect)
- func (s PolyShape) SetUserData(data interface{})
- func (s PolyShape) SetVerts(verts []Vect, offset Vect)
- func (s PolyShape) Space() Space
- func (s PolyShape) String() string
- func (s PolyShape) SurfaceVelocity() Vect
- func (s PolyShape) Update(pos, rot Vect) BB
- func (s PolyShape) UserData() interface{}
- func (s PolyShape) VertLocal(idx int) Vect
- func (s PolyShape) VertsWorld() []Vect
- func (s PolyShape) VertsWorldFloat64() []float64
- type RatchetJoint
- func (c RatchetJoint) A() Body
- func (c RatchetJoint) ActivateBodies()
- func (c RatchetJoint) Angle() float64
- func (c RatchetJoint) B() Body
- func (c RatchetJoint) ErrorBias() float64
- func (c RatchetJoint) Free()
- func (c RatchetJoint) Impulse() float64
- func (c RatchetJoint) MaxBias() float64
- func (c RatchetJoint) MaxForce() float64
- func (c RatchetJoint) Phase() float64
- func (c RatchetJoint) Ratchet() float64
- func (c RatchetJoint) SetAngle(m float64)
- func (c RatchetJoint) SetErrorBias(b float64)
- func (c RatchetJoint) SetMaxBias(b float64)
- func (c RatchetJoint) SetMaxForce(f float64)
- func (c RatchetJoint) SetPhase(m float64)
- func (c RatchetJoint) SetPostSolveFunc(f func(c Constraint, s Space))
- func (c RatchetJoint) SetPreSolveFunc(f func(c Constraint, s Space))
- func (c RatchetJoint) SetRatchet(m float64)
- func (c RatchetJoint) SetUserData(data interface{})
- func (c RatchetJoint) Space() Space
- func (c RatchetJoint) UserData() interface{}
- type RotaryLimitJoint
- func (c RotaryLimitJoint) A() Body
- func (c RotaryLimitJoint) ActivateBodies()
- func (c RotaryLimitJoint) B() Body
- func (c RotaryLimitJoint) ErrorBias() float64
- func (c RotaryLimitJoint) Free()
- func (c RotaryLimitJoint) Impulse() float64
- func (c RotaryLimitJoint) Max() float64
- func (c RotaryLimitJoint) MaxBias() float64
- func (c RotaryLimitJoint) MaxForce() float64
- func (c RotaryLimitJoint) Min() float64
- func (c RotaryLimitJoint) SetErrorBias(b float64)
- func (c RotaryLimitJoint) SetMax(m float64)
- func (c RotaryLimitJoint) SetMaxBias(b float64)
- func (c RotaryLimitJoint) SetMaxForce(f float64)
- func (c RotaryLimitJoint) SetMin(m float64)
- func (c RotaryLimitJoint) SetPostSolveFunc(f func(c Constraint, s Space))
- func (c RotaryLimitJoint) SetPreSolveFunc(f func(c Constraint, s Space))
- func (c RotaryLimitJoint) SetUserData(data interface{})
- func (c RotaryLimitJoint) Space() Space
- func (c RotaryLimitJoint) UserData() interface{}
- type SegmentQuery
- type SegmentQueryInfo
- type SegmentShape
- func (s SegmentShape) A() Vect
- func (s SegmentShape) B() Vect
- func (s SegmentShape) BB() BB
- func (s SegmentShape) Body() Body
- func (s SegmentShape) CacheBB() BB
- func (s SegmentShape) CollisionType() CollisionType
- func (s SegmentShape) Elasticity() float64
- func (s SegmentShape) Free()
- func (s SegmentShape) Friction() float64
- func (s SegmentShape) Group() Group
- func (s SegmentShape) Layers() Layers
- func (s SegmentShape) NearestPointQuery(p Vect) (float64, NearestPointQueryInfo)
- func (s SegmentShape) Normal() Vect
- func (s SegmentShape) PointQuery(p Vect) bool
- func (s SegmentShape) Radius() float64
- func (s SegmentShape) SegmentQuery(a, b Vect) (bool, SegmentQueryInfo)
- func (s SegmentShape) Sensor() bool
- func (s SegmentShape) SetBody(b Body)
- func (s SegmentShape) SetCollisionType(t CollisionType)
- func (s SegmentShape) SetElasticity(e float64)
- func (s SegmentShape) SetEndpoints(a, b Vect)
- func (s SegmentShape) SetFriction(f float64)
- func (s SegmentShape) SetGroup(g Group)
- func (s SegmentShape) SetLayers(l Layers)
- func (s SegmentShape) SetNeighbors(prev, next Vect)
- func (s SegmentShape) SetRadius(radius float64)
- func (s SegmentShape) SetSensor(b bool)
- func (s SegmentShape) SetSurfaceVelocity(v Vect)
- func (s SegmentShape) SetUserData(data interface{})
- func (s SegmentShape) Space() Space
- func (s SegmentShape) String() string
- func (s SegmentShape) SurfaceVelocity() Vect
- func (s SegmentShape) Update(pos, rot Vect) BB
- func (s SegmentShape) UserData() interface{}
- type Shape
- type SimpleMotor
- func (c SimpleMotor) A() Body
- func (c SimpleMotor) ActivateBodies()
- func (c SimpleMotor) B() Body
- func (c SimpleMotor) ErrorBias() float64
- func (c SimpleMotor) Free()
- func (c SimpleMotor) Impulse() float64
- func (c SimpleMotor) MaxBias() float64
- func (c SimpleMotor) MaxForce() float64
- func (c SimpleMotor) Rate() float64
- func (c SimpleMotor) SetErrorBias(b float64)
- func (c SimpleMotor) SetMaxBias(b float64)
- func (c SimpleMotor) SetMaxForce(f float64)
- func (c SimpleMotor) SetPostSolveFunc(f func(c Constraint, s Space))
- func (c SimpleMotor) SetPreSolveFunc(f func(c Constraint, s Space))
- func (c SimpleMotor) SetRate(m float64)
- func (c SimpleMotor) SetUserData(data interface{})
- func (c SimpleMotor) Space() Space
- func (c SimpleMotor) UserData() interface{}
- type SlideJoint
- func (c SlideJoint) A() Body
- func (c SlideJoint) ActivateBodies()
- func (c SlideJoint) Anchr1() Vect
- func (c SlideJoint) Anchr2() Vect
- func (c SlideJoint) B() Body
- func (c SlideJoint) ErrorBias() float64
- func (c SlideJoint) Free()
- func (c SlideJoint) Impulse() float64
- func (c SlideJoint) Max() float64
- func (c SlideJoint) MaxBias() float64
- func (c SlideJoint) MaxForce() float64
- func (c SlideJoint) Min() float64
- func (c SlideJoint) SetAnchr1(v Vect)
- func (c SlideJoint) SetAnchr2(v Vect)
- func (c SlideJoint) SetErrorBias(b float64)
- func (c SlideJoint) SetMax(m float64)
- func (c SlideJoint) SetMaxBias(b float64)
- func (c SlideJoint) SetMaxForce(f float64)
- func (c SlideJoint) SetMin(m float64)
- func (c SlideJoint) SetPostSolveFunc(f func(c Constraint, s Space))
- func (c SlideJoint) SetPreSolveFunc(f func(c Constraint, s Space))
- func (c SlideJoint) SetUserData(data interface{})
- func (c SlideJoint) Space() Space
- func (c SlideJoint) UserData() interface{}
- type Space
- func (s Space) ActivateShapesTouchingShape(sh Shape)
- func (s Space) Add(obj SpaceObject) SpaceObject
- func (s Space) AddBody(b Body) Body
- func (s Space) AddCollisionHandler(a, b CollisionType, ...)
- func (s Space) AddConstraint(c Constraint) Constraint
- func (s Space) AddPostStepCallback(f func(Space, interface{}), key interface{}) bool
- func (s Space) AddShape(sh Shape) Shape
- func (s Space) AddStaticShape(sh Shape) Shape
- func (s Space) BBQuery(bb BB, layers Layers, group Group, f BBQuery)
- func (s Space) CollisionBias() float64
- func (s Space) CollisionPersistence() Timestamp
- func (s Space) CollisionSlop() float64
- func (s Space) Contains(obj SpaceObject) bool
- func (s Space) ConvertBodyToDynamic(b Body, m, i float64)
- func (s Space) ConvertBodyToStatic(b Body)
- func (s Space) CurrentTimeStep() float64
- func (s Space) Damping() float64
- func (s Space) Each(iter interface{})
- func (s Space) EachBody(iter func(Body))
- func (s Space) EachConstraint(iter func(Constraint))
- func (s Space) EachShape(iter func(Shape))
- func (s Space) EnableContactGraph() bool
- func (s Space) Free()
- func (s Space) FreeChildren()
- func (s Space) Gravity() Vect
- func (s Space) IdleSpeedThreshold() float64
- func (s Space) IsLocked() bool
- func (s Space) Iterations() int
- func (s Space) NearestPointQuery(point Vect, maxDistance float64, layers Layers, group Group, ...)
- func (s Space) PointQuery(point Vect, layers Layers, group Group, f PointQuery)
- func (s Space) PointQueryFirst(point Vect, layers Layers, group Group) Shape
- func (s Space) ReindexShape(sh Shape)
- func (s Space) ReindexShapesForBody(b Body)
- func (s Space) ReindexStatic()
- func (s Space) Remove(obj SpaceObject)
- func (s Space) RemoveBody(b Body)
- func (s Space) RemoveCollisionHandler(a CollisionType, b CollisionType)
- func (s Space) RemoveConstraint(c Constraint)
- func (s Space) RemoveShape(sh Shape)
- func (s Space) RemoveStaticShape(sh Shape)
- func (s Space) SegmentQuery(start, end Vect, layers Layers, group Group, f SegmentQuery)
- func (s Space) SetCollisionBias(b float64)
- func (s Space) SetCollisionPersistence(p Timestamp)
- func (s Space) SetCollisionSlop(sl float64)
- func (s Space) SetDamping(d float64)
- func (s Space) SetDefaultCollisionHandler(beginFunc, preSolveFunc func(Space, Arbiter, interface{}) bool, ...)
- func (s Space) SetEnableContactGraph(cg bool)
- func (s Space) SetGravity(g Vect)
- func (s Space) SetIdleSpeedThreshold(t float64)
- func (s Space) SetIterations(i int)
- func (s Space) SetSleepTimeThreshold(t float64)
- func (s Space) SetUserData(data interface{})
- func (s Space) SleepTimeThreshold() float64
- func (s Space) StaticBody() Body
- func (s Space) Step(dt float64)
- func (s Space) String() string
- func (s Space) UseSpatialHash(dim float64, count int)
- func (s Space) UserData() interface{}
- type SpaceObject
- type Timestamp
- type Vect
- func (a Vect) Add(b Vect) Vect
- func (a Vect) Dist(b Vect) float64
- func (v Vect) Div(x float64) Vect
- func (v1 Vect) Dot(v2 Vect) float64
- func (v Vect) Length() float64
- func (v1 Vect) Lerp(v2 Vect, t float64) Vect
- func (v1 Vect) LerpConst(v2 Vect, a float64) Vect
- func (v Vect) Mul(x float64) Vect
- func (v Vect) Neg() Vect
- func (v Vect) String() string
- func (a Vect) Sub(b Vect) Vect
- func (v Vect) ToAngle() float64
Constants ¶
const ( // NoGroup is a value for Shape.Group signifying that a shape is in no group. NoGroup = Group(0) // AllLayers is a value for Shape.Layers signifying that a shape is in every layer. AllLayers = Layers(0) )
const ( VersionMajor = int(C.CP_VERSION_MAJOR) VersionMinor = int(C.CP_VERSION_MINOR) VersionRelease = int(C.CP_VERSION_RELEASE) )
Chipmunk version.
Variables ¶
This section is empty.
Functions ¶
func AreaForCircle ¶
AreaForCircle returns the area of a hollow circle.
func AreaForPoly ¶
AreaForPoly returns the signed area of a polygon. A Clockwise winding gives positive area. This is probably backwards from what you expect, but matches Chipmunk's the winding for poly shapes.
func AreaForSegment ¶
AreaForSegment returns the area of a fattened (capsule shaped) line segment.
func MomentForBox ¶
MomentForBox returns the moment of inertia for a solid box.
func MomentForBox2 ¶
MomentForBox2 returns the moment of inertia for a solid box.
func MomentForCircle ¶
MomentForCircle returns the moment of inertia for a circle.
func MomentForPoly ¶
MomentForPoly returns the moment of inertia for a solid polygon shape assuming it's center of gravity is at it's centroid. The offset is added to each vertex.
func MomentForSegment ¶
MomentForSegment returns the moment of inertia for a line segment.
func PolyValidate ¶
PolyValidate returns true if a set of vertexes is convex and has a clockwise winding.
func RecenterPoly ¶
func RecenterPoly(verts []Vect)
RecenterPoly centers the polygon on the origin (subtracts the centroid of the polygon from each vertex).
func ResetShapeIDCounter ¶
func ResetShapeIDCounter()
ResetShapeIDCounter is used to reset the shape ID counter when recreating a space. When initializing a shape, it's hash value comes from a counter. Because the hash value may affect iteration order, you can reset the shape ID counter when recreating a space. This will make the simulation be deterministic.
func VertsEqual ¶
VertsEqual returns a boolean reporting whether a == b.
Types ¶
type Arbiter ¶
type Arbiter uintptr
Arbiter is a type of colliding pair of shapes.
func (Arbiter) Bodies ¶
Bodies returns the colliding bodies involved for this arbiter. The order of the CollisionType the bodies are associated with values will match the order set when the collision handler was registered.
func (Arbiter) ContactPoints ¶
func (a Arbiter) ContactPoints() []ContactPoint
ContactPoints returns a contact set from an arbiter.
func (Arbiter) Elasticity ¶
Elasticity returns a calculated value to use for the elasticity coefficient. Override in a pre-solve collision handler for custom behavior.
func (Arbiter) Friction ¶
Friction returns a calculated value to use for the friction coefficient. Override in a pre-solve collision handler for custom behavior.
func (Arbiter) Ignore ¶
func (a Arbiter) Ignore()
Ignore causes a collision pair to be ignored as if you returned false from a begin callback. If called from a pre-step callback, you will still need to return false if you want it to be ignored in the current step.
func (Arbiter) IsFirstContact ¶
IsFirstContact returns true if this is the first step a pair of objects started colliding.
func (Arbiter) SetContactPoints ¶
func (a Arbiter) SetContactPoints(cp []ContactPoint)
SetContactPoints replaces the contact point set for an arbiter. This can be a very powerful feature, but use it with caution!
func (Arbiter) SetElasticity ¶
SetElasticity sets elasticity coefficient.
func (Arbiter) SetFriction ¶
SetFriction sets friction coefficient.
func (Arbiter) SetSurfaceVelocity ¶
SetSurfaceVelocity sets calculated value to use for applying surface velocities.
func (Arbiter) Shapes ¶
Shapes returns the colliding shapes involved for this arbiter. The order of their CollisionType values will match the order set when the collision handler was registered.
func (Arbiter) SurfaceVelocity ¶
SurfaceVelocity returns a calculated value to use for applying surface velocities. Override in a pre-solve collision handler for custom behavior.
func (Arbiter) TotalImpulse ¶
TotalImpulse returns the total impulse that was applied by this arbiter. This function should only be called from a post-solve, post-step or body.EachArbiter callback.
func (Arbiter) TotalImpulseWithFriction ¶
TotalImpulseWithFriction returns the total impulse including the friction that was applied by this arbiter. This function should only be called from a post-solve, post-step or body.EachArbiter callback.
type BB ¶
type BB struct {
// contains filtered or unexported fields
}
BB is an axis-aligned 2D bounding box type (left, bottom, right, top).
func BBNewForCircle ¶
BBNewForCircle constructs a BB for a circle with the given position and radius.
func (BB) ContainsVect ¶
ContainsVect returns true if the bounding box contains a vector.
func (BB) Intersects ¶
Intersects returns true if two bounding boxes intersect.
func (BB) IntersectsSegment ¶
IntersectsSegment returns true if the bounding box intersects the line segment defined using two points.
func (BB) MergedArea ¶
MergedArea merges two bounding boxes and returns the area of the merged bounding box.
func (BB) SegmentQuery ¶
SegmentQuery returns the fraction along the segment query the BB is hit. Returns math.Inf(1) if it doesn't hit.
type Body ¶
type Body uintptr
Body is a rigid body struct.
func (Body) ActivateStatic ¶
ActivateStatic wakes up any sleeping or idle bodies touching a static body.
func (Body) Angle ¶
Angle returns the rotation of the body around it's center of gravity in radians.
func (Body) AngularVelocity ¶
AngularVelocity returns the angular velocity of the body around it's center of gravity in radians/second.
func (Body) AngularVelocityLimit ¶
AngularVelocityLimit returns the maximum rotational rate (in radians/second) allowed when updating the angular velocity.
func (Body) ApplyForce ¶
ApplyForce applies a force (in world coordinates) to the body at a point relative to the center of gravity (also in world coordinates).
func (Body) ApplyImpulse ¶
ApplyImpulse applies an impulse (in world coordinates) to the body at a point relative to the center of gravity (also in world coordinates).
func (Body) EachArbiter ¶
EachArbiter calls a callback function once for each arbiter which is currently active on the body.
func (Body) EachConstraint ¶
func (b Body) EachConstraint(iter func(Body, Constraint))
EachConstraint calls a callback function once for each constraint attached to the body and added to the space.
func (Body) EachShape ¶
EachShape calls a callback function once for each shape attached to the body and added to the space.
func (Body) IsSleeping ¶
IsSleeping returns true if the body is sleeping.
func (Body) KineticEnergy ¶
KineticEnergy returns the kinetic energy of a body.
func (Body) LocalToWorld ¶
LocalToWorld converts body relative/local coordinates to absolute/world coordinates.
func (Body) ResetForces ¶
func (b Body) ResetForces()
ResetForces sets the forces and torque of a body to zero.
func (Body) Rotation ¶
Rotation returns the cached unit length vector representing the angle of the body.
func (Body) SetAngle ¶
SetAngle sets the rotation of the body around it's center of gravity in radians.
func (Body) SetAngularVelocity ¶
SetAngularVelocity sets the angular velocity of the body around it's center of gravity in radians/second.
func (Body) SetAngularVelocityLimit ¶
SetAngularVelocityLimit sets the maximum rotational rate (in radians/second) allowed when updating the angular velocity.
func (Body) SetPosition ¶
SetPosition sets the position of the body.
func (Body) SetPositionFunc ¶
SetPositionFunc sets a function that is called to integrate the body's position.
func (Body) SetTorque ¶
SetTorque sets the torque applied to the body around it's center of gravity.
func (Body) SetUserData ¶
func (b Body) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Body reference in a callback.
func (Body) SetVelocity ¶
SetVelocity sets the velocity of the body.
func (Body) SetVelocityFunc ¶
SetVelocityFunc sets a function that is called to integrate the body's velocity.
func (Body) SetVelocityLimit ¶
SetVelocityLimit sets the maximum velocity allowed when updating the velocity.
func (Body) SleepWithGroup ¶
SleepWithGroup forces a body to fall asleep immediately along with other bodies in a group.
func (Body) Space ¶
Space returns space the body was added to or 0 if the body doesn't belong to any space.
func (Body) UpdatePosition ¶
UpdatePosition is a default function that is called to integrate the body's position.
func (Body) UpdateVelocity ¶
UpdateVelocity is a default function that is called to integrate the body's velocity.
func (Body) VelocityAtLocalPoint ¶
VelocityAtLocalPoint returns the velocity on a body (in world units) at a point on the body in local coordinates.
func (Body) VelocityAtWorldPoint ¶
VelocityAtWorldPoint returns the velocity on a body (in world units) at a point on the body in world coordinates.
func (Body) VelocityLimit ¶
VelocityLimit returns the maximum velocity allowed when updating the velocity.
func (Body) WorldToLocal ¶
WorldToLocal converts body absolute/world coordinates to relative/local coordinates.
type CircleShape ¶
type CircleShape struct {
// contains filtered or unexported fields
}
CircleShape is a circle shape type.
func CircleShapeNew ¶
func CircleShapeNew(body Body, radius float64, offset Vect) CircleShape
CircleShapeNew creates a new circle shape.
func (CircleShape) Body ¶
func (s CircleShape) Body() Body
Body returns the rigid body this collision shape is attached to.
func (CircleShape) CacheBB ¶
func (s CircleShape) CacheBB() BB
CacheBB updates, caches and returns the bounding box of a shape based on the body it's attached to.
func (CircleShape) Center ¶
func (s CircleShape) Center() Vect
Center returns the center of the circle shape (world coordinates).
func (CircleShape) CollisionType ¶
func (s CircleShape) CollisionType() CollisionType
CollisionType returns collision type of the shape used when picking collision handlers.
func (CircleShape) Elasticity ¶
func (s CircleShape) Elasticity() float64
Elasticity returns shape's coefficient of restitution.
func (CircleShape) Friction ¶
func (s CircleShape) Friction() float64
Friction returns shape's coefficient of friction.
func (CircleShape) Group ¶
func (s CircleShape) Group() Group
Group returns a group of the shape. Shapes in the same group don't collide.
func (CircleShape) Layers ¶
func (s CircleShape) Layers() Layers
Layers returns layers bitmask of the shape. Shapes collide only if bitwise of their layers is non-zero.
func (CircleShape) NearestPointQuery ¶
func (s CircleShape) NearestPointQuery(p Vect) (float64, NearestPointQueryInfo)
NearestPointQuery finds the closest point on the surface of shape to a specific point. The first returned value is the distance between the points. A negative distance means the point is inside the shape.
func (CircleShape) Offset ¶
func (s CircleShape) Offset() Vect
Offset returns the offset from the center of gravity.
func (CircleShape) PointQuery ¶
PointQuery returns true if a point lies within a shape.
func (CircleShape) Radius ¶
func (s CircleShape) Radius() float64
Radius returns the radius of the circle.
func (CircleShape) SegmentQuery ¶
func (s CircleShape) SegmentQuery(a, b Vect) (bool, SegmentQueryInfo)
SegmentQuery performs a segment query against a shape.
func (CircleShape) Sensor ¶
func (s CircleShape) Sensor() bool
Sensor returns true when shape is "sensor" one, i.e. does not produce collisions.
func (CircleShape) SetBody ¶
func (s CircleShape) SetBody(b Body)
SetBody sets the rigid body this collision shape is attached to.
func (CircleShape) SetCollisionType ¶
func (s CircleShape) SetCollisionType(t CollisionType)
SetCollisionType sets collision type of the shape used when picking collision handlers.
func (CircleShape) SetElasticity ¶
func (s CircleShape) SetElasticity(e float64)
SetElasticity sets coefficient of restitution.
func (CircleShape) SetFriction ¶
func (s CircleShape) SetFriction(f float64)
SetFriction sets coefficient of friction.
func (CircleShape) SetGroup ¶
func (s CircleShape) SetGroup(g Group)
SetGroup sets a group of the shape. Shapes in the same group don't collide.
func (CircleShape) SetLayers ¶
func (s CircleShape) SetLayers(l Layers)
SetLayers sets layers bitmask of the shape. Shapes collide only if bitwise of their layers is non-zero.
func (CircleShape) SetOffset ¶
func (s CircleShape) SetOffset(offset Vect)
SetOffset sets the offset from the center of gravity. NOTE: this is unsafe function.
func (CircleShape) SetRadius ¶
func (s CircleShape) SetRadius(radius float64)
SetRadius sets the radius of the circle. NOTE: this is unsafe function.
func (CircleShape) SetSensor ¶
func (s CircleShape) SetSensor(b bool)
SetSensor sets if the shape is "sensor" one, i.e. does not produce collisions, but still calls collision callbacks.
func (CircleShape) SetSurfaceVelocity ¶
func (s CircleShape) SetSurfaceVelocity(v Vect)
SetSurfaceVelocity sets surface velocity used when solving friction.
func (CircleShape) SetUserData ¶
func (s CircleShape) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Shape reference in a callback.
func (CircleShape) Space ¶
func (s CircleShape) Space() Space
Space returns space the body was added to or nil if the body doesn't belong to any space.
func (CircleShape) String ¶
func (s CircleShape) String() string
String converts a circle shape to a human-readable string.
func (CircleShape) SurfaceVelocity ¶
func (s CircleShape) SurfaceVelocity() Vect
SurfaceVelocity returns surface velocity used when solving friction.
type CollisionType ¶
type CollisionType C.cpCollisionType
CollisionType is a type used for Space.CollisionType.
type Constraint ¶
type Constraint interface { A() Body ActivateBodies() B() Body ErrorBias() float64 Free() Impulse() float64 MaxBias() float64 MaxForce() float64 SetErrorBias(float64) SetMaxBias(float64) SetMaxForce(float64) SetUserData(interface{}) Space() Space UserData() interface{} // contains filtered or unexported methods }
Constraint is a type of object which is used to connect two bodies together.
type ContactPoint ¶
type ContactPoint struct { // Point is position normal of the contact point. Point Vect // Normal is the normal of the contact point. Normal Vect // Dist is the depth of the contact point. Dist float64 }
ContactPoint is a contact point type of collision.
type DampedRotarySpring ¶
type DampedRotarySpring struct {
// contains filtered or unexported fields
}
DampedRotarySpring is like a DampedSpring, but operates in a rotational fashion.
func DampedRotarySpringNew ¶
func DampedRotarySpringNew(a, b Body, restAngle, stiffness, damping float64) DampedRotarySpring
DampedRotarySpringNew creates a new damped rotary spring.
func (DampedRotarySpring) A ¶
func (c DampedRotarySpring) A() Body
A returns the first body the constraint controls.
func (DampedRotarySpring) ActivateBodies ¶
func (c DampedRotarySpring) ActivateBodies()
ActivateBodies calls Activate() on bodies the constraint controls.
func (DampedRotarySpring) B ¶
func (c DampedRotarySpring) B() Body
B returns the second body the constraint controls.
func (DampedRotarySpring) Damping ¶
func (c DampedRotarySpring) Damping() float64
Damping returns the amount of viscous damping to apply.
func (DampedRotarySpring) ErrorBias ¶
func (c DampedRotarySpring) ErrorBias() float64
ErrorBias returns the rate at which joint error is corrected.
func (DampedRotarySpring) Impulse ¶
func (c DampedRotarySpring) Impulse() float64
Impulse returns the last impulse applied by this constraint.
func (DampedRotarySpring) MaxBias ¶
func (c DampedRotarySpring) MaxBias() float64
MaxBias returns the maximum rate (speed) that a joint can be corrected at.
func (DampedRotarySpring) MaxForce ¶
func (c DampedRotarySpring) MaxForce() float64
MaxForce returns the maximum force this constraint is allowed to use.
func (DampedRotarySpring) RestAngle ¶
func (c DampedRotarySpring) RestAngle() float64
RestAngle returns the angular offset in radians the spring attempts to keep between the two bodies.
func (DampedRotarySpring) SetDamping ¶
func (c DampedRotarySpring) SetDamping(damping float64)
SetDamping sets the amount of viscous damping to apply.
func (DampedRotarySpring) SetErrorBias ¶
func (c DampedRotarySpring) SetErrorBias(b float64)
SetErrorBias sets the rate at which joint error is corrected. Defaults to math.Pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
func (DampedRotarySpring) SetMaxBias ¶
func (c DampedRotarySpring) SetMaxBias(b float64)
SetMaxBias sets the maximum rate (speed) that a joint can be corrected at (defaults to infinity).
func (DampedRotarySpring) SetMaxForce ¶
func (c DampedRotarySpring) SetMaxForce(f float64)
SetMaxForce sets the maximum force this constraint is allowed to use (defalts to infinity). This allows joints to be pulled apart if too much force is applied to them. It also allows you to use constraints as force or friction generators for controlling bodies.
func (DampedRotarySpring) SetPostSolveFunc ¶
func (c DampedRotarySpring) SetPostSolveFunc(f func(c Constraint, s Space))
SetPostSolveFunc sets a callback function type that gets called after solving a joint. Use the applied impulse to perform effects like breakable joints.
func (DampedRotarySpring) SetPreSolveFunc ¶
func (c DampedRotarySpring) SetPreSolveFunc(f func(c Constraint, s Space))
SetPreSolveFunc sets a callback function type that gets called before solving a joint. Animate your joint anchors, update your motor torque, etc.
func (DampedRotarySpring) SetRestAngle ¶
func (c DampedRotarySpring) SetRestAngle(restAngle float64)
SetRestAngle sets the angular offset in radians the spring attempts to keep between the two bodies.
func (DampedRotarySpring) SetStiffness ¶
func (c DampedRotarySpring) SetStiffness(stiffness float64)
SetStiffness sets the young's modulus of the spring.
func (DampedRotarySpring) SetUserData ¶
func (c DampedRotarySpring) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Constraint reference in a callback.
func (DampedRotarySpring) Space ¶
func (c DampedRotarySpring) Space() Space
Space returns space the constraint was added to or 0 if the constraint doesn't belong to any space.
func (DampedRotarySpring) Stiffness ¶
func (c DampedRotarySpring) Stiffness() float64
Stiffness returns the young's modulus of the spring.
type DampedSpring ¶
type DampedSpring struct {
// contains filtered or unexported fields
}
DampedSpring is a spring with a damper. While a spring is not technically a constraint, the damper is. The spring forces are simply a convenience.
func DampedSpringNew ¶
func DampedSpringNew(a, b Body, anchr1, anchr2 Vect, restLength, stiffness, damping float64) DampedSpring
DampedSpringNew creates a new damped spring.
func (DampedSpring) A ¶
func (c DampedSpring) A() Body
A returns the first body the constraint controls.
func (DampedSpring) ActivateBodies ¶
func (c DampedSpring) ActivateBodies()
ActivateBodies calls Activate() on bodies the constraint controls.
func (DampedSpring) Anchr1 ¶
func (c DampedSpring) Anchr1() Vect
Anchr1 returns the anchor point on the first body.
func (DampedSpring) Anchr2 ¶
func (c DampedSpring) Anchr2() Vect
Anchr2 returns the anchor point on the second body.
func (DampedSpring) B ¶
func (c DampedSpring) B() Body
B returns the second body the constraint controls.
func (DampedSpring) Damping ¶
func (c DampedSpring) Damping() float64
Damping returns the amount of viscous damping to apply.
func (DampedSpring) ErrorBias ¶
func (c DampedSpring) ErrorBias() float64
ErrorBias returns the rate at which joint error is corrected.
func (DampedSpring) Impulse ¶
func (c DampedSpring) Impulse() float64
Impulse returns the last impulse applied by this constraint.
func (DampedSpring) MaxBias ¶
func (c DampedSpring) MaxBias() float64
MaxBias returns the maximum rate (speed) that a joint can be corrected at.
func (DampedSpring) MaxForce ¶
func (c DampedSpring) MaxForce() float64
MaxForce returns the maximum force this constraint is allowed to use.
func (DampedSpring) RestLength ¶
func (c DampedSpring) RestLength() float64
RestLength returns the length the spring wants to contract or expand to.
func (DampedSpring) SetAnchr1 ¶
func (c DampedSpring) SetAnchr1(v Vect)
SetAnchr1 sets the anchor point on the first body.
func (DampedSpring) SetAnchr2 ¶
func (c DampedSpring) SetAnchr2(v Vect)
SetAnchr2 sets the anchor point on the second body.
func (DampedSpring) SetDamping ¶
func (c DampedSpring) SetDamping(damping float64)
SetDamping sets the amount of viscous damping to apply.
func (DampedSpring) SetErrorBias ¶
func (c DampedSpring) SetErrorBias(b float64)
SetErrorBias sets the rate at which joint error is corrected. Defaults to math.Pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
func (DampedSpring) SetMaxBias ¶
func (c DampedSpring) SetMaxBias(b float64)
SetMaxBias sets the maximum rate (speed) that a joint can be corrected at (defaults to infinity).
func (DampedSpring) SetMaxForce ¶
func (c DampedSpring) SetMaxForce(f float64)
SetMaxForce sets the maximum force this constraint is allowed to use (defalts to infinity). This allows joints to be pulled apart if too much force is applied to them. It also allows you to use constraints as force or friction generators for controlling bodies.
func (DampedSpring) SetPostSolveFunc ¶
func (c DampedSpring) SetPostSolveFunc(f func(c Constraint, s Space))
SetPostSolveFunc sets a callback function type that gets called after solving a joint. Use the applied impulse to perform effects like breakable joints.
func (DampedSpring) SetPreSolveFunc ¶
func (c DampedSpring) SetPreSolveFunc(f func(c Constraint, s Space))
SetPreSolveFunc sets a callback function type that gets called before solving a joint. Animate your joint anchors, update your motor torque, etc.
func (DampedSpring) SetRestLength ¶
func (c DampedSpring) SetRestLength(restLength float64)
SetRestLength sets the length the spring wants to contract or expand to.
func (DampedSpring) SetStiffness ¶
func (c DampedSpring) SetStiffness(stiffness float64)
SetStiffness sets the young's modulus of the spring.
func (DampedSpring) SetUserData ¶
func (c DampedSpring) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Constraint reference in a callback.
func (DampedSpring) Space ¶
func (c DampedSpring) Space() Space
Space returns space the constraint was added to or 0 if the constraint doesn't belong to any space.
func (DampedSpring) Stiffness ¶
func (c DampedSpring) Stiffness() float64
Stiffness returns the young's modulus of the spring.
type GearJoint ¶
type GearJoint struct {
// contains filtered or unexported fields
}
GearJoint constrains the rotational speed of one body to another. A ratio of 1.0 will lock the rotation of two bodies together, and negative ratios will cause them to spin in opposite directions. You can also use gear joints as rotary servos by setting MaxForce and MaxBias to finite values and changing the Phase property.
func GearJointNew ¶
GearJointNew creates a new gear joint.
func (GearJoint) ActivateBodies ¶
func (c GearJoint) ActivateBodies()
ActivateBodies calls Activate() on bodies the constraint controls.
func (GearJoint) ErrorBias ¶
func (c GearJoint) ErrorBias() float64
ErrorBias returns the rate at which joint error is corrected.
func (GearJoint) Impulse ¶
func (c GearJoint) Impulse() float64
Impulse returns the last impulse applied by this constraint.
func (GearJoint) MaxBias ¶
func (c GearJoint) MaxBias() float64
MaxBias returns the maximum rate (speed) that a joint can be corrected at.
func (GearJoint) MaxForce ¶
func (c GearJoint) MaxForce() float64
MaxForce returns the maximum force this constraint is allowed to use.
func (GearJoint) SetErrorBias ¶
func (c GearJoint) SetErrorBias(b float64)
SetErrorBias sets the rate at which joint error is corrected. Defaults to math.Pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
func (GearJoint) SetMaxBias ¶
func (c GearJoint) SetMaxBias(b float64)
SetMaxBias sets the maximum rate (speed) that a joint can be corrected at (defaults to infinity).
func (GearJoint) SetMaxForce ¶
func (c GearJoint) SetMaxForce(f float64)
SetMaxForce sets the maximum force this constraint is allowed to use (defalts to infinity). This allows joints to be pulled apart if too much force is applied to them. It also allows you to use constraints as force or friction generators for controlling bodies.
func (GearJoint) SetPostSolveFunc ¶
func (c GearJoint) SetPostSolveFunc(f func(c Constraint, s Space))
SetPostSolveFunc sets a callback function type that gets called after solving a joint. Use the applied impulse to perform effects like breakable joints.
func (GearJoint) SetPreSolveFunc ¶
func (c GearJoint) SetPreSolveFunc(f func(c Constraint, s Space))
SetPreSolveFunc sets a callback function type that gets called before solving a joint. Animate your joint anchors, update your motor torque, etc.
func (GearJoint) SetUserData ¶
func (c GearJoint) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Constraint reference in a callback.
type GrooveJoint ¶
type GrooveJoint struct {
// contains filtered or unexported fields
}
GrooveJoint holds a pivot point on one body to line along a line segment on another like a pin in a groove.
func GrooveJointNew ¶
func GrooveJointNew(a, b Body, grooveA, grooveB, anchr2 Vect) GrooveJoint
GrooveJointNew creates a new groove joint. Make sure you have the bodies in the right place as the joint will snap into shape as soon as you start simulating the space.
func (GrooveJoint) A ¶
func (c GrooveJoint) A() Body
A returns the first body the constraint controls.
func (GrooveJoint) ActivateBodies ¶
func (c GrooveJoint) ActivateBodies()
ActivateBodies calls Activate() on bodies the constraint controls.
func (GrooveJoint) Anchr2 ¶
func (c GrooveJoint) Anchr2() Vect
Anchr2 returns the anchor point on the second body that is held to the line segment on the first.
func (GrooveJoint) B ¶
func (c GrooveJoint) B() Body
B returns the second body the constraint controls.
func (GrooveJoint) ErrorBias ¶
func (c GrooveJoint) ErrorBias() float64
ErrorBias returns the rate at which joint error is corrected.
func (GrooveJoint) GrooveA ¶
func (c GrooveJoint) GrooveA() Vect
GrooveA returns the start of the line segment on the first body.
func (GrooveJoint) GrooveB ¶
func (c GrooveJoint) GrooveB() Vect
GrooveB returns the end of the line segment on the first body.
func (GrooveJoint) Impulse ¶
func (c GrooveJoint) Impulse() float64
Impulse returns the last impulse applied by this constraint.
func (GrooveJoint) MaxBias ¶
func (c GrooveJoint) MaxBias() float64
MaxBias returns the maximum rate (speed) that a joint can be corrected at.
func (GrooveJoint) MaxForce ¶
func (c GrooveJoint) MaxForce() float64
MaxForce returns the maximum force this constraint is allowed to use.
func (GrooveJoint) SetAnchr2 ¶
func (c GrooveJoint) SetAnchr2(v Vect)
SetAnchr2 sets the anchor point on the second body that is held to the line segment on the first.
func (GrooveJoint) SetErrorBias ¶
func (c GrooveJoint) SetErrorBias(b float64)
SetErrorBias sets the rate at which joint error is corrected. Defaults to math.Pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
func (GrooveJoint) SetGrooveA ¶
func (c GrooveJoint) SetGrooveA(v Vect)
SetGrooveA sets the start of the line segment on the first body.
func (GrooveJoint) SetGrooveB ¶
func (c GrooveJoint) SetGrooveB(v Vect)
SetGrooveB sets the end of the line segment on the first body.
func (GrooveJoint) SetMaxBias ¶
func (c GrooveJoint) SetMaxBias(b float64)
SetMaxBias sets the maximum rate (speed) that a joint can be corrected at (defaults to infinity).
func (GrooveJoint) SetMaxForce ¶
func (c GrooveJoint) SetMaxForce(f float64)
SetMaxForce sets the maximum force this constraint is allowed to use (defalts to infinity). This allows joints to be pulled apart if too much force is applied to them. It also allows you to use constraints as force or friction generators for controlling bodies.
func (GrooveJoint) SetPostSolveFunc ¶
func (c GrooveJoint) SetPostSolveFunc(f func(c Constraint, s Space))
SetPostSolveFunc sets a callback function type that gets called after solving a joint. Use the applied impulse to perform effects like breakable joints.
func (GrooveJoint) SetPreSolveFunc ¶
func (c GrooveJoint) SetPreSolveFunc(f func(c Constraint, s Space))
SetPreSolveFunc sets a callback function type that gets called before solving a joint. Animate your joint anchors, update your motor torque, etc.
func (GrooveJoint) SetUserData ¶
func (c GrooveJoint) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Constraint reference in a callback.
type NearestPointQuery ¶
NearestPointQuery is a callback function type for NearestPointQuery function.
type NearestPointQueryInfo ¶
type NearestPointQueryInfo struct { // Shape is the nearest shape. nil if no shape was within range. Shape // P is the closest point on the shape's surface (world space coordinates). P Vect // D is the distance to the point. Negative if the point is inside the shape. D float64 // G is the gradient of the signed distance field for the shape. G Vect }
NearestPointQueryInfo is a nearest point query struct.
type PinJoint ¶
type PinJoint struct {
// contains filtered or unexported fields
}
PinJoint holds a set distance between points on two bodies. Think of them as connecting a solid pin or rod between the two anchor points.
func PinJointNew ¶
PinJointNew creates a new pin joint.
func (PinJoint) ActivateBodies ¶
func (c PinJoint) ActivateBodies()
ActivateBodies calls Activate() on bodies the constraint controls.
func (PinJoint) Dist ¶
Dist returns the distance between the two anchor points that the joint keeps.
func (PinJoint) ErrorBias ¶
func (c PinJoint) ErrorBias() float64
ErrorBias returns the rate at which joint error is corrected.
func (PinJoint) Impulse ¶
func (c PinJoint) Impulse() float64
Impulse returns the last impulse applied by this constraint.
func (PinJoint) MaxBias ¶
func (c PinJoint) MaxBias() float64
MaxBias returns the maximum rate (speed) that a joint can be corrected at.
func (PinJoint) MaxForce ¶
func (c PinJoint) MaxForce() float64
MaxForce returns the maximum force this constraint is allowed to use.
func (PinJoint) SetDist ¶
SetDist sets the distance between the two anchor points that the joint keeps.
func (PinJoint) SetErrorBias ¶
func (c PinJoint) SetErrorBias(b float64)
SetErrorBias sets the rate at which joint error is corrected. Defaults to math.Pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
func (PinJoint) SetMaxBias ¶
func (c PinJoint) SetMaxBias(b float64)
SetMaxBias sets the maximum rate (speed) that a joint can be corrected at (defaults to infinity).
func (PinJoint) SetMaxForce ¶
func (c PinJoint) SetMaxForce(f float64)
SetMaxForce sets the maximum force this constraint is allowed to use (defalts to infinity). This allows joints to be pulled apart if too much force is applied to them. It also allows you to use constraints as force or friction generators for controlling bodies.
func (PinJoint) SetPostSolveFunc ¶
func (c PinJoint) SetPostSolveFunc(f func(c Constraint, s Space))
SetPostSolveFunc sets a callback function type that gets called after solving a joint. Use the applied impulse to perform effects like breakable joints.
func (PinJoint) SetPreSolveFunc ¶
func (c PinJoint) SetPreSolveFunc(f func(c Constraint, s Space))
SetPreSolveFunc sets a callback function type that gets called before solving a joint. Animate your joint anchors, update your motor torque, etc.
func (PinJoint) SetUserData ¶
func (c PinJoint) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Constraint reference in a callback.
type PivotJoint ¶
type PivotJoint struct {
// contains filtered or unexported fields
}
PivotJoint holds two points on two bodies together allowing them to rotate freely around the pivot.
func PivotJointNew ¶
func PivotJointNew(a, b Body, pivot Vect) PivotJoint
PivotJointNew creates a new pivot joint.
func PivotJointNew2 ¶
func PivotJointNew2(a, b Body, anchr1, anchr2 Vect) PivotJoint
PivotJointNew2 creates a new pivot joint with the two anchor points.
func (PivotJoint) A ¶
func (c PivotJoint) A() Body
A returns the first body the constraint controls.
func (PivotJoint) ActivateBodies ¶
func (c PivotJoint) ActivateBodies()
ActivateBodies calls Activate() on bodies the constraint controls.
func (PivotJoint) Anchr1 ¶
func (c PivotJoint) Anchr1() Vect
Anchr1 returns the anchor point on the first body.
func (PivotJoint) Anchr2 ¶
func (c PivotJoint) Anchr2() Vect
Anchr2 returns the anchor point on the second body.
func (PivotJoint) B ¶
func (c PivotJoint) B() Body
B returns the second body the constraint controls.
func (PivotJoint) ErrorBias ¶
func (c PivotJoint) ErrorBias() float64
ErrorBias returns the rate at which joint error is corrected.
func (PivotJoint) Impulse ¶
func (c PivotJoint) Impulse() float64
Impulse returns the last impulse applied by this constraint.
func (PivotJoint) MaxBias ¶
func (c PivotJoint) MaxBias() float64
MaxBias returns the maximum rate (speed) that a joint can be corrected at.
func (PivotJoint) MaxForce ¶
func (c PivotJoint) MaxForce() float64
MaxForce returns the maximum force this constraint is allowed to use.
func (PivotJoint) SetAnchr1 ¶
func (c PivotJoint) SetAnchr1(v Vect)
SetAnchr1 sets the anchor point on the first body.
func (PivotJoint) SetAnchr2 ¶
func (c PivotJoint) SetAnchr2(v Vect)
SetAnchr2 sets the anchor point on the second body.
func (PivotJoint) SetErrorBias ¶
func (c PivotJoint) SetErrorBias(b float64)
SetErrorBias sets the rate at which joint error is corrected. Defaults to math.Pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
func (PivotJoint) SetMaxBias ¶
func (c PivotJoint) SetMaxBias(b float64)
SetMaxBias sets the maximum rate (speed) that a joint can be corrected at (defaults to infinity).
func (PivotJoint) SetMaxForce ¶
func (c PivotJoint) SetMaxForce(f float64)
SetMaxForce sets the maximum force this constraint is allowed to use (defalts to infinity). This allows joints to be pulled apart if too much force is applied to them. It also allows you to use constraints as force or friction generators for controlling bodies.
func (PivotJoint) SetPostSolveFunc ¶
func (c PivotJoint) SetPostSolveFunc(f func(c Constraint, s Space))
SetPostSolveFunc sets a callback function type that gets called after solving a joint. Use the applied impulse to perform effects like breakable joints.
func (PivotJoint) SetPreSolveFunc ¶
func (c PivotJoint) SetPreSolveFunc(f func(c Constraint, s Space))
SetPreSolveFunc sets a callback function type that gets called before solving a joint. Animate your joint anchors, update your motor torque, etc.
func (PivotJoint) SetUserData ¶
func (c PivotJoint) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Constraint reference in a callback.
type PointQuery ¶
type PointQuery func(s Shape)
PointQuery is a callback function type for PointQuery function.
type PolyShape ¶
type PolyShape struct {
// contains filtered or unexported fields
}
PolyShape is a polygon shape type.
func PolyShapeNew ¶
PolyShapeNew creates a new polygon shape.
func PolyShapeNew2 ¶
PolyShapeNew2 creates a new polygon shape.
func (PolyShape) Body ¶
func (s PolyShape) Body() Body
Body returns the rigid body this collision shape is attached to.
func (PolyShape) CacheBB ¶
func (s PolyShape) CacheBB() BB
CacheBB updates, caches and returns the bounding box of a shape based on the body it's attached to.
func (PolyShape) CollisionType ¶
func (s PolyShape) CollisionType() CollisionType
CollisionType returns collision type of the shape used when picking collision handlers.
func (PolyShape) Elasticity ¶
func (s PolyShape) Elasticity() float64
Elasticity returns shape's coefficient of restitution.
func (PolyShape) Friction ¶
func (s PolyShape) Friction() float64
Friction returns shape's coefficient of friction.
func (PolyShape) Group ¶
func (s PolyShape) Group() Group
Group returns a group of the shape. Shapes in the same group don't collide.
func (PolyShape) Layers ¶
func (s PolyShape) Layers() Layers
Layers returns layers bitmask of the shape. Shapes collide only if bitwise of their layers is non-zero.
func (PolyShape) NearestPointQuery ¶
func (s PolyShape) NearestPointQuery(p Vect) (float64, NearestPointQueryInfo)
NearestPointQuery finds the closest point on the surface of shape to a specific point. The first returned value is the distance between the points. A negative distance means the point is inside the shape.
func (PolyShape) PointQuery ¶
PointQuery returns true if a point lies within a shape.
func (PolyShape) SegmentQuery ¶
func (s PolyShape) SegmentQuery(a, b Vect) (bool, SegmentQueryInfo)
SegmentQuery performs a segment query against a shape.
func (PolyShape) Sensor ¶
func (s PolyShape) Sensor() bool
Sensor returns true when shape is "sensor" one, i.e. does not produce collisions.
func (PolyShape) SetBody ¶
func (s PolyShape) SetBody(b Body)
SetBody sets the rigid body this collision shape is attached to.
func (PolyShape) SetCollisionType ¶
func (s PolyShape) SetCollisionType(t CollisionType)
SetCollisionType sets collision type of the shape used when picking collision handlers.
func (PolyShape) SetElasticity ¶
func (s PolyShape) SetElasticity(e float64)
SetElasticity sets coefficient of restitution.
func (PolyShape) SetFriction ¶
func (s PolyShape) SetFriction(f float64)
SetFriction sets coefficient of friction.
func (PolyShape) SetGroup ¶
func (s PolyShape) SetGroup(g Group)
SetGroup sets a group of the shape. Shapes in the same group don't collide.
func (PolyShape) SetLayers ¶
func (s PolyShape) SetLayers(l Layers)
SetLayers sets layers bitmask of the shape. Shapes collide only if bitwise of their layers is non-zero.
func (PolyShape) SetSensor ¶
func (s PolyShape) SetSensor(b bool)
SetSensor sets if the shape is "sensor" one, i.e. does not produce collisions, but still calls collision callbacks.
func (PolyShape) SetSurfaceVelocity ¶
func (s PolyShape) SetSurfaceVelocity(v Vect)
SetSurfaceVelocity sets surface velocity used when solving friction.
func (PolyShape) SetUserData ¶
func (s PolyShape) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Shape reference in a callback.
func (PolyShape) Space ¶
func (s PolyShape) Space() Space
Space returns space the body was added to or nil if the body doesn't belong to any space.
func (PolyShape) SurfaceVelocity ¶
func (s PolyShape) SurfaceVelocity() Vect
SurfaceVelocity returns surface velocity used when solving friction.
func (PolyShape) Update ¶
Update updates, caches and returns the bounding box of a shape with an explicit transformation.
func (PolyShape) UserData ¶
func (s PolyShape) UserData() interface{}
UserData returns user defined data.
func (PolyShape) VertLocal ¶
VertLocal returns a specific vertex of a polygon shape (local coordinates).
func (PolyShape) VertsWorld ¶
VertsWorld returns vertex positions (world coordinates).
func (PolyShape) VertsWorldFloat64 ¶
VertsWorldFloat64 returns vertex positions (world coordinates) as array of float64 values.
type RatchetJoint ¶
type RatchetJoint struct {
// contains filtered or unexported fields
}
RatchetJoint creates rotary ratches similar to a socket wrench.
func RatchetJointNew ¶
func RatchetJointNew(a, b Body, phase, ratchet float64) RatchetJoint
RatchetJointNew creates a new ratchet joint.
func (RatchetJoint) A ¶
func (c RatchetJoint) A() Body
A returns the first body the constraint controls.
func (RatchetJoint) ActivateBodies ¶
func (c RatchetJoint) ActivateBodies()
ActivateBodies calls Activate() on bodies the constraint controls.
func (RatchetJoint) Angle ¶
func (c RatchetJoint) Angle() float64
Angle returns the current ratchet position in radians.
func (RatchetJoint) B ¶
func (c RatchetJoint) B() Body
B returns the second body the constraint controls.
func (RatchetJoint) ErrorBias ¶
func (c RatchetJoint) ErrorBias() float64
ErrorBias returns the rate at which joint error is corrected.
func (RatchetJoint) Impulse ¶
func (c RatchetJoint) Impulse() float64
Impulse returns the last impulse applied by this constraint.
func (RatchetJoint) MaxBias ¶
func (c RatchetJoint) MaxBias() float64
MaxBias returns the maximum rate (speed) that a joint can be corrected at.
func (RatchetJoint) MaxForce ¶
func (c RatchetJoint) MaxForce() float64
MaxForce returns the maximum force this constraint is allowed to use.
func (RatchetJoint) Phase ¶
func (c RatchetJoint) Phase() float64
Phase returns the angular offset of the ratchet positions in radians.
func (RatchetJoint) Ratchet ¶
func (c RatchetJoint) Ratchet() float64
Ratchet returns the angle in radians of each ratchet position.
func (RatchetJoint) SetAngle ¶
func (c RatchetJoint) SetAngle(m float64)
SetAngle sets the ratchet position in radians.
func (RatchetJoint) SetErrorBias ¶
func (c RatchetJoint) SetErrorBias(b float64)
SetErrorBias sets the rate at which joint error is corrected. Defaults to math.Pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
func (RatchetJoint) SetMaxBias ¶
func (c RatchetJoint) SetMaxBias(b float64)
SetMaxBias sets the maximum rate (speed) that a joint can be corrected at (defaults to infinity).
func (RatchetJoint) SetMaxForce ¶
func (c RatchetJoint) SetMaxForce(f float64)
SetMaxForce sets the maximum force this constraint is allowed to use (defalts to infinity). This allows joints to be pulled apart if too much force is applied to them. It also allows you to use constraints as force or friction generators for controlling bodies.
func (RatchetJoint) SetPhase ¶
func (c RatchetJoint) SetPhase(m float64)
SetPhase sets the angular offset of the ratchet positions in radians.
func (RatchetJoint) SetPostSolveFunc ¶
func (c RatchetJoint) SetPostSolveFunc(f func(c Constraint, s Space))
SetPostSolveFunc sets a callback function type that gets called after solving a joint. Use the applied impulse to perform effects like breakable joints.
func (RatchetJoint) SetPreSolveFunc ¶
func (c RatchetJoint) SetPreSolveFunc(f func(c Constraint, s Space))
SetPreSolveFunc sets a callback function type that gets called before solving a joint. Animate your joint anchors, update your motor torque, etc.
func (RatchetJoint) SetRatchet ¶
func (c RatchetJoint) SetRatchet(m float64)
SetRatchet sets the angle in radians of each ratchet position. Negative values cause the ratchet to operate in the opposite direction.
func (RatchetJoint) SetUserData ¶
func (c RatchetJoint) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Constraint reference in a callback.
type RotaryLimitJoint ¶
type RotaryLimitJoint struct {
// contains filtered or unexported fields
}
RotaryLimitJoint constrains the angle between two bodies. This joint is often used in conjuction with a separate PivotJoint in order to limit the rotation around the pivot.
func RotaryLimitJointNew ¶
func RotaryLimitJointNew(a, b Body, min, max float64) RotaryLimitJoint
RotaryLimitJointNew creates a new rotary limit joint.
func (RotaryLimitJoint) A ¶
func (c RotaryLimitJoint) A() Body
A returns the first body the constraint controls.
func (RotaryLimitJoint) ActivateBodies ¶
func (c RotaryLimitJoint) ActivateBodies()
ActivateBodies calls Activate() on bodies the constraint controls.
func (RotaryLimitJoint) B ¶
func (c RotaryLimitJoint) B() Body
B returns the second body the constraint controls.
func (RotaryLimitJoint) ErrorBias ¶
func (c RotaryLimitJoint) ErrorBias() float64
ErrorBias returns the rate at which joint error is corrected.
func (RotaryLimitJoint) Impulse ¶
func (c RotaryLimitJoint) Impulse() float64
Impulse returns the last impulse applied by this constraint.
func (RotaryLimitJoint) Max ¶
func (c RotaryLimitJoint) Max() float64
Max returns the maximum angular delta of the joint in radians.
func (RotaryLimitJoint) MaxBias ¶
func (c RotaryLimitJoint) MaxBias() float64
MaxBias returns the maximum rate (speed) that a joint can be corrected at.
func (RotaryLimitJoint) MaxForce ¶
func (c RotaryLimitJoint) MaxForce() float64
MaxForce returns the maximum force this constraint is allowed to use.
func (RotaryLimitJoint) Min ¶
func (c RotaryLimitJoint) Min() float64
Min returns the minimum angular delta of the joint in radians.
func (RotaryLimitJoint) SetErrorBias ¶
func (c RotaryLimitJoint) SetErrorBias(b float64)
SetErrorBias sets the rate at which joint error is corrected. Defaults to math.Pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
func (RotaryLimitJoint) SetMax ¶
func (c RotaryLimitJoint) SetMax(m float64)
SetMax sets the maximum angular delta of the joint in radians.
func (RotaryLimitJoint) SetMaxBias ¶
func (c RotaryLimitJoint) SetMaxBias(b float64)
SetMaxBias sets the maximum rate (speed) that a joint can be corrected at (defaults to infinity).
func (RotaryLimitJoint) SetMaxForce ¶
func (c RotaryLimitJoint) SetMaxForce(f float64)
SetMaxForce sets the maximum force this constraint is allowed to use (defalts to infinity). This allows joints to be pulled apart if too much force is applied to them. It also allows you to use constraints as force or friction generators for controlling bodies.
func (RotaryLimitJoint) SetMin ¶
func (c RotaryLimitJoint) SetMin(m float64)
SetMin sets the minimum angular delta of the joint in radians.
func (RotaryLimitJoint) SetPostSolveFunc ¶
func (c RotaryLimitJoint) SetPostSolveFunc(f func(c Constraint, s Space))
SetPostSolveFunc sets a callback function type that gets called after solving a joint. Use the applied impulse to perform effects like breakable joints.
func (RotaryLimitJoint) SetPreSolveFunc ¶
func (c RotaryLimitJoint) SetPreSolveFunc(f func(c Constraint, s Space))
SetPreSolveFunc sets a callback function type that gets called before solving a joint. Animate your joint anchors, update your motor torque, etc.
func (RotaryLimitJoint) SetUserData ¶
func (c RotaryLimitJoint) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Constraint reference in a callback.
type SegmentQuery ¶
SegmentQuery is a query callback function type.
type SegmentQueryInfo ¶
type SegmentQueryInfo struct { // Shape is the one that was hit. nil if no collision occured. Shape // Normalized distance along the query segment in the range [0;1]. T float64 // Normal of the surface hit. N Vect }
SegmentQueryInfo holds the result of SegmentQuery.
func (SegmentQueryInfo) HitDistance ¶
func (s SegmentQueryInfo) HitDistance(start, end Vect) float64
HitDistance returns the hit distance for a segment query.
func (SegmentQueryInfo) HitPoint ¶
func (s SegmentQueryInfo) HitPoint(start, end Vect) Vect
HitPoint returns the hit point for a segment query.
type SegmentShape ¶
type SegmentShape struct {
// contains filtered or unexported fields
}
SegmentShape is a a beveled (rounded) segment shape.
func SegmentShapeNew ¶
func SegmentShapeNew(body Body, a, b Vect, radius float64) SegmentShape
SegmentShapeNew creates a new segment shape.
func (SegmentShape) BB ¶
func (s SegmentShape) BB() BB
BB returns current bounding box of the shape.
func (SegmentShape) Body ¶
func (s SegmentShape) Body() Body
Body returns the rigid body this collision shape is attached to.
func (SegmentShape) CacheBB ¶
func (s SegmentShape) CacheBB() BB
CacheBB updates, caches and returns the bounding box of a shape based on the body it's attached to.
func (SegmentShape) CollisionType ¶
func (s SegmentShape) CollisionType() CollisionType
CollisionType returns collision type of the shape used when picking collision handlers.
func (SegmentShape) Elasticity ¶
func (s SegmentShape) Elasticity() float64
Elasticity returns shape's coefficient of restitution.
func (SegmentShape) Friction ¶
func (s SegmentShape) Friction() float64
Friction returns shape's coefficient of friction.
func (SegmentShape) Group ¶
func (s SegmentShape) Group() Group
Group returns a group of the shape. Shapes in the same group don't collide.
func (SegmentShape) Layers ¶
func (s SegmentShape) Layers() Layers
Layers returns layers bitmask of the shape. Shapes collide only if bitwise of their layers is non-zero.
func (SegmentShape) NearestPointQuery ¶
func (s SegmentShape) NearestPointQuery(p Vect) (float64, NearestPointQueryInfo)
NearestPointQuery finds the closest point on the surface of shape to a specific point. The first returned value is the distance between the points. A negative distance means the point is inside the shape.
func (SegmentShape) Normal ¶
func (s SegmentShape) Normal() Vect
Normal returns the normal of the segment shape.
func (SegmentShape) PointQuery ¶
PointQuery returns true if a point lies within a shape.
func (SegmentShape) Radius ¶
func (s SegmentShape) Radius() float64
Radius returns the beveling radius of the segment shape.
func (SegmentShape) SegmentQuery ¶
func (s SegmentShape) SegmentQuery(a, b Vect) (bool, SegmentQueryInfo)
SegmentQuery performs a segment query against a shape.
func (SegmentShape) Sensor ¶
func (s SegmentShape) Sensor() bool
Sensor returns true when shape is "sensor" one, i.e. does not produce collisions.
func (SegmentShape) SetBody ¶
func (s SegmentShape) SetBody(b Body)
SetBody sets the rigid body this collision shape is attached to.
func (SegmentShape) SetCollisionType ¶
func (s SegmentShape) SetCollisionType(t CollisionType)
SetCollisionType sets collision type of the shape used when picking collision handlers.
func (SegmentShape) SetElasticity ¶
func (s SegmentShape) SetElasticity(e float64)
SetElasticity sets coefficient of restitution.
func (SegmentShape) SetEndpoints ¶
func (s SegmentShape) SetEndpoints(a, b Vect)
SetEndpoints sets the endpoints of a segment shape. NOTE: this is unsafe function.
func (SegmentShape) SetFriction ¶
func (s SegmentShape) SetFriction(f float64)
SetFriction sets coefficient of friction.
func (SegmentShape) SetGroup ¶
func (s SegmentShape) SetGroup(g Group)
SetGroup sets a group of the shape. Shapes in the same group don't collide.
func (SegmentShape) SetLayers ¶
func (s SegmentShape) SetLayers(l Layers)
SetLayers sets layers bitmask of the shape. Shapes collide only if bitwise of their layers is non-zero.
func (SegmentShape) SetNeighbors ¶
func (s SegmentShape) SetNeighbors(prev, next Vect)
SetNeighbors FIXME TODO OMG WTF
func (SegmentShape) SetRadius ¶
func (s SegmentShape) SetRadius(radius float64)
SetRadius sets the radius of a segment shape. NOTE: this is unsafe function.
func (SegmentShape) SetSensor ¶
func (s SegmentShape) SetSensor(b bool)
SetSensor sets if the shape is "sensor" one, i.e. does not produce collisions, but still calls collision callbacks.
func (SegmentShape) SetSurfaceVelocity ¶
func (s SegmentShape) SetSurfaceVelocity(v Vect)
SetSurfaceVelocity sets surface velocity used when solving friction.
func (SegmentShape) SetUserData ¶
func (s SegmentShape) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Shape reference in a callback.
func (SegmentShape) Space ¶
func (s SegmentShape) Space() Space
Space returns space the body was added to or nil if the body doesn't belong to any space.
func (SegmentShape) String ¶
func (s SegmentShape) String() string
String converts a segment shape to a human-readable string.
func (SegmentShape) SurfaceVelocity ¶
func (s SegmentShape) SurfaceVelocity() Vect
SurfaceVelocity returns surface velocity used when solving friction.
type Shape ¶
type Shape interface { BB() BB Body() Body CacheBB() BB CollisionType() CollisionType Elasticity() float64 Free() Friction() float64 Group() Group Layers() Layers NearestPointQuery(Vect) (float64, NearestPointQueryInfo) PointQuery(Vect) bool SegmentQuery(Vect, Vect) (bool, SegmentQueryInfo) Sensor() bool SetBody(Body) SetCollisionType(CollisionType) SetElasticity(float64) SetFriction(float64) SetGroup(Group) SetLayers(Layers) SetSensor(bool) SetSurfaceVelocity(Vect) String() string SurfaceVelocity() Vect Update(Vect, Vect) BB // contains filtered or unexported methods }
Shape is an opaque collision shape struct.
func BoxShapeNew ¶
BoxShapeNew creates a new box shape.
type SimpleMotor ¶
type SimpleMotor struct {
// contains filtered or unexported fields
}
SimpleMotor makes two objects spin relative to each other. They are most often used with the MaxForce property set to a finite value.
func SimpleMotorNew ¶
func SimpleMotorNew(a, b Body, rate float64) SimpleMotor
SimpleMotorNew creates a new simple motor.
func (SimpleMotor) A ¶
func (c SimpleMotor) A() Body
A returns the first body the constraint controls.
func (SimpleMotor) ActivateBodies ¶
func (c SimpleMotor) ActivateBodies()
ActivateBodies calls Activate() on bodies the constraint controls.
func (SimpleMotor) B ¶
func (c SimpleMotor) B() Body
B returns the second body the constraint controls.
func (SimpleMotor) ErrorBias ¶
func (c SimpleMotor) ErrorBias() float64
ErrorBias returns the rate at which joint error is corrected.
func (SimpleMotor) Impulse ¶
func (c SimpleMotor) Impulse() float64
Impulse returns the last impulse applied by this constraint.
func (SimpleMotor) MaxBias ¶
func (c SimpleMotor) MaxBias() float64
MaxBias returns the maximum rate (speed) that a joint can be corrected at.
func (SimpleMotor) MaxForce ¶
func (c SimpleMotor) MaxForce() float64
MaxForce returns the maximum force this constraint is allowed to use.
func (SimpleMotor) Rate ¶
func (c SimpleMotor) Rate() float64
Rate returns the relative rotation speed of the two bodies in radians per second.
func (SimpleMotor) SetErrorBias ¶
func (c SimpleMotor) SetErrorBias(b float64)
SetErrorBias sets the rate at which joint error is corrected. Defaults to math.Pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
func (SimpleMotor) SetMaxBias ¶
func (c SimpleMotor) SetMaxBias(b float64)
SetMaxBias sets the maximum rate (speed) that a joint can be corrected at (defaults to infinity).
func (SimpleMotor) SetMaxForce ¶
func (c SimpleMotor) SetMaxForce(f float64)
SetMaxForce sets the maximum force this constraint is allowed to use (defalts to infinity). This allows joints to be pulled apart if too much force is applied to them. It also allows you to use constraints as force or friction generators for controlling bodies.
func (SimpleMotor) SetPostSolveFunc ¶
func (c SimpleMotor) SetPostSolveFunc(f func(c Constraint, s Space))
SetPostSolveFunc sets a callback function type that gets called after solving a joint. Use the applied impulse to perform effects like breakable joints.
func (SimpleMotor) SetPreSolveFunc ¶
func (c SimpleMotor) SetPreSolveFunc(f func(c Constraint, s Space))
SetPreSolveFunc sets a callback function type that gets called before solving a joint. Animate your joint anchors, update your motor torque, etc.
func (SimpleMotor) SetRate ¶
func (c SimpleMotor) SetRate(m float64)
SetRate sets the relative rotation speed of the two bodies in radians per second.
func (SimpleMotor) SetUserData ¶
func (c SimpleMotor) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Constraint reference in a callback.
type SlideJoint ¶
type SlideJoint struct {
// contains filtered or unexported fields
}
SlideJoint holds the distance between points on two bodies between a minimum and a maximum. Think of them as a telescoping PinJoint.
func SlideJointNew ¶
func SlideJointNew(a, b Body, anchr1, anchr2 Vect, min, max float64) SlideJoint
SlideJointNew creates a new slide joint.
func (SlideJoint) A ¶
func (c SlideJoint) A() Body
A returns the first body the constraint controls.
func (SlideJoint) ActivateBodies ¶
func (c SlideJoint) ActivateBodies()
ActivateBodies calls Activate() on bodies the constraint controls.
func (SlideJoint) Anchr1 ¶
func (c SlideJoint) Anchr1() Vect
Anchr1 returns the anchor point on the first body.
func (SlideJoint) Anchr2 ¶
func (c SlideJoint) Anchr2() Vect
Anchr2 returns the anchor point on the second body.
func (SlideJoint) B ¶
func (c SlideJoint) B() Body
B returns the second body the constraint controls.
func (SlideJoint) ErrorBias ¶
func (c SlideJoint) ErrorBias() float64
ErrorBias returns the rate at which joint error is corrected.
func (SlideJoint) Impulse ¶
func (c SlideJoint) Impulse() float64
Impulse returns the last impulse applied by this constraint.
func (SlideJoint) Max ¶
func (c SlideJoint) Max() float64
Max returns the maximum allowed distance between anchor points.
func (SlideJoint) MaxBias ¶
func (c SlideJoint) MaxBias() float64
MaxBias returns the maximum rate (speed) that a joint can be corrected at.
func (SlideJoint) MaxForce ¶
func (c SlideJoint) MaxForce() float64
MaxForce returns the maximum force this constraint is allowed to use.
func (SlideJoint) Min ¶
func (c SlideJoint) Min() float64
Min returns the minimum allowed distance between anchor points.
func (SlideJoint) SetAnchr1 ¶
func (c SlideJoint) SetAnchr1(v Vect)
SetAnchr1 sets the anchor point on the first body.
func (SlideJoint) SetAnchr2 ¶
func (c SlideJoint) SetAnchr2(v Vect)
SetAnchr2 sets the anchor point on the second body.
func (SlideJoint) SetErrorBias ¶
func (c SlideJoint) SetErrorBias(b float64)
SetErrorBias sets the rate at which joint error is corrected. Defaults to math.Pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
func (SlideJoint) SetMax ¶
func (c SlideJoint) SetMax(m float64)
SetMax sets the maximum allowed distance between anchor points.
func (SlideJoint) SetMaxBias ¶
func (c SlideJoint) SetMaxBias(b float64)
SetMaxBias sets the maximum rate (speed) that a joint can be corrected at (defaults to infinity).
func (SlideJoint) SetMaxForce ¶
func (c SlideJoint) SetMaxForce(f float64)
SetMaxForce sets the maximum force this constraint is allowed to use (defalts to infinity). This allows joints to be pulled apart if too much force is applied to them. It also allows you to use constraints as force or friction generators for controlling bodies.
func (SlideJoint) SetMin ¶
func (c SlideJoint) SetMin(m float64)
SetMin sets the minimum allowed distance between anchor points.
func (SlideJoint) SetPostSolveFunc ¶
func (c SlideJoint) SetPostSolveFunc(f func(c Constraint, s Space))
SetPostSolveFunc sets a callback function type that gets called after solving a joint. Use the applied impulse to perform effects like breakable joints.
func (SlideJoint) SetPreSolveFunc ¶
func (c SlideJoint) SetPreSolveFunc(f func(c Constraint, s Space))
SetPreSolveFunc sets a callback function type that gets called before solving a joint. Animate your joint anchors, update your motor torque, etc.
func (SlideJoint) SetUserData ¶
func (c SlideJoint) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your the game object so you can access it when given a Constraint reference in a callback.
type Space ¶
type Space uintptr
Space is a basic unit of simulation in Chipmunk.
func (Space) ActivateShapesTouchingShape ¶
ActivateShapesTouchingShape activates body (calls Activate()) of any shape that overlaps the given shape.
func (Space) AddCollisionHandler ¶
func (s Space) AddCollisionHandler(a, b CollisionType, beginFunc, preSolveFunc func(Space, Arbiter, interface{}) bool, postStepFunc, separateFunc func(Space, Arbiter, interface{}), data interface{})
AddCollisionHandler sets a collision handler to be used whenever the two shapes with the given collision types collide
func (Space) AddConstraint ¶
func (s Space) AddConstraint(c Constraint) Constraint
AddConstraint adds a constraint to the simulation.
func (Space) AddPostStepCallback ¶
AddPostStepCallback schedules a post-step callback to be called when Space.Step() finishes. You can only register one callback per unique value for key. Returns true only if the key has never been scheduled before.
func (Space) AddShape ¶
AddShape adds a collision shape to the simulation. If the shape is attached to a static body, it will be added as a static shape.
func (Space) AddStaticShape ¶
AddStaticShape explicity adds a shape as a static shape to the simulation.
func (Space) BBQuery ¶
BBQuery performs a fast rectangle query on the space calling a callback function for each shape found. Only the shape's bounding boxes are checked for overlap, not their full shape.
func (Space) CollisionBias ¶
CollisionBias returns the speed of how fast overlapping shapes are pushed apart.
func (Space) CollisionPersistence ¶
CollisionPersistence returns the number of frames that contact information should persist.
func (Space) CollisionSlop ¶
CollisionSlop returns amount of encouraged penetration between colliding shapes.
func (Space) Contains ¶
func (s Space) Contains(obj SpaceObject) bool
Contains tests if a collision shape, rigid body or a constraint has been added to the space.
func (Space) ConvertBodyToDynamic ¶
ConvertBodyToDynamic converts a body to a dynamic rogue body. This will convert any static shapes attached to the body into regular ones. If you want the body to be active after the transition, you must add it to the space also.
func (Space) ConvertBodyToStatic ¶
ConvertBodyToStatic converts a dynamic rogue body to a static one. This will convert any shapes attached to the body into static shapes, but does not handle constra ints. If the body is active, you must remove it from the space first.
func (Space) CurrentTimeStep ¶
CurrentTimeStep returns the current (if you are in a callback from SpaceStep()) or most recent (outside of a SpaceStep() call) timestep.
func (Space) Damping ¶
Damping returns the damping rate expressed as the fraction of velocity bodies retain each second.
func (Space) Each ¶
func (s Space) Each(iter interface{})
Each calls a callback function on each object of specific type (according to iterator) in the space.
func (Space) EachConstraint ¶
func (s Space) EachConstraint(iter func(Constraint))
EachConstraint calls a callback function on each constraint in the space.
func (Space) EnableContactGraph ¶
EnableContactGraph returns true if rebuild of the contact graph during each step is enabled.
func (Space) FreeChildren ¶
func (s Space) FreeChildren()
FreeChildren frees all bodies, constraints and shapes in the space.
func (Space) Gravity ¶
Gravity returns current gravity used when integrating velocity for rigid bodies.
func (Space) IdleSpeedThreshold ¶
IdleSpeedThreshold returns speed threshold for a body to be considered idle.
func (Space) Iterations ¶
Iterations returns the number of iterations to use in the impulse solver (to solve contacts).
func (Space) NearestPointQuery ¶
func (s Space) NearestPointQuery(point Vect, maxDistance float64, layers Layers, group Group, f NearestPointQuery)
NearestPointQuery queries the space at a point and calls a callback function for each shape found.
func (Space) PointQuery ¶
func (s Space) PointQuery(point Vect, layers Layers, group Group, f PointQuery)
PointQuery queries the space at a point and calls a callback function for each shape found.
func (Space) PointQueryFirst ¶
PointQueryFirst queries the space at a point and returns the first shape found. Returns nil if no shapes were found.
func (Space) ReindexShape ¶
ReindexShape updates the collision detection data for a specific shape in the space.
func (Space) ReindexShapesForBody ¶
ReindexShapesForBody updates the collision detection data for all shapes attached to a body.
func (Space) ReindexStatic ¶
func (s Space) ReindexStatic()
ReindexStatic updates the collision detection info for the static shape in the space.
func (Space) RemoveBody ¶
RemoveBody removes a rigid body from the simulation.
func (Space) RemoveCollisionHandler ¶
func (s Space) RemoveCollisionHandler(a CollisionType, b CollisionType)
RemoveCollisionHandler unsets a collision handler.
func (Space) RemoveConstraint ¶
func (s Space) RemoveConstraint(c Constraint)
RemoveConstraint removes a constraint from the simulation.
func (Space) RemoveShape ¶
RemoveShape removes a collision shape from the simulation.
func (Space) RemoveStaticShape ¶
RemoveStaticShape removes a collision shape added using AddStaticShape() from the simulation.
func (Space) SegmentQuery ¶
func (s Space) SegmentQuery(start, end Vect, layers Layers, group Group, f SegmentQuery)
SegmentQuery performs a directed line segment query (like a raycast) against the space calling a callback function for each shape intersected.
func (Space) SetCollisionBias ¶
SetCollisionBias sets the speed of how fast overlapping shapes are pushed apart. Expressed as a fraction of the error remaining after each second. Defaults to pow(1.0 - 0.1, 60.0) meaning that Chipmunk fixes 10% of overlap each frame at 60Hz.
func (Space) SetCollisionPersistence ¶
SetCollisionPersistence sets the number of frames that contact information should persist. Defaults to 3. There is probably never a reason to change this value.
func (Space) SetCollisionSlop ¶
SetCollisionSlop sets amount of encouraged penetration between colliding shapes. Used to reduce oscillating contacts and keep the collision cache warm. Defaults to 0.1. If you have poor simulation quality, increase this number as much as possible without allowing visible amounts of overlap.
func (Space) SetDamping ¶
SetDamping sets the damping rate expressed as the fraction of velocity bodies retain each second. A value of 0.9 would mean that each body's velocity will drop 10% per second. The default value is 1.0, meaning no damping is applied. Note this damping value is different than those of DampedSpring and DampedRotarySpring.
func (Space) SetDefaultCollisionHandler ¶
func (s Space) SetDefaultCollisionHandler(beginFunc, preSolveFunc func(Space, Arbiter, interface{}) bool, postStepFunc, separateFunc func(Space, Arbiter, interface{}), data interface{})
SetDefaultCollisionHandler sets a default collision handler for this space. The default collision handler is invoked for each colliding pair of shapes that isn't explicitly handled by a specific collision handler. You can pass NULL for any function you don't want to implement.
func (Space) SetEnableContactGraph ¶
SetEnableContactGraph enables a rebuild of the contact graph during each step. Must be enabled to use the EachArbiter() method of Body. Disabled by default for a small performance boost. Enabled implicitly when the sleeping feature is enabled.
func (Space) SetGravity ¶
SetGravity sets the gravity to pass to rigid bodies when integrating velocity.
func (Space) SetIdleSpeedThreshold ¶
SetIdleSpeedThreshold sets the speed threshold for a body to be considered idle. The default value of 0.0 means to let the space guess a good threshold based on gravity.
func (Space) SetIterations ¶
SetIterations sets the number of iterations to use in the impulse solver to solve contacts.
func (Space) SetSleepTimeThreshold ¶
SetSleepTimeThreshold sets the time a group of bodies must remain idle in order to fall asleep. Enabling sleeping also implicitly enables the the contact graph. The default value of math.Inf(1) disables the sleeping algorithm.
func (Space) SetUserData ¶
func (s Space) SetUserData(data interface{})
SetUserData sets user definable data pointer. Generally this points to your game's controller or game state so you can access it when given a Space reference in a callback.
func (Space) SleepTimeThreshold ¶
SleepTimeThreshold returns the time a groups of bodies must remain idle in order to "fall asleep".
func (Space) StaticBody ¶
StaticBody returns a dedicated static body for the space. You don't have to use it, but because it's memory is managed automatically with the space it's very convenient. You can set its user data pointer to something helpful if you want for callbacks.
func (Space) UseSpatialHash ¶
UseSpatialHash switches the space to use a spatial has as it's spatial index.
type SpaceObject ¶
type SpaceObject interface { Free() // contains filtered or unexported methods }
SpaceObject is an interface every space object must implement.
type Vect ¶
type Vect struct {
X, Y float64
}
Vect is a 2D vector type.
func CentroidForPoly ¶
CentroidForPoly returns the natural centroid of a polygon.
func ConvexHull ¶
ConvexHull calculates the convex hull of a given set of points. Returns the points and index of the first vertex in the hull came from the input. Tolerance is the allowed amount to shrink the hull when simplifying it. A tolerance of 0.0 creates an exact hull.
func VectForAngle ¶
VectForAngle returns the unit length vector for the given angle (radians).
func (Vect) LerpConst ¶
LerpConst does a spherical linear interpolation between two vectors by no more than specific angle (radians).