engine: azul3d.org/engine/native/cp Index | Files

package cp

import "azul3d.org/engine/native/cp"

Package cp is a wrapper for the Chipmunk 2D Physics Engine.

More information about Chipmunk can be found at:

http://chipmunk-physics.net/

This package uses the Chipmunk library, and as such it is also bound by it's license which can be found at:

https://github.com/slembcke/Chipmunk2D/blob/master/LICENSE.txt

Index

Package Files

arbiter.go bb.go body.go chipmunk.go constraint.go dampedrotaryspring.go dampedspring.go gearjoint.go groovejoint.go pinjoint.go pivotjoint.go polyshape.go ratchetjoint.go rotarylimitjoint.go shape.go simplemotor.go slicejoint.go space.go spatialindex.go transform.go types_amd64.go typescompat.go unsafe.go vect.go

Constants

const (
    // Value for cpShape.group signifying that a shape is in no group.
    NO_GROUP = C.CP_NO_GROUP

    // Value for cpShape.layers signifying that a shape is in every layer.
    ALL_CATEGORIES = C.CP_ALL_CATEGORIES

    // cpCollisionType value internally reserved for hashing wildcard handlers.
    WILDCARD_COLLISION_TYPE = C.CP_WILDCARD_COLLISION_TYPE
)
const (
    MAX_CONTACTS_PER_ARBITER = C.CP_MAX_CONTACTS_PER_ARBITER
)

Variables

var (
    SHAPE_FILTER_ALL  = ShapeFilter{NO_GROUP, ALL_CATEGORIES, ALL_CATEGORIES}
    SHAPE_FILTER_NONE = ShapeFilter{NO_GROUP, 0 &^ ALL_CATEGORIES, 0 &^ ALL_CATEGORIES}
)
var (
    TransformIdentity = Transform{1, 0, 0, 1, 0, 0}
)

Identity transform matrix.

var (
    // Version string.
    VersionString = C.GoString(C.cpVersionString)
)
var (
    // The zero vector.
    Vzero = Vect{0, 0}
)

func AreaForCircle Uses

func AreaForCircle(r1, r2 float64) float64

Calculate area of a hollow circle.

r1 and r2 are the inner and outer diameters. A solid circle has an inner diameter of 0.

func AreaForPoly Uses

func AreaForPoly(verts []Vect, radius float64) float64

Calculate 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 Uses

func AreaForSegment(a, b Vect, radius float64) float64

Calculate the area of a fattened (capsule shaped) line segment.

func BodyUpdatePosition Uses

func BodyUpdatePosition(b *Body, dt float64)

Default position integration function.

func BodyUpdateVelocity Uses

func BodyUpdateVelocity(b *Body, gravity Vect, damping, dt float64)

Default velocity integration function..

func ConvexHull Uses

func ConvexHull(count int, verts, result *Vect, first *int, tol float64) int

Calculate the convex hull of a given set of points. Returns the count of points in the hull.

result must be a pointer to a  cpVect array with at least  count elements.
If  verts ==  result, then  verts will be reduced inplace.

first is an optional pointer to an integer to store where the first vertex
in the hull came from (i.e. verts[first] == result[0])

tol is the allowed amount to shrink the hull when simplifying it. A
tolerance of 0.0 creates an exact hull.

func Fabs Uses

func Fabs(f float64) float64

Return the absolute value of a cpFloat.

func Fclamp Uses

func Fclamp(f, min, max float64) float64

Clamp f to be between min and max.

func Fclamp01 Uses

func Fclamp01(f float64) float64

Clamp f to be between 0 and 1.

func Flerp Uses

func Flerp(f1, f2, t float64) float64

Linearly interpolate (or extrapolate) between f1 and f2 by t percent.

func Flerpconst Uses

func Flerpconst(f1, f2, d float64) float64

Linearly interpolate from f1 to f2 by no more than d.

func Fmax Uses

func Fmax(a, b float64) float64

Return the max of two cpFloats.

func Fmin Uses

func Fmin(a, b float64) float64

Return the min of two cpFloats.

func MomentForBox Uses

func MomentForBox(m, width, height float64) float64

Calculate the moment of inertia for a solid box.

func MomentForBox2 Uses

func MomentForBox2(m float64, box BB) float64

Calculate the moment of inertia for a solid box.

func MomentForCircle Uses

func MomentForCircle(m, r1, r2 float64, offset Vect) float64

Calculate the moment of inertia for a circle.

r1 and r2 are the inner and outer diameters. A solid circle has an inner diameter of 0.

func MomentForPoly Uses

func MomentForPoly(m float64, verts []Vect, offset Vect, radius float64) float64

Calculate 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 Uses

func MomentForSegment(m float64, a, b Vect, radius float64) float64

Calculate the moment of inertia for a line segment.

Beveling radius is not supported.

func Vcross Uses

func Vcross(v1, v2 Vect) float64

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 Vdist Uses

func Vdist(v1, v2 Vect) float64

Returns the distance between v1 and v2.

func Vdistsq Uses

func Vdistsq(v1, v2 Vect) float64

Returns the squared distance between v1 and v2. Faster than cpvdist() when you only need to compare distances.

func Veql Uses

func Veql(v1, v2 Vect) bool

Check if two vectors are equal. (Be careful when comparing floating point numbers!)

func Vlength Uses

func Vlength(v Vect) float64

Returns the length of v.

func Vlengthsq Uses

func Vlengthsq(v Vect) float64

Returns the squared length of v. Faster than cpvlength() when you only need to compare lengths.

func Vnear Uses

func Vnear(v1, v2 Vect, dist float64) bool

Returns true if the distance between v1 and v2 is less than dist.

func Vtoangle Uses

func Vtoangle(v Vect) float64

Returns the angular direction v is pointing in (in radians).

type Arbiter Uses

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

The Arbiter struct controls pairs of colliding shapes.

They are also used in conjuction with collision handler callbacks allowing you to retrieve information on the collision and control it.

func (*Arbiter) CallWildcardBeginA Uses

func (a *Arbiter) CallWildcardBeginA(space *Space) bool

func (*Arbiter) CallWildcardBeginB Uses

func (a *Arbiter) CallWildcardBeginB(space *Space) bool

func (*Arbiter) CallWildcardPostSolveA Uses

func (a *Arbiter) CallWildcardPostSolveA(space *Space)

func (*Arbiter) CallWildcardPostSolveB Uses

func (a *Arbiter) CallWildcardPostSolveB(space *Space)

func (*Arbiter) CallWildcardPreSolveA Uses

func (a *Arbiter) CallWildcardPreSolveA(space *Space) bool

func (*Arbiter) CallWildcardPreSolveB Uses

func (a *Arbiter) CallWildcardPreSolveB(space *Space) bool

func (*Arbiter) CallWildcardSeparateA Uses

func (a *Arbiter) CallWildcardSeparateA(space *Space)

func (*Arbiter) CallWildcardSeparateB Uses

func (a *Arbiter) CallWildcardSeparateB(space *Space)

func (*Arbiter) ContactPointSet Uses

func (a *Arbiter) ContactPointSet() *ContactPointSet

Return a contact set from an arbiter.

func (*Arbiter) Count Uses

func (a *Arbiter) Count() int

Get the number of contact points for this arbiter.

func (*Arbiter) Depth Uses

func (a *Arbiter) Depth(i int) float64

Get the depth of the ith contact point.

func (*Arbiter) Friction Uses

func (a *Arbiter) Friction() float64

func (*Arbiter) GetNormal Uses

func (a *Arbiter) GetNormal() Vect

Get the normal of the collision.

func (*Arbiter) Ignore Uses

func (a *Arbiter) Ignore() bool

func (*Arbiter) IsFirstContact Uses

func (a *Arbiter) IsFirstContact() bool

Returns true if this is the first step a pair of objects started colliding.

func (*Arbiter) IsRemoval Uses

func (a *Arbiter) IsRemoval() bool

Returns true if in separate callback due to a shape being removed from the space.

func (*Arbiter) Point1 Uses

func (a *Arbiter) Point1(i int) Vect

Get the position of the ith contact point on the surface of the first shape.

func (*Arbiter) Point2 Uses

func (a *Arbiter) Point2(i int) Vect

Get the position of the ith contact point on the surface of the second shape.

func (*Arbiter) Restitution Uses

func (a *Arbiter) Restitution() float64

func (*Arbiter) SetContactPointSet Uses

func (a *Arbiter) SetContactPointSet(set *ContactPointSet)

Replace the contact point set for an arbiter.

This can be a very powerful feature, but use it with caution!

func (*Arbiter) SetFriction Uses

func (a *Arbiter) SetFriction(friction float64)

func (*Arbiter) SetRestitution Uses

func (a *Arbiter) SetRestitution(restitution float64)

func (*Arbiter) SetSurfaceVelocity Uses

func (a *Arbiter) SetSurfaceVelocity(vr Vect)

Override the relative surface velocity of the two shapes in contact.

By default this is calculated to be the difference of the two surface velocities clamped to the tangent plane.

func (*Arbiter) SetUserData Uses

func (a *Arbiter) SetUserData(i interface{})

func (*Arbiter) Shapes Uses

func (arb *Arbiter) Shapes() (a, b *Shape)

Return the colliding shapes involved for this arbiter.

The order of their cpSpace.collision_type values will match the order set when the collision handler was registered.

func (*Arbiter) SurfaceVelocity Uses

func (a *Arbiter) SurfaceVelocity() Vect

Get the relative surface velocity of the two shapes in contact.

func (*Arbiter) TotalImpulse Uses

func (a *Arbiter) TotalImpulse() Vect

Calculate 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 cpBodyEachArbiter callback.

func (*Arbiter) TotalKE Uses

func (a *Arbiter) TotalKE() float64

Calculate the amount of energy lost in a collision including static, but not dynamic friction. This function should only be called from a post-solve, post-step or cpBodyEachArbiter callback.

func (*Arbiter) UserData Uses

func (a *Arbiter) UserData() interface{}

type Array Uses

type Array C.cpArray

type BB Uses

type BB struct {
    L   float64
    B   float64
    R   float64
    T   float64
}

Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top)

func BBNew Uses

func BBNew(l, b, r, t float64) BB

Convenience constructor for BB structs.

func BBNewForCircle Uses

func BBNewForCircle(p Vect, r float64) BB

Constructs a BB for a circle with the given position and radius.

func BBNewForExtents Uses

func BBNewForExtents(c Vect, hw, hh float64) BB

Constructs a BB centered on a point with the given extents (half sizes).

func (BB) Area Uses

func (bb BB) Area() float64

Returns the area of the bounding box.

func (BB) Center Uses

func (bb BB) Center() Vect

Returns the center of a bounding box.

func (BB) ClampVect Uses

func (bb BB) ClampVect(v Vect) Vect

Clamp a vector to a bounding box.

func (BB) ContainsBB Uses

func (bb BB) ContainsBB(other BB) bool

Returns true if other lies completely within bb.

func (BB) ContainsVect Uses

func (bb BB) ContainsVect(v Vect) bool

Returns true if bb contains v.

func (BB) Expand Uses

func (bb BB) Expand(v Vect) BB

Returns a bounding box that holds both bb and v.

func (BB) Intersects Uses

func (a BB) Intersects(b BB) bool

Returns true if a and b intersect.

func (BB) IntersectsSegment Uses

func (bb BB) IntersectsSegment(a, b Vect) bool

Return true if the bounding box intersects the line segment with ends a and b.

func (BB) Merge Uses

func (a BB) Merge(b BB) BB

Returns a bounding box that holds both bounding boxes.

func (BB) MergedArea Uses

func (a BB) MergedArea(b BB) float64

Merges a and b and returns the area of the merged bounding box.

func (BB) SegmentQuery Uses

func (bb BB) SegmentQuery(a, b Vect) float64

Returns the fraction along the segment query the BB is hit. Returns INFINITY if it doesn't hit.

func (BB) WrapVect Uses

func (bb BB) WrapVect(v Vect) Vect

Wrap a vector to a bounding box.

type Bitmask Uses

type Bitmask uint32

type Body Uses

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

func BodyNew Uses

func BodyNew(mass, moment float64) *Body

Allocate and initialize a Body.

func BodyNewKinematic Uses

func BodyNewKinematic() *Body

Allocate and initialize a Body, and set it as a kinematic body.

func BodyNewStatic Uses

func BodyNewStatic() *Body

Allocate and initialize a cpBody, and set it as a static body.

func (*Body) Activate Uses

func (b *Body) Activate()

Wake up a sleeping or idle body.

func (*Body) ActivateStatic Uses

func (b *Body) ActivateStatic(filter *Shape)

Wake up any sleeping or idle bodies touching a static body.

func (*Body) Angle Uses

func (b *Body) Angle() float64

Get the angle of the body.

func (*Body) AngularVelocity Uses

func (b *Body) AngularVelocity() float64

Get the angular velocity of the body.

func (*Body) ApplyForceAtLocalPoint Uses

func (b *Body) ApplyForceAtLocalPoint(force, point Vect)

Apply a force to a body. Both the force and point are expressed in body local coordinates.

func (*Body) ApplyForceAtWorldPoint Uses

func (b *Body) ApplyForceAtWorldPoint(force, point Vect)

Apply a force to a body. Both the force and point are expressed in world coordinates.

func (*Body) ApplyImpulseAtLocalPoint Uses

func (b *Body) ApplyImpulseAtLocalPoint(impulse, point Vect)

Apply an impulse to a body. Both the impulse and point are expressed in body local coordinates.

func (*Body) ApplyImpulseAtWorldPoint Uses

func (b *Body) ApplyImpulseAtWorldPoint(impulse, point Vect)

Apply an impulse to a body. Both the impulse and point are expressed in world coordinates.

func (*Body) BoxShapeNew Uses

func (b *Body) BoxShapeNew(width, height, radius float64) *Shape

Allocate and initialize a box shaped polygon shape.

func (*Body) BoxShapeNew2 Uses

func (b *Body) BoxShapeNew2(box BB, radius float64) *Shape

Allocate and initialize an offset box shaped polygon shape.

func (*Body) CenterOfGravity Uses

func (b *Body) CenterOfGravity() Vect

Get the offset of the center of gravity in body local coordinates.

func (*Body) CircleShapeNew Uses

func (b *Body) CircleShapeNew(radius float64, offset Vect) *Shape

Allocate and initialize a circle shape.

func (*Body) EachArbiter Uses

func (b *Body) EachArbiter(f func(b *Body, a *Arbiter))

Returns a slice of all arbiters that are currently active on the body.

func (*Body) EachConstraint Uses

func (b *Body) EachConstraint(f func(b *Body, c *Constraint))

Returns a slice of all contraints attached to the body and added to the space.

func (*Body) EachShape Uses

func (b *Body) EachShape(f func(b *Body, s *Shape))

Returns a slice of all shapes attached to the body and added to the space.

func (*Body) Force Uses

func (b *Body) Force() Vect

Get the force applied to the body for the next time step.

func (*Body) Free Uses

func (b *Body) Free()

Free is deprecated. Do not use it, it is no-op.

func (*Body) IsSleeping Uses

func (b *Body) IsSleeping() bool

Returns true if the body is sleeping.

func (*Body) KineticEnergy Uses

func (b *Body) KineticEnergy() float64

Get the amount of kinetic energy contained by the body.

func (*Body) LocalToWorld Uses

func (b *Body) LocalToWorld(point Vect) Vect

Convert body relative/local coordinates to absolute/world coordinates.

func (*Body) Mass Uses

func (b *Body) Mass() float64

Get the mass of the body.

func (*Body) Moment Uses

func (b *Body) Moment() float64

Get the moment of inertia of the body.

func (*Body) PolyShapeNew Uses

func (b *Body) PolyShapeNew(verts []Vect, transform Transform, radius float64) *Shape

Allocate and initialize a polygon shape with rounded corners.

A convex hull will be created from the vertexes.

func (*Body) Position Uses

func (b *Body) Position() Vect

Get the position of a body.

func (*Body) Rotation Uses

func (b *Body) Rotation() Vect

Get the rotation vector of the body. (The x basis vector of it's transform.)

func (*Body) SegmentShapeNew Uses

func (bd *Body) SegmentShapeNew(a, b Vect, radius float64) *Shape

Allocate and initialize a segment shape.

func (*Body) SetAngle Uses

func (b *Body) SetAngle(a float64)

Set the angle of a body.

func (*Body) SetAngularVelocity Uses

func (b *Body) SetAngularVelocity(angularVelocity float64)

Set the angular velocity of the body.

func (*Body) SetCenterOfGravity Uses

func (b *Body) SetCenterOfGravity(cog Vect)

Set the offset of the center of gravity in body local coordinates.

func (*Body) SetForce Uses

func (b *Body) SetForce(force Vect)

Set the force applied to the body for the next time step.

func (*Body) SetMass Uses

func (b *Body) SetMass(m float64)

Set the mass of the body.

func (*Body) SetMoment Uses

func (b *Body) SetMoment(i float64)

Set the moment of inertia of the body.

func (*Body) SetPosition Uses

func (b *Body) SetPosition(pos Vect)

Set the position of the body.

func (*Body) SetPositionUpdateFunc Uses

func (b *Body) SetPositionUpdateFunc(f BodyPositionFunc)

Set the callback used to update a body's position.

NOTE: It's not generally recommended to override this.

func (*Body) SetTorque Uses

func (b *Body) SetTorque(torque float64)

Set the torque applied to the body for the next time step.

func (*Body) SetType Uses

func (b *Body) SetType(t BodyType)

Set the type of the body.

func (*Body) SetUserData Uses

func (b *Body) SetUserData(userData interface{})

Set the user data interface assigned to the body.

func (*Body) SetVelocity Uses

func (b *Body) SetVelocity(velocity Vect)

Set the velocity of the body.

func (*Body) SetVelocityUpdateFunc Uses

func (b *Body) SetVelocityUpdateFunc(f BodyVelocityFunc)

Set the callback used to update a body's velocity.

func (*Body) Sleep Uses

func (b *Body) Sleep()

Force a body to fall asleep immediately.

func (*Body) SleepWithGroup Uses

func (b *Body) SleepWithGroup(group *Body)

Force a body to fall asleep immediately along with other bodies in a group.

func (*Body) Space Uses

func (b *Body) Space() *Space

Get the space this body is added to.

func (*Body) Torque Uses

func (b *Body) Torque() float64

Get the torque applied to the body for the next time step.

func (*Body) Type Uses

func (b *Body) Type() BodyType

Get the type of the body.

func (*Body) UserData Uses

func (b *Body) UserData() interface{}

Get the user data interface assigned to the body.

func (*Body) Velocity Uses

func (b *Body) Velocity() Vect

Get the velocity of the body.

func (*Body) VelocityAtLocalPoint Uses

func (b *Body) VelocityAtLocalPoint(point Vect) Vect

Get the velocity on a body (in world units) at a point on the body in local coordinates.

func (*Body) VelocityAtWorldPoint Uses

func (b *Body) VelocityAtWorldPoint(point Vect) Vect

Get the velocity on a body (in world units) at a point on the body in world coordinates.

func (*Body) WorldToLocal Uses

func (b *Body) WorldToLocal(point Vect) Vect

Convert body absolute/world coordinates to relative/local coordinates.

type BodyPositionFunc Uses

type BodyPositionFunc func(body *Body, dt float64)

Rigid body position update function type.

type BodyType Uses

type BodyType int

Chipmunk's rigid body type. Rigid bodies hold the physical properties of an object like it's mass, and position and velocity of it's center of gravity. They don't have an shape on their own. They are given a shape by creating collision shapes (cpShape) that point to the body.

const (
    BODY_TYPE_DYNAMIC   BodyType = C.CP_BODY_TYPE_DYNAMIC
    BODY_TYPE_KINEMATIC BodyType = C.CP_BODY_TYPE_KINEMATIC
    BODY_TYPE_STATIC    BodyType = C.CP_BODY_TYPE_STATIC
)

type BodyVelocityFunc Uses

type BodyVelocityFunc func(body *Body, gravity Vect, damping, dt float64)

Rigid body velocity update function type.

type CircleShape Uses

type CircleShape C.cpCircleShape

type CollisionBeginFunc Uses

type CollisionBeginFunc func(arb *Arbiter, space *Space, userData interface{}) bool

Collision begin event function callback type.

Returning false from a begin callback causes the collision to be ignored until the the separate callback is called when the objects stop colliding.

type CollisionHandler Uses

type CollisionHandler struct {
    TypeA, TypeB  CollisionType
    BeginFunc     CollisionBeginFunc
    PreSolveFunc  CollisionPreSolveFunc
    PostSolveFunc CollisionPostSolveFunc
    SeparateFunc  CollisionSeparateFunc
    UserData      interface{}
}

type CollisionID Uses

type CollisionID uint32

type CollisionPostSolveFunc Uses

type CollisionPostSolveFunc func(arb *Arbiter, space *Space, userData interface{})

Collision post-solve event function callback type.

type CollisionPreSolveFunc Uses

type CollisionPreSolveFunc func(arb *Arbiter, space *Space, userData interface{}) bool

Collision pre-solve event function callback type.

Returning false from a pre-step callback causes the collision to be ignored until the next step.

type CollisionSeparateFunc Uses

type CollisionSeparateFunc func(arb *Arbiter, space *Space, userData interface{})

Collision separate event function callback type.

type CollisionType Uses

type CollisionType uint64

type Constraint Uses

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

func DampedRotarySpringNew Uses

func DampedRotarySpringNew(a, b *Body, restAngle, stiffness, damping float64) *Constraint

Allocate and initialize a damped rotary spring.

func DampedSpringNew Uses

func DampedSpringNew(a, b *Body, anchorA, anchorB Vect, restLength, stiffness, damping float64) *Constraint

Allocate and initialize a damped spring.

func GearJointNew Uses

func GearJointNew(a, b *Body, phase, ratio float64) *Constraint

Allocate and initialize a gear joint.

func GrooveJointNew Uses

func GrooveJointNew(a, b *Body, grooveA, grooveB, anchorB Vect) *Constraint

Allocate and initialize a groove joint.

func PinJointNew Uses

func PinJointNew(a, b *Body, anchorA, anchorB Vect) *Constraint

Allocate and initialize a pin joint.

func PivotJointNew Uses

func PivotJointNew(a, b *Body, pivot Vect) *Constraint

Allocate and initialize a pivot joint.

func PivotJointNew2 Uses

func PivotJointNew2(a, b *Body, anchorA, anchorB Vect) *Constraint

Allocate and initialize a pivot joint with specific anchors.

func RatchetJointNew Uses

func RatchetJointNew(a, b *Body, phase, ratchet float64) *Constraint

Allocate and initialize a ratchet joint.

func RotaryLimitJointNew Uses

func RotaryLimitJointNew(a, b *Body, min, max float64) *Constraint

Allocate and initialize a damped rotary limit joint.

func SimpleMotorNew Uses

func SimpleMotorNew(a, b *Body, rate float64) *Constraint

Allocate and initialize a simple motor.

func SlideJointNew Uses

func SlideJointNew(a, b *Body, anchorA, anchorB Vect, min, max float64) *Constraint

Allocate and initialize a slide joint.

func (*Constraint) BodyA Uses

func (c *Constraint) BodyA() *Body

Get the first body the constraint is attached to.

func (*Constraint) BodyB Uses

func (c *Constraint) BodyB() *Body

Get the second body the constraint is attached to.

func (*Constraint) CollideBodies Uses

func (c *Constraint) CollideBodies() bool

Get if the two bodies connected by the constraint are allowed to collide or not.

func (*Constraint) DampedRotarySpringDamping Uses

func (c *Constraint) DampedRotarySpringDamping() float64

Get the damping of the spring.

func (*Constraint) DampedRotarySpringRestAngle Uses

func (c *Constraint) DampedRotarySpringRestAngle() float64

Get the rest length of the spring.

func (*Constraint) DampedRotarySpringSetDamping Uses

func (c *Constraint) DampedRotarySpringSetDamping(damping float64)

Set the damping of the spring.

func (*Constraint) DampedRotarySpringSetStiffness Uses

func (c *Constraint) DampedRotarySpringSetStiffness(stiffness float64)

Set the stiffness of the spring in force/distance.

func (*Constraint) DampedRotarySpringSetTorqueFunc Uses

func (c *Constraint) DampedRotarySpringSetTorqueFunc(f func(spring *Constraint, relativeAngle float64) float64)

Set the damping rotary spring torque callback function.

func (*Constraint) DampedRotarySpringStiffness Uses

func (c *Constraint) DampedRotarySpringStiffness() float64

Get the stiffness of the spring in force/distance.

func (*Constraint) DampedRotarySpringTorqueFunc Uses

func (c *Constraint) DampedRotarySpringTorqueFunc() func(spring *Constraint, relativeAngle float64) float64

Get the damping rotary spring torque callback function.

func (*Constraint) DampedSpringAnchorA Uses

func (c *Constraint) DampedSpringAnchorA() Vect

Get the location of the first anchor relative to the first body.

func (*Constraint) DampedSpringAnchorB Uses

func (c *Constraint) DampedSpringAnchorB() Vect

Get the location of the second anchor relative to the second body.

func (*Constraint) DampedSpringDamping Uses

func (c *Constraint) DampedSpringDamping() float64

Get the damping of the spring.

func (*Constraint) DampedSpringForceFunc Uses

func (c *Constraint) DampedSpringForceFunc() func(spring *Constraint, dist float64) float64

Get the damping rotary spring torque callback function.

func (*Constraint) DampedSpringRestLength Uses

func (c *Constraint) DampedSpringRestLength() float64

Get the rest length of the spring.

func (*Constraint) DampedSpringSetAnchorA Uses

func (c *Constraint) DampedSpringSetAnchorA(anchorA Vect)

Set the location of the first anchor relative to the first body.

func (*Constraint) DampedSpringSetAnchorB Uses

func (c *Constraint) DampedSpringSetAnchorB(anchorA Vect)

Set the location of the second anchor relative to the second body.

func (*Constraint) DampedSpringSetDamping Uses

func (c *Constraint) DampedSpringSetDamping(damping float64)

Set the damping of the spring.

func (*Constraint) DampedSpringSetForceFunc Uses

func (c *Constraint) DampedSpringSetForceFunc(f func(spring *Constraint, dist float64) float64)

Set the damping spring force callback function.

func (*Constraint) DampedSpringSetRestLength Uses

func (c *Constraint) DampedSpringSetRestLength(restLength float64)

Set the rest length of the spring.

func (*Constraint) DampedSpringSetStiffness Uses

func (c *Constraint) DampedSpringSetStiffness(stiffness float64)

Set the stiffness of the spring in force/distance.

func (*Constraint) DampedSpringStiffness Uses

func (c *Constraint) DampedSpringStiffness() float64

Get the stiffness of the spring in force/distance.

func (*Constraint) ErrorBias Uses

func (c *Constraint) ErrorBias() float64

Get rate at which joint error is corrected.

func (*Constraint) Free Uses

func (c *Constraint) Free()

Free is deprecated. Do not use it, it is no-op.

func (*Constraint) GearJointPhase Uses

func (c *Constraint) GearJointPhase() float64

Get the phase offset of the gears.

func (*Constraint) GearJointRatio Uses

func (c *Constraint) GearJointRatio() float64

Get the angular distance of each ratchet.

func (*Constraint) GearJointSetPhase Uses

func (c *Constraint) GearJointSetPhase(phase float64)

Set the phase offset of the gears.

func (*Constraint) GearJointSetRatio Uses

func (c *Constraint) GearJointSetRatio(ratio float64)

Set the ratio of a gear joint.

func (*Constraint) GrooveJointAnchorB Uses

func (c *Constraint) GrooveJointAnchorB() Vect

Get the location of the second anchor relative to the second body.

func (*Constraint) GrooveJointGrooveA Uses

func (c *Constraint) GrooveJointGrooveA() Vect

Get the first endpoint of the groove relative to the first body.

func (*Constraint) GrooveJointGrooveB Uses

func (c *Constraint) GrooveJointGrooveB() Vect

Get the first endpoint of the groove relative to the first body.

func (*Constraint) GrooveJointSetAnchorB Uses

func (c *Constraint) GrooveJointSetAnchorB(grooveB Vect)

Set the location of the second anchor relative to the second body.

func (*Constraint) GrooveJointSetGrooveA Uses

func (c *Constraint) GrooveJointSetGrooveA(grooveA Vect)

Set the first endpoint of the groove relative to the first body.

func (*Constraint) GrooveJointSetGrooveB Uses

func (c *Constraint) GrooveJointSetGrooveB(grooveB Vect)

Set the first endpoint of the groove relative to the first body.

func (*Constraint) Impulse Uses

func (c *Constraint) Impulse() float64

Get the last impulse applied by this constraint.

func (*Constraint) IsDampedRotarySpring Uses

func (c *Constraint) IsDampedRotarySpring() bool

Check if a constraint is a damped rotary spring.

func (*Constraint) IsDampedSpring Uses

func (c *Constraint) IsDampedSpring() bool

Check if a constraint is a damped spring.

func (*Constraint) IsGearJoint Uses

func (c *Constraint) IsGearJoint() bool

Check if a constraint is a ratchet joint.

func (*Constraint) IsGrooveJoint Uses

func (c *Constraint) IsGrooveJoint() bool

Check if a constraint is a groove joint.

func (*Constraint) IsPinJoint Uses

func (c *Constraint) IsPinJoint() bool

Check if a constraint is a pin joint.

func (*Constraint) IsPivotJoint Uses

func (c *Constraint) IsPivotJoint() bool

Check if a constraint is a pivot joint.

func (*Constraint) IsRatchetJoint Uses

func (c *Constraint) IsRatchetJoint() bool

Check if a constraint is a ratchet joint.

func (*Constraint) IsRotaryLimitJoint Uses

func (c *Constraint) IsRotaryLimitJoint() bool

Check if a constraint is a rotary limit joint.

func (*Constraint) IsSimpleMotor Uses

func (c *Constraint) IsSimpleMotor() bool

Check if a constraint is a simple motor.

func (*Constraint) IsSlideJoint Uses

func (c *Constraint) IsSlideJoint() bool

Check if a constraint is a slide joint.

func (*Constraint) MaxBias Uses

func (c *Constraint) MaxBias() float64

Get the maximum rate at which joint error is corrected.

func (*Constraint) MaxForce Uses

func (c *Constraint) MaxForce() float64

Get the maximum force that this constraint is allowed to use.

func (*Constraint) PinJointAnchorA Uses

func (c *Constraint) PinJointAnchorA() Vect

Get the location of the first anchor relative to the first body.

func (*Constraint) PinJointAnchorB Uses

func (c *Constraint) PinJointAnchorB() Vect

Get the location of the second anchor relative to the second body.

func (*Constraint) PinJointDist Uses

func (c *Constraint) PinJointDist() float64

Get the distance the joint will maintain between the two anchors.

func (*Constraint) PinJointSetAnchorA Uses

func (c *Constraint) PinJointSetAnchorA(anchorA Vect)

Set the location of the first anchor relative to the first body.

func (*Constraint) PinJointSetAnchorB Uses

func (c *Constraint) PinJointSetAnchorB(anchorB Vect)

Set the location of the second anchor relative to the second body.

func (*Constraint) PinJointSetDist Uses

func (c *Constraint) PinJointSetDist(dist float64)

Set the distance the joint will maintain between the two anchors.

func (*Constraint) PivotJointAnchorA Uses

func (c *Constraint) PivotJointAnchorA() Vect

Get the location of the first anchor relative to the first body.

func (*Constraint) PivotJointAnchorB Uses

func (c *Constraint) PivotJointAnchorB() Vect

Get the location of the second anchor relative to the second body.

func (*Constraint) PivotJointSetAnchorA Uses

func (c *Constraint) PivotJointSetAnchorA(anchorA Vect)

Set the location of the first anchor relative to the first body.

func (*Constraint) PivotJointSetAnchorB Uses

func (c *Constraint) PivotJointSetAnchorB(anchorB Vect)

Set the location of the second anchor relative to the second body.

func (*Constraint) PostSolveFunc Uses

func (c *Constraint) PostSolveFunc() func(*Constraint, *Space)

Get the post-solve function that is called before the solver runs.

func (*Constraint) PreSolveFunc Uses

func (c *Constraint) PreSolveFunc() func(*Constraint, *Space)

Get the pre-solve function that is called before the solver runs.

func (*Constraint) RatchetJointAngle Uses

func (c *Constraint) RatchetJointAngle() float64

Get the angle of the current ratchet tooth.

func (*Constraint) RatchetJointPhase Uses

func (c *Constraint) RatchetJointPhase() float64

Get the phase offset of the ratchet.

func (*Constraint) RatchetJointRatchet Uses

func (c *Constraint) RatchetJointRatchet() float64

Get the angular distance of each ratchet.

func (*Constraint) RatchetJointSetAngle Uses

func (c *Constraint) RatchetJointSetAngle(angle float64)

Set the angle of the current ratchet tooth.

func (*Constraint) RatchetJointSetPhase Uses

func (c *Constraint) RatchetJointSetPhase(phase float64)

Get the phase offset of the ratchet.

func (*Constraint) RatchetJointSetRatchet Uses

func (c *Constraint) RatchetJointSetRatchet(ratchet float64)

Set the angular distance of each ratchet.

func (*Constraint) RotaryLimitJointMax Uses

func (c *Constraint) RotaryLimitJointMax() float64

Get the maximum distance the joint will maintain between the two anchors.

func (*Constraint) RotaryLimitJointMin Uses

func (c *Constraint) RotaryLimitJointMin() float64

Get the minimum distance the joint will maintain between the two anchors.

func (*Constraint) RotaryLimitJointSetMax Uses

func (c *Constraint) RotaryLimitJointSetMax(max float64)

Set the maximum distance the joint will maintain between the two anchors.

func (*Constraint) RotaryLimitJointSetMin Uses

func (c *Constraint) RotaryLimitJointSetMin(min float64)

Set the minimum distance the joint will maintain between the two anchors.

func (*Constraint) RotarySpringSetRestAngle Uses

func (c *Constraint) RotarySpringSetRestAngle(restAngle float64)

Set the rest length of the spring.

func (*Constraint) SetCollideBodies Uses

func (c *Constraint) SetCollideBodies(collideBodies bool)

Set if the two bodies connected by the constraint are allowed to collide or not. (defaults to cpFalse)

func (*Constraint) SetErrorBias Uses

func (c *Constraint) SetErrorBias(errorBias float64)

Set rate at which joint error is corrected.

Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.

func (*Constraint) SetMaxBias Uses

func (c *Constraint) SetMaxBias(maxBias float64)

Set the maximum rate at which joint error is corrected. (defaults to INFINITY)

func (*Constraint) SetMaxForce Uses

func (c *Constraint) SetMaxForce(maxForce float64)

Set the maximum force that this constraint is allowed to use. (defaults to INFINITY)

func (*Constraint) SetPostSolveFunc Uses

func (c *Constraint) SetPostSolveFunc(f func(*Constraint, *Space))

Set the post-solve function that is called before the solver runs.

func (*Constraint) SetPreSolveFunc Uses

func (c *Constraint) SetPreSolveFunc(f func(*Constraint, *Space))

Set the pre-solve function that is called before the solver runs.

func (*Constraint) SetUserData Uses

func (c *Constraint) SetUserData(i interface{})

Set the user definable data pointer for this constraint

func (*Constraint) SimpleMotorRate Uses

func (c *Constraint) SimpleMotorRate() float64

Get the rate of the motor.

func (*Constraint) SimpleMotorSetRate Uses

func (c *Constraint) SimpleMotorSetRate(rate float64)

Set the rate of the motor.

func (*Constraint) SlideJointAnchorA Uses

func (c *Constraint) SlideJointAnchorA() Vect

Get the location of the first anchor relative to the first body.

func (*Constraint) SlideJointAnchorB Uses

func (c *Constraint) SlideJointAnchorB() Vect

Get the location of the second anchor relative to the second body.

func (*Constraint) SlideJointMax Uses

func (c *Constraint) SlideJointMax() float64

Get the maximum distance the joint will maintain between the two anchors.

func (*Constraint) SlideJointMin Uses

func (c *Constraint) SlideJointMin() float64

Get the minimum distance the joint will maintain between the two anchors.

func (*Constraint) SlideJointSetAnchorA Uses

func (c *Constraint) SlideJointSetAnchorA(anchorA Vect)

Set the location of the first anchor relative to the first body.

func (*Constraint) SlideJointSetAnchorB Uses

func (c *Constraint) SlideJointSetAnchorB(anchorB Vect)

Set the location of the second anchor relative to the second body.

func (*Constraint) SlideJointSetMax Uses

func (c *Constraint) SlideJointSetMax(max float64)

Set the maximum distance the joint will maintain between the two anchors.

func (*Constraint) SlideJointSetMin Uses

func (c *Constraint) SlideJointSetMin(min float64)

Set the minimum distance the joint will maintain between the two anchors.

func (*Constraint) Space Uses

func (c *Constraint) Space() *Space

Get the Space this constraint is added to.

func (*Constraint) UserData Uses

func (c *Constraint) UserData() interface{}

Get the user definable data pointer for this constraint

type ConstraintPostSolveFunc Uses

type ConstraintPostSolveFunc func(c *Constraint, space *Space)

Callback function type that gets called after solving a joint.

type ConstraintPreSolveFunc Uses

type ConstraintPreSolveFunc func(c *Constraint, space *Space)

Callback function type that gets called before solving a joint.

type ContactBufferHeader Uses

type ContactBufferHeader C.cpContactBufferHeader

type ContactPoint Uses

type ContactPoint struct {
    // The position of the contact on the surface of each shape.
    Point1, Point2 Vect

    // Penetration distance of the two shapes. Overlapping means it will be
    // negative.
    //
    // This value is calculated as Vdot(Vsub(point2, point1), normal) and is
    // ignored by arbiter.SetContactPointSet().
    Distance float64
}

type ContactPointSet Uses

type ContactPointSet struct {
    // The number of contact points in the set.
    Count Int

    // The normal of the collision.
    Normal Vect

    // The array of contact points.
    Points [MAX_CONTACTS_PER_ARBITER]ContactPoint
}

A struct that wraps up the important collision data for an arbiter.

type DampedRotarySpring Uses

type DampedRotarySpring C.cpDampedRotarySpring

type DampedSpring Uses

type DampedSpring C.cpDampedSpring

type DataPointer Uses

type DataPointer unsafe.Pointer

type GearJoint Uses

type GearJoint C.cpGearJoint

type GrooveJoint Uses

type GrooveJoint C.cpGrooveJoint

type Group Uses

type Group uint64

type HashSet Uses

type HashSet C.cpHashSet

type HashValue Uses

type HashValue uint64

type Int Uses

type Int C.int

type Mat2x2 Uses

type Mat2x2 struct {
    A   float64
    B   float64
    C   float64
    D   float64
}

Row major [[a, b][c, d]]

func Mat2x2New Uses

func Mat2x2New(a, b, c, d float64) Mat2x2

func (Mat2x2) Transform Uses

func (m Mat2x2) Transform(v Vect) Vect

type PinJoint Uses

type PinJoint C.cpPinJoint

type PivotJoint Uses

type PivotJoint C.cpPivotJoint

type PointQueryInfo Uses

type PointQueryInfo struct {
    // The nearest shape, nil if no shape was within range.
    Shape *Shape

    // The closest point on the shape's surface. (in world space coordinates)
    Point Vect

    // 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 same as info.p/info.d, but accurate even for very small values of
    // info.d.
    Gradient Vect
}

Nearest point query info struct.

type PolyShape Uses

type PolyShape C.cpPolyShape

type RatchetJoint Uses

type RatchetJoint C.cpRatchetJoint

type RotaryLimitJoint Uses

type RotaryLimitJoint C.cpRotaryLimitJoint

type SegmentQueryInfo Uses

type SegmentQueryInfo struct {
    // The shape that was hit, nil if no collision occured.
    Shape *Shape

    // The point of impact.
    Point Vect

    // The normal of the surface hit.
    Normal Vect

    // The normalized distance along the query segment in the range [0, 1].
    Alpha float64
}

Segment query info struct.

type SegmentShape Uses

type SegmentShape C.cpSegmentShape

type Shape Uses

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

The Shape struct defines the shape of a rigid body.

func (*Shape) Area Uses

func (s *Shape) Area() float64

Get the calculated area of this shape.

func (*Shape) BB Uses

func (s *Shape) BB() BB

Get the bounding box that contains the shape given it's current position and angle.

func (*Shape) Body Uses

func (s *Shape) Body() *Body

The cpBody this shape is connected to.

func (*Shape) CacheBB Uses

func (s *Shape) CacheBB() BB

Update, cache and return the bounding box of a shape based on the body it's attached to.

func (*Shape) CenterOfGravity Uses

func (s *Shape) CenterOfGravity() Vect

Get the centroid of this shape.

func (*Shape) CircleOffset Uses

func (s *Shape) CircleOffset() Vect

Get the offset of a circle shape.

func (*Shape) CircleRadius Uses

func (s *Shape) CircleRadius() float64

Get the radius of a circle shape.

func (*Shape) CircleShapeSetOffset Uses

func (shape *Shape) CircleShapeSetOffset(offset Vect)

Set the offset of a circle shape.

This function is used for mutating collision shapes. Chipmunk does not have any way to get velocity information on changing shapes, so the results will be unrealistic. This function is considered 'unsafe' by Chipmunk.

func (*Shape) CircleShapeSetRadius Uses

func (shape *Shape) CircleShapeSetRadius(radius float64)

Set the radius of a circle shape.

This function is used for mutating collision shapes. Chipmunk does not have any way to get velocity information on changing shapes, so the results will be unrealistic. This function is considered 'unsafe' by Chipmunk.

func (*Shape) CollisionType Uses

func (s *Shape) CollisionType() CollisionType

Get the collision type of this shape.

func (*Shape) Density Uses

func (s *Shape) Density() float64

Get the density of the shape if you are having Chipmunk calculate mass properties for you.

func (*Shape) Elasticity Uses

func (s *Shape) Elasticity() float64

Get the elasticity of this shape.

func (*Shape) Filter Uses

func (s *Shape) Filter() ShapeFilter

Get the collision filtering parameters of this shape.

func (*Shape) Free Uses

func (s *Shape) Free()

Free is deprecated. Do not use it, it is no-op.

func (*Shape) Friction Uses

func (s *Shape) Friction() float64

Get the friction of this shape.

func (*Shape) Mass Uses

func (s *Shape) Mass() float64

Get the mass of the shape if you are having Chipmunk calculate mass properties for you.

func (*Shape) Moment Uses

func (s *Shape) Moment() float64

Get the calculated moment of inertia for this shape.

func (*Shape) PointQuery Uses

func (s *Shape) PointQuery(p Vect) (out *PointQueryInfo, d float64)

Perform a nearest point query. It finds the closest point on the surface of shape to a specific point.

The value returned is the distance between the points. A negative distance means the point is inside the shape.

func (*Shape) PolyCount Uses

func (s *Shape) PolyCount() int

Get the number of verts in a polygon shape.

func (*Shape) PolyRadius Uses

func (s *Shape) PolyRadius() float64

Get the radius of a polygon shape.

func (*Shape) PolyShapeSetRadius Uses

func (shape *Shape) PolyShapeSetRadius(radius float64)

Set the radius of a poly shape.

This function is used for mutating collision shapes. Chipmunk does not have any way to get velocity information on changing shapes, so the results will be unrealistic. This function is considered 'unsafe' by Chipmunk.

func (*Shape) PolyShapeSetVerts Uses

func (shape *Shape) PolyShapeSetVerts(verts []Vect, transform Transform)

Set the vertexes of a poly shape.

This function is used for mutating collision shapes. Chipmunk does not have any way to get velocity information on changing shapes, so the results will be unrealistic. This function is considered 'unsafe' by Chipmunk.

func (*Shape) PolyShapeSetVertsRaw Uses

func (shape *Shape) PolyShapeSetVertsRaw(verts []Vect)

Set the vertexes of a poly shape.

This function is used for mutating collision shapes. Chipmunk does not have any way to get velocity information on changing shapes, so the results will be unrealistic. This function is considered 'unsafe' by Chipmunk.

func (*Shape) PolyVert Uses

func (s *Shape) PolyVert(index int) Vect

Get the ith vertex of a polygon shape.

func (*Shape) SegmentA Uses

func (s *Shape) SegmentA() Vect

Get the first endpoint of a segment shape.

func (*Shape) SegmentB Uses

func (s *Shape) SegmentB() Vect

Get the second endpoint of a segment shape.

func (*Shape) SegmentNormal Uses

func (s *Shape) SegmentNormal() Vect

Get the normal of a segment shape.

func (*Shape) SegmentQuery Uses

func (s *Shape) SegmentQuery(a, b Vect, radius float64) (info *SegmentQueryInfo, ret bool)

Perform a segment query against a shape.

func (*Shape) SegmentRadius Uses

func (s *Shape) SegmentRadius() float64

Get the first endpoint of a segment shape.

func (*Shape) SegmentSetNeighbors Uses

func (s *Shape) SegmentSetNeighbors(prev, next Vect)

Let Chipmunk know about the geometry of adjacent segments to avoid colliding with endcaps.

func (*Shape) SegmentShapeSetEndpoints Uses

func (shape *Shape) SegmentShapeSetEndpoints(a, b Vect)

Set the endpoints of a segment shape.

This function is used for mutating collision shapes. Chipmunk does not have any way to get velocity information on changing shapes, so the results will be unrealistic. This function is considered 'unsafe' by Chipmunk.

func (*Shape) SegmentShapeSetRadius Uses

func (shape *Shape) SegmentShapeSetRadius(radius float64)

Set the radius of a segment shape.

This function is used for mutating collision shapes. Chipmunk does not have any way to get velocity information on changing shapes, so the results will be unrealistic. This function is considered 'unsafe' by Chipmunk.

func (*Shape) Sensor Uses

func (s *Shape) Sensor() bool

Get if the shape is set to be a sensor or not.

func (*Shape) SetBody Uses

func (s *Shape) SetBody(b *Body)

Set the cpBody this shape is connected to.

Can only be used if the shape is not currently added to a space.

func (*Shape) SetCollisionType Uses

func (s *Shape) SetCollisionType(collisionType CollisionType)

Set the collision type of this shape.

func (*Shape) SetDensity Uses

func (s *Shape) SetDensity(density float64)

Set the density of this shape to have Chipmunk calculate mass properties for you.

func (*Shape) SetElasticity Uses

func (s *Shape) SetElasticity(elasticity float64)

Set the elasticity of this shape.

func (*Shape) SetFilter Uses

func (s *Shape) SetFilter(filter ShapeFilter)

Set the collision filtering parameters of this shape.

func (*Shape) SetFriction Uses

func (s *Shape) SetFriction(friction float64)

Set the friction of this shape.

func (*Shape) SetMass Uses

func (s *Shape) SetMass(mass float64)

Set the mass of this shape to have Chipmunk calculate mass properties for you.

func (*Shape) SetSensor Uses

func (s *Shape) SetSensor(sensor bool)

Set if the shape is a sensor or not.

func (*Shape) SetSurfaceVelocity Uses

func (s *Shape) SetSurfaceVelocity(surfaceVelocity Vect)

Set the surface velocity of this shape.

func (*Shape) SetUserData Uses

func (s *Shape) SetUserData(i interface{})

Set the user definable data pointer of this shape.

func (*Shape) ShapesCollide Uses

func (a *Shape) ShapesCollide(b *Shape) ContactPointSet

Return contact information about two shapes.

func (*Shape) Space Uses

func (s *Shape) Space() *Space

The cpSpace this body is added to.

func (*Shape) SurfaceVelocity Uses

func (s *Shape) SurfaceVelocity() Vect

Get the surface velocity of this shape.

func (*Shape) Update Uses

func (s *Shape) Update(transform Transform) BB

Update, cache and return the bounding box of a shape with an explicit transformation.

func (*Shape) UserData Uses

func (s *Shape) UserData() interface{}

Get the user definable data interface of this shape.

type ShapeFilter Uses

type ShapeFilter struct {
    Group      Group
    Categories Bitmask
    Mask       Bitmask
}

func ShapeFilterNew Uses

func ShapeFilterNew(group Group, categories, mask Bitmask) ShapeFilter

type SimpleMotorJoint Uses

type SimpleMotorJoint C.cpSimpleMotorJoint

type SlideJoint Uses

type SlideJoint C.cpSlideJoint

type Space Uses

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

func SpaceNew Uses

func SpaceNew() *Space

Allocate and initialize a cpSpace.

func (*Space) AddBody Uses

func (s *Space) AddBody(body *Body) *Body

Add a rigid body to the simulation.

func (*Space) AddCollisionHandler Uses

func (s *Space) AddCollisionHandler(a, b CollisionType, handler *CollisionHandler)

func (*Space) AddConstraint Uses

func (s *Space) AddConstraint(constraint *Constraint) *Constraint

Add a constraint to the simulation.

func (*Space) AddDefaultCollisionHandler Uses

func (s *Space) AddDefaultCollisionHandler()

func (*Space) AddPostStepCallback Uses

func (s *Space) AddPostStepCallback(f func())

Schedule a post-step callback to be called when space.Step() finishes.

func (*Space) AddShape Uses

func (s *Space) AddShape(shape *Shape) *Shape

Add 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) AddWildcardHandler Uses

func (s *Space) AddWildcardHandler(t CollisionType, handler *CollisionHandler)

func (*Space) BBQuery Uses

func (s *Space) BBQuery(bb BB, filter ShapeFilter, f SpaceBBQueryFunc, data interface{})

Perform a fast rectangle query on the space calling func for each shape found.

Only the shape's bounding boxes are checked for overlap, not their full shape.

func (*Space) CollisionBias Uses

func (s *Space) CollisionBias() float64

Determines 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) CollisionPersistence Uses

func (s *Space) CollisionPersistence() Timestamp

Number of frames that contact information should persist.

Defaults to 3. There is probably never a reason to change this value.

func (*Space) CollisionSlop Uses

func (s *Space) CollisionSlop() float64

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) ContainsBody Uses

func (s *Space) ContainsBody(body *Body) bool

Test if a rigid body has been added to the space.

func (*Space) ContainsConstraint Uses

func (s *Space) ContainsConstraint(constraint *Constraint) bool

Test if a constraint has been added to the space.

func (*Space) ContainsShape Uses

func (s *Space) ContainsShape(shape *Shape) bool

Test if a collision shape has been added to the space.

func (*Space) CurrentTimeStep Uses

func (s *Space) CurrentTimeStep() float64

Returns the current (or most recent) time step used with the given space. Useful from callbacks if your time step is not a compile-time global.

func (*Space) Damping Uses

func (s *Space) Damping() float64

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.

This damping value is different than those of cpDampedSpring and cpDampedRotarySpring.

func (*Space) DebugDraw Uses

func (s *Space) DebugDraw(options *SpaceDebugDrawOptions)

DebugDraw draws the space using the debug draw options (which includes callbacks for performing the actual drawing). All options fields are entirely optional (callbacks may be nil, etc).

options.Data is arbitrary user data fed into the callbacks (this is just for a 1:1 mapping of chipmunks API, in Go you can just use a closure and access the data itself not storing it inside options.Data).

func (*Space) EachBody Uses

func (s *Space) EachBody(space *Space, f func(b *Body))

Space/body iterator callback function type.

func (*Space) EachConstraint Uses

func (s *Space) EachConstraint(space *Space, f func(c *Constraint))

Call f for each shape in the space.

func (*Space) EachShape Uses

func (s *Space) EachShape(space *Space, f func(s *Shape))

Call f for each shape in the space.

func (*Space) Free Uses

func (s *Space) Free()

Free is deprecated. Do not use it, it is no-op.

func (*Space) Gravity Uses

func (s *Space) Gravity() Vect

Gravity to pass to rigid bodies when integrating velocity.

func (*Space) IdleSpeedThreshold Uses

func (s *Space) IdleSpeedThreshold() float64

Speed threshold for a body to be considered idle.

The default value of 0 means to let the space guess a good threshold based on gravity.

func (*Space) IsLocked Uses

func (s *Space) IsLocked() bool

returns true from inside a callback when objects cannot be added/removed.

func (*Space) Iterations Uses

func (s *Space) Iterations() int

Number of iterations to use in the impulse solver to solve contacts and other constraints.

func (*Space) PointQuery Uses

func (s *Space) PointQuery(point Vect, maxDistance float64, filter ShapeFilter, f SpacePointQueryFunc, data interface{})

Query the space at a point and call f for each shape found.

func (*Space) PointQueryNearest Uses

func (s *Space) PointQueryNearest(point Vect, maxDistance float64, filter ShapeFilter) (shape *Shape, out *PointQueryInfo)

Query the space at a point and return the nearest shape found. Returns NULL if no shapes were found.

func (*Space) ReindexShape Uses

func (s *Space) ReindexShape(shape *Shape)

Update the collision detection data for a specific shape in the space.

func (*Space) ReindexShapesForBody Uses

func (s *Space) ReindexShapesForBody(body *Body)

Update the collision detection data for all shapes attached to a body.

func (*Space) ReindexStatic Uses

func (s *Space) ReindexStatic()

Update the collision detection info for the static shapes in the space.

func (*Space) RemoveBody Uses

func (s *Space) RemoveBody(body *Body)

Remove a rigid body from the simulation.

func (*Space) RemoveConstraint Uses

func (s *Space) RemoveConstraint(constraint *Constraint)

Remove a constraint from the simulation.

func (*Space) RemoveShape Uses

func (s *Space) RemoveShape(shape *Shape)

Remove a collision shape from the simulation.

func (*Space) SegmentQuery Uses

func (s *Space) SegmentQuery(start, end Vect, radius float64, filter ShapeFilter, f SpaceSegmentQueryFunc, data interface{})

Perform a directed line segment query (like a raycast) against the space calling f for each shape intersected.

func (*Space) SegmentQueryFirst Uses

func (s *Space) SegmentQueryFirst(start, end Vect, radius float64, filter ShapeFilter) (shape *Shape, out *SegmentQueryInfo)

Perform a directed line segment query (like a raycast) against the space and return the first shape hit. Returns NULL if no shapes were hit.

func (*Space) SetCollisionBias Uses

func (s *Space) SetCollisionBias(collisionBias float64)

func (*Space) SetCollisionPersistence Uses

func (s *Space) SetCollisionPersistence(collisionPersistence Timestamp)

func (*Space) SetCollisionSlop Uses

func (s *Space) SetCollisionSlop(collisionSlop float64)

func (*Space) SetDamping Uses

func (s *Space) SetDamping(damping float64)

func (*Space) SetGravity Uses

func (s *Space) SetGravity(gravity Vect)

func (*Space) SetIdleSpeedThreshold Uses

func (s *Space) SetIdleSpeedThreshold(idleSpeedThreshold float64)

func (*Space) SetIterations Uses

func (s *Space) SetIterations(iterations int)

func (*Space) SetSleepTimeThreshold Uses

func (s *Space) SetSleepTimeThreshold(sleepTimeThreshold float64)

func (*Space) SetUserData Uses

func (s *Space) SetUserData(i interface{})

func (*Space) ShapeQuery Uses

func (s *Space) ShapeQuery(shape *Shape, f SpaceShapeQueryFunc, data interface{}) bool

Query a space for any shapes overlapping the given shape and call func for each shape found.

func (*Space) SleepTimeThreshold Uses

func (s *Space) SleepTimeThreshold() float64

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 INFINITY disables the sleeping algorithm.

func (*Space) StaticBody Uses

func (s *Space) StaticBody() *Body

The Space provided static body for a given cpSpace.

This is merely provided for convenience and you are not required to use it.

func (*Space) Step Uses

func (s *Space) Step(dt float64)

Step the space forward in time by dt.

func (*Space) UseSpatialHash Uses

func (s *Space) UseSpatialHash(dim float64, count int)

Switch the space to use a spatial has as it's spatial index.

func (*Space) UserData Uses

func (s *Space) UserData() interface{}

User definable data interface.

Generally this points to your game's controller or game state class so you can access it when given a cpSpace reference in a callback.

type SpaceArbiterApplyImpulseFunc Uses

type SpaceArbiterApplyImpulseFunc func(arb *Arbiter)

type SpaceBBQueryFunc Uses

type SpaceBBQueryFunc func(shape *Shape, data interface{})

Rectangle Query callback function type.

type SpaceDebugColor Uses

type SpaceDebugColor struct {
    R   float32
    G   float32
    B   float32
    A   float32
}

type SpaceDebugDrawCircleImpl Uses

type SpaceDebugDrawCircleImpl func(pos Vect, angle, radius float64, outlineColor, fillColor SpaceDebugColor, data interface{})

type SpaceDebugDrawColorForShapeImpl Uses

type SpaceDebugDrawColorForShapeImpl func(shape *Shape, data interface{}) SpaceDebugColor

type SpaceDebugDrawDotImpl Uses

type SpaceDebugDrawDotImpl func(size float64, pos Vect, color SpaceDebugColor, data interface{})

type SpaceDebugDrawFatSegmentImpl Uses

type SpaceDebugDrawFatSegmentImpl func(a, b Vect, radius float64, outlineColor, fillColor SpaceDebugColor, data interface{})

type SpaceDebugDrawFlags Uses

type SpaceDebugDrawFlags int
const (
    SPACE_DEBUG_DRAW_SHAPES           SpaceDebugDrawFlags = C.CP_SPACE_DEBUG_DRAW_SHAPES
    SPACE_DEBUG_DRAW_CONSTRAINTS      SpaceDebugDrawFlags = C.CP_SPACE_DEBUG_DRAW_CONSTRAINTS
    SPACE_DEBUG_DRAW_COLLISION_POINTS SpaceDebugDrawFlags = C.CP_SPACE_DEBUG_DRAW_COLLISION_POINTS
)

type SpaceDebugDrawOptions Uses

type SpaceDebugDrawOptions struct {
    DrawCircle     SpaceDebugDrawCircleImpl
    DrawSegment    SpaceDebugDrawSegmentImpl
    DrawFatSegment SpaceDebugDrawFatSegmentImpl
    DrawPolygon    SpaceDebugDrawPolygonImpl
    DrawDot        SpaceDebugDrawDotImpl

    ColorForShape SpaceDebugDrawColorForShapeImpl

    Flags               SpaceDebugDrawFlags
    ShapeOutlineColor   SpaceDebugColor
    ConstraintColor     SpaceDebugColor
    CollisionPointColor SpaceDebugColor

    Data interface{}
}

type SpaceDebugDrawPolygonImpl Uses

type SpaceDebugDrawPolygonImpl func(verts []Vect, radius float64, outlineColor, fillColor SpaceDebugColor, data interface{})

type SpaceDebugDrawSegmentImpl Uses

type SpaceDebugDrawSegmentImpl func(a, b Vect, color SpaceDebugColor, data interface{})

type SpacePointQueryFunc Uses

type SpacePointQueryFunc func(shape *Shape, point Vect, distance float64, gradient Vect, data interface{})

Nearest point query callback function type.

type SpaceSegmentQueryFunc Uses

type SpaceSegmentQueryFunc func(shape *Shape, point, normal Vect, alpha float64, data interface{})

Nearest point query callback function type.

type SpaceShapeQueryFunc Uses

type SpaceShapeQueryFunc func(shape *Shape, points *ContactPointSet, data interface{})

Shape query callback function type.

type Timestamp Uses

type Timestamp uint32

type Transform Uses

type Transform struct {
    A   float64
    B   float64
    C   float64
    D   float64
    Tx  float64
    Ty  float64
}

Column major affine transform.

func TransformAxialScale Uses

func TransformAxialScale(axis, pivot Vect, scale float64) Transform

func TransformBoneScale Uses

func TransformBoneScale(v0, v1 Vect) Transform

func TransformNew Uses

func TransformNew(a, b, c, d, tx, ty float64) Transform

Construct a new transform matrix.

(a, b) is the x basis vector.

(c, d) is the y basis vector.

(tx, ty) is the translation.

func TransformNewTranspose Uses

func TransformNewTranspose(a, c, tx, b, d, ty float64) Transform

Construct a new transform matrix in transposed order.

func TransformOrtho Uses

func TransformOrtho(bb BB) Transform

func TransformRigid Uses

func TransformRigid(translate Vect, radians float64) Transform

Create a rigid transformation matrix. (translation + rotation)

func TransformRotate Uses

func TransformRotate(radians float64) Transform

Create a rotation matrix.

func TransformScale Uses

func TransformScale(scaleX, scaleY float64) Transform

Create a scale matrix.

func TransformTranslate Uses

func TransformTranslate(translate Vect) Transform

Create a translation matrix.

func (Transform) BB Uses

func (t Transform) BB(bb BB) BB

Transform a BB.

func (Transform) Inverse Uses

func (t Transform) Inverse() Transform

Get the inverse of a transform matrix.

func (Transform) Mult Uses

func (t1 Transform) Mult(t2 Transform) Transform

Multiply two transformation matrices.

func (Transform) Point Uses

func (t Transform) Point(p Vect) Vect

Transform an absolute point. (i.e. a vertex)

func (Transform) RigidInverse Uses

func (t Transform) RigidInverse() Transform

Fast inverse of a rigid transformation matrix.

func (Transform) Vect Uses

func (t Transform) Vect(v Vect) Vect

Transform a vector (i.e. a normal)

func (Transform) Wrap Uses

func (outer Transform) Wrap(inner Transform) Transform

func (Transform) WrapInverse Uses

func (outer Transform) WrapInverse(inner Transform) Transform

type Vect Uses

type Vect struct {
    X   float64
    Y   float64
}

Chipmunk's 2D vector type.

func CentroidForPoly Uses

func CentroidForPoly(verts []Vect) Vect

Calculate the natural centroid of a polygon.

func ClosetPointOnSegment Uses

func ClosetPointOnSegment(p, a, b Vect) Vect

Returns the closest point on the line segment ab, to the point p.

func V Uses

func V(x, y float64) Vect

Convenience constructor for cpVect structs.

func Vadd Uses

func Vadd(v1, v2 Vect) Vect

Add two vectors

func Vdot Uses

func Vdot(v1, v2 Vect) Vect

Vector dot product.

func Vforangle Uses

func Vforangle(a float64) Vect

Returns the unit length vector for the given angle (in radians).

func Vlerp Uses

func Vlerp(v1, v2 Vect, t float64) Vect

Linearly interpolate between v1 and v2.

func Vlerpconst Uses

func Vlerpconst(v1, v2 Vect, d float64) Vect

Linearly interpolate between v1 towards v2 by distance d.

func Vmult Uses

func Vmult(v Vect, s float64) Vect

Scalar multiplication.

func Vneg Uses

func Vneg(v Vect) Vect

Negate a vector.

func Vnormalize Uses

func Vnormalize(v Vect) Vect

Returns a normalized copy of v.

func Vperp Uses

func Vperp(v Vect) Vect

Returns a perpendicular vector. (90 degree rotation)

func Vproject Uses

func Vproject(v1, v2 Vect) Vect

Returns the vector projection of v1 onto v2.

func Vrotate Uses

func Vrotate(v1, v2 Vect) Vect

Uses complex number multiplication to rotate v1 by v2. Scaling will occur if v1 is not a unit vector.

func Vrperp Uses

func Vrperp(v Vect) Vect

Returns a perpendicular vector. (-90 degree rotation)

func Vslerp Uses

func Vslerp(v1, v2 Vect, t float64) Vect

Spherical linearly interpolate between v1 and v2.

func Vslerpconst Uses

func Vslerpconst(v1, v2 Vect, a float64) Vect

Spherical linearly interpolate between v1 towards v2 by no more than angle a radians

func Vsub Uses

func Vsub(v1, v2 Vect) Vect

Subtract two vectors.

func Vunrotate Uses

func Vunrotate(v1, v2 Vect) Vect

Inverse of Vrotate().

Package cp imports 4 packages (graph). Updated 2016-07-26. Refresh now. Tools for package owners.