Documentation
¶
Index ¶
- Constants
- Variables
- func AbsInt(v int) int
- func AddType(createFcn ContactCreateFcn, destroyFcn ContactDestroyFcn, ...)
- func AngularStiffness(stiffness *float64, damping *float64, frequencyHertz float64, ...)
- func ChainAndCircleContact_Destroy(contact IContact)
- func ChainAndPolygonContact_Destroy(contact IContact)
- func CircleContact_Destroy(contact IContact)
- func ClipSegmentToLine(vOut []ClipVertex, vIn []ClipVertex, normal Vec2, offset float64, ...) int
- func CollideEdgeAndPolygon(manifold *Manifold, edgeA *EdgeShape, xfA Transform, polygonB *PolygonShape, ...)
- func ComputeEdgeSeparation(polygonB tempPolygon, v1 Vec2, normal1 Vec2) ePAxis
- func ComputePolygonSeparation(polygonB tempPolygon, v1 Vec2, v2 Vec2) ePAxis
- func ContactDestroy(contact IContact)
- func ContactInitializeRegisters()
- func ContactUpdate(contact IContact, listener IContactListener)
- func Distance(output *DistanceOutput, cache *simplexCache, input *DistanceInput)
- func EdgeAndCircleContact_Destroy(contact IContact)
- func EdgeAndPolygonContact_Destroy(contact IContact)
- func FloatClamp(a, low, high float64) float64
- func GetPointStates(state1 *[maxManifoldPoints]uint8, state2 *[maxManifoldPoints]uint8, ...)
- func InvSqrt(x float64) float64
- func IsPowerOfTwo(x uint32) bool
- func IsProjectedPointOnLineSegment(v1 Vec2, v2 Vec2, p Vec2) bool
- func IsValid(x float64) bool
- func JointDestroy(joint IJoint)
- func LinearStiffness(stiffness *float64, damping *float64, frequencyHertz float64, ...)
- func MakeSimplexCache() simplexCache
- func MixFriction(friction1, friction2 float64) float64
- func MixRestitution(restitution1, restitution2 float64) float64
- func MixRestitutionThreshold(threshold1, threshold2 float64) float64
- func NextPowerOfTwo(x uint32) uint32
- func PolygonAndCircleContact_Destroy(contact IContact)
- func PolygonContact_Destroy(contact IContact)
- func ShapeCast(output *ShapeCastOutput, input *ShapeCastInput) bool
- func TestOverlapBoundingBoxes(a, b AABB) bool
- func TestOverlapShapes(shapeA IShape, indexA int, shapeB IShape, indexB int, xfA Transform, ...) bool
- func TimeOfImpact(output *TOIOutput, input *TOIInput)
- func ValidateHull(hull *Hull) bool
- func Vec2Cross(a, b Vec2) float64
- func Vec2Distance(a, b Vec2) float64
- func Vec2DistanceSquared(a, b Vec2) float64
- func Vec2Dot(a, b Vec2) float64
- func Vec2Equals(a, b Vec2) bool
- func Vec2NotEquals(a, b Vec2) bool
- func Vec3Dot(a, b Vec3) float64
- type AABB
- func (bb *AABB) CombineInPlace(aabb AABB)
- func (bb *AABB) CombineTwoInPlace(aabb1, aabb2 AABB)
- func (bb AABB) Contains(aabb AABB) bool
- func (bb AABB) GetCenter() Vec2
- func (bb AABB) GetExtents() Vec2
- func (bb AABB) GetPerimeter() float64
- func (bb AABB) IsValid() bool
- func (bb AABB) RayCast(output *RayCastOutput, input RayCastInput) bool
- type Body
- func (body *Body) Advance(alpha float64)
- func (body Body) Angle() float64
- func (body *Body) ApplyAngularImpulse(impulse float64, wake bool)
- func (body *Body) ApplyForce(force Vec2, point Vec2, wake bool)
- func (body *Body) ApplyForceToCenter(force Vec2, wake bool)
- func (body *Body) ApplyLinearImpulse(impulse Vec2, point Vec2, wake bool)
- func (body *Body) ApplyLinearImpulseToCenter(impulse Vec2, wake bool)
- func (body *Body) ApplyTorque(torque float64, wake bool)
- func (body Body) ContactList() *ContactEdge
- func (body *Body) CreateFixture(shape IShape, density float64) *Fixture
- func (body *Body) CreateFixtureFromDef(def *FixtureDef) *Fixture
- func (body *Body) DestroyFixture(fixture *Fixture)
- func (body *Body) Dump()
- func (body Body) FixtureList() *Fixture
- func (body Body) GetAngularDamping() float64
- func (body Body) GetAngularVelocity() float64
- func (body Body) GetWorld() *World
- func (body Body) GravityScale() float64
- func (body Body) Inertia() float64
- func (body Body) IsAwake() bool
- func (body Body) IsBullet() bool
- func (body Body) IsDynamic() bool
- func (body Body) IsEnabled() bool
- func (body Body) IsFixedRotation() bool
- func (body Body) IsKinematic() bool
- func (body Body) IsSleepingAllowed() bool
- func (body Body) IsStatic() bool
- func (body Body) JointList() *JointEdge
- func (body Body) LinearDamping() float64
- func (body Body) LinearVelocity() Vec2
- func (body Body) LinearVelocityFromLocalPoint(localPoint Vec2) Vec2
- func (body Body) LinearVelocityFromWorldPoint(worldPoint Vec2) Vec2
- func (body Body) LocalCenter() Vec2
- func (body Body) LocalPoint(worldPoint Vec2) Vec2
- func (body Body) LocalVector(worldVector Vec2) Vec2
- func (body Body) Mass() float64
- func (body Body) MassData() MassData
- func (body Body) Next() *Body
- func (body Body) Position() Vec2
- func (body *Body) ResetMassData()
- func (body *Body) SetActive(flag bool)
- func (body *Body) SetAngularDamping(angularDamping float64)
- func (body *Body) SetAngularVelocity(w float64)
- func (body *Body) SetAwake(flag bool)
- func (body *Body) SetBullet(flag bool)
- func (body *Body) SetFixedRotation(flag bool)
- func (body *Body) SetGravityScale(scale float64)
- func (body *Body) SetLinearDamping(linearDamping float64)
- func (body *Body) SetLinearVelocity(v Vec2)
- func (body *Body) SetMassData(massData *MassData)
- func (body *Body) SetSleepingAllowed(flag bool)
- func (body *Body) SetTransform(position Vec2, angle float64)
- func (body *Body) SetType(bt BodyType)
- func (body Body) ShouldCollide(other *Body) bool
- func (body *Body) SynchronizeFixtures()
- func (body *Body) SynchronizeTransform()
- func (body Body) Transform() Transform
- func (body Body) Type() BodyType
- func (body Body) WorldCenter() Vec2
- func (body Body) WorldPoint(localPoint Vec2) Vec2
- func (body Body) WorldVector(localVector Vec2) Vec2
- type BodyDef
- type BodyType
- type BroadPhase
- func (bp *BroadPhase) BufferMove(proxyId int)
- func (bp *BroadPhase) CreateProxy(aabb AABB, userData any) int
- func (bp *BroadPhase) DestroyProxy(proxyId int)
- func (bp BroadPhase) GetFatAABB(proxyId int) AABB
- func (bp BroadPhase) GetProxyCount() int
- func (bp BroadPhase) GetTreeBalance() int
- func (bp BroadPhase) GetTreeHeight() int
- func (bp BroadPhase) GetTreeQuality() float64
- func (bp BroadPhase) GetUserData(proxyId int) any
- func (bp *BroadPhase) MoveProxy(proxyId int, aabb AABB, displacement Vec2)
- func (bp *BroadPhase) Query(callback TreeQueryCallback, aabb AABB)
- func (bp *BroadPhase) QueryCallback(proxyId int) bool
- func (bp *BroadPhase) RayCast(callback TreeRayCastCallback, input RayCastInput)
- func (bp *BroadPhase) ShiftOrigin(newOrigin Vec2)
- func (bp BroadPhase) TestOverlap(proxyIdA int, proxyIdB int) bool
- func (bp *BroadPhase) TouchProxy(proxyId int)
- func (bp *BroadPhase) UnBufferMove(proxyId int)
- func (bp *BroadPhase) UpdatePairs(addPairCallback BroadPhaseAddPairCallback)
- type BroadPhaseAddPairCallback
- type BroadPhaseQueryCallback
- type ChainAndCircleContact
- type ChainAndPolygonContact
- type ChainShape
- func (chain *ChainShape) Clear()
- func (chain ChainShape) Clone() IShape
- func (chain ChainShape) ComputeAABB(aabb *AABB, xf Transform, childIndex int)
- func (chain ChainShape) ComputeMass(massData *MassData, density float64)
- func (chain *ChainShape) CreateChain(vertices []Vec2, count int, prevVertex Vec2, nextVertex Vec2)
- func (chain *ChainShape) CreateLoop(vertices []Vec2, count int)
- func (chain *ChainShape) Destroy()
- func (chain ChainShape) GetChildCount() int
- func (chain ChainShape) GetChildEdge(edge *EdgeShape, index int)
- func (chain ChainShape) RayCast(output *RayCastOutput, input RayCastInput, xf Transform, childIndex int) bool
- func (chain ChainShape) TestPoint(xf Transform, p Vec2) bool
- type CircleContact
- type CircleShape
- func (shape CircleShape) Clone() IShape
- func (shape CircleShape) ComputeAABB(aabb *AABB, transform Transform, childIndex int)
- func (shape CircleShape) ComputeMass(massData *MassData, density float64)
- func (shape CircleShape) Destroy()
- func (shape CircleShape) GetChildCount() int
- func (shape CircleShape) RayCast(output *RayCastOutput, input RayCastInput, transform Transform, childIndex int) bool
- func (shape CircleShape) TestPoint(transform Transform, p Vec2) bool
- type ClipVertex
- type Contact
- func (contact *Contact) FlagForFiltering()
- func (contact Contact) GetChildIndexA() int
- func (contact Contact) GetChildIndexB() int
- func (contact Contact) GetFixtureA() *Fixture
- func (contact Contact) GetFixtureB() *Fixture
- func (contact Contact) GetFlags() uint32
- func (contact Contact) GetFriction() float64
- func (contact Contact) GetManifold() *Manifold
- func (contact Contact) GetNext() IContact
- func (contact Contact) GetNodeA() *ContactEdge
- func (contact Contact) GetNodeB() *ContactEdge
- func (contact Contact) GetPrev() IContact
- func (contact Contact) GetRestitution() float64
- func (contact Contact) GetRestitutionThreshold() float64
- func (contact Contact) GetTOI() float64
- func (contact Contact) GetTOICount() int
- func (contact Contact) GetTangentSpeed() float64
- func (contact Contact) GetWorldManifold(worldManifold *WorldManifold)
- func (contact Contact) IsEnabled() bool
- func (contact Contact) IsTouching() bool
- func (contact *Contact) ResetFriction()
- func (contact *Contact) ResetRestitution()
- func (contact *Contact) ResetRestitutionThreshold()
- func (contact *Contact) SetChildIndexA(index int)
- func (contact *Contact) SetChildIndexB(index int)
- func (contact *Contact) SetEnabled(flag bool)
- func (contact *Contact) SetFixtureA(fixture *Fixture)
- func (contact *Contact) SetFixtureB(fixture *Fixture)
- func (contact *Contact) SetFlags(flags uint32)
- func (contact *Contact) SetFriction(friction float64)
- func (contact *Contact) SetManifold(manifold *Manifold)
- func (contact *Contact) SetNext(next IContact)
- func (contact *Contact) SetNodeA(node *ContactEdge)
- func (contact *Contact) SetNodeB(node *ContactEdge)
- func (contact *Contact) SetPrev(prev IContact)
- func (contact *Contact) SetRestitution(restitution float64)
- func (contact *Contact) SetRestitutionThreshold(threshold float64)
- func (contact *Contact) SetTOI(toi float64)
- func (contact *Contact) SetTOICount(toiCount int)
- func (contact *Contact) SetTangentSpeed(speed float64)
- type ContactCreateFcn
- type ContactDestroyFcn
- type ContactEdge
- type ContactFeature
- type ContactFilter
- type ContactID
- type ContactImpulse
- type ContactManager
- type ContactPositionConstraint
- type ContactRegister
- type ContactSolver
- func (solver *ContactSolver) Destroy()
- func (solver *ContactSolver) InitializeVelocityConstraints()
- func (solver *ContactSolver) SolvePositionConstraints() bool
- func (solver *ContactSolver) SolveTOIPositionConstraints(toiIndexA int, toiIndexB int) bool
- func (solver *ContactSolver) SolveVelocityConstraints()
- func (solver *ContactSolver) StoreImpulses()
- func (solver *ContactSolver) WarmStart()
- type ContactSolverDef
- type ContactVelocityConstraint
- type DistanceInput
- type DistanceJoint
- func (joint DistanceJoint) Dump()
- func (joint DistanceJoint) GetAnchorA() Vec2
- func (joint DistanceJoint) GetAnchorB() Vec2
- func (joint DistanceJoint) GetCurrentLength() float64
- func (joint DistanceJoint) GetDamping() float64
- func (joint DistanceJoint) GetLength() float64
- func (joint DistanceJoint) GetLocalAnchorA() Vec2
- func (joint DistanceJoint) GetLocalAnchorB() Vec2
- func (joint DistanceJoint) GetMaxLength() float64
- func (joint DistanceJoint) GetMinLength() float64
- func (joint DistanceJoint) GetReactionForce(inv_dt float64) Vec2
- func (joint DistanceJoint) GetReactionTorque(inv_dt float64) float64
- func (joint DistanceJoint) GetStiffness() float64
- func (joint *DistanceJoint) InitVelocityConstraints(data SolverData)
- func (joint *DistanceJoint) SetDamping(damping float64)
- func (joint *DistanceJoint) SetLength(length float64) float64
- func (joint *DistanceJoint) SetMaxLength(maxLength float64) float64
- func (joint *DistanceJoint) SetMinLength(minLength float64) float64
- func (joint *DistanceJoint) SetStiffness(stiffness float64)
- func (joint *DistanceJoint) SolvePositionConstraints(data SolverData) bool
- func (joint *DistanceJoint) SolveVelocityConstraints(data SolverData)
- type DistanceJointDef
- type DistanceOutput
- type DistanceProxy
- type DynamicTree
- func (tree *DynamicTree) AllocateNode() int
- func (tree *DynamicTree) Balance(iA int) int
- func (tree DynamicTree) ClearMoved(proxyId int)
- func (tree DynamicTree) ComputeHeight(nodeId int) int
- func (tree DynamicTree) ComputeTotalHeight() int
- func (tree *DynamicTree) CreateProxy(aabb AABB, userData any) int
- func (tree *DynamicTree) DestroyProxy(proxyId int)
- func (tree *DynamicTree) FreeNode(nodeId int)
- func (tree DynamicTree) GetAreaRatio() float64
- func (tree DynamicTree) GetFatAABB(proxyId int) AABB
- func (tree DynamicTree) GetHeight() int
- func (tree DynamicTree) GetMaxBalance() int
- func (tree DynamicTree) GetUserData(proxyId int) any
- func (tree *DynamicTree) InsertLeaf(leaf int)
- func (tree *DynamicTree) MoveProxy(proxyId int, aabb AABB, displacement Vec2) bool
- func (tree *DynamicTree) Query(queryCallback TreeQueryCallback, aabb AABB)
- func (tree DynamicTree) RayCast(rayCastCallback TreeRayCastCallback, input RayCastInput)
- func (tree *DynamicTree) RebuildBottomUp()
- func (tree *DynamicTree) RemoveLeaf(leaf int)
- func (tree *DynamicTree) ShiftOrigin(newOrigin Vec2)
- func (tree DynamicTree) Validate()
- func (tree DynamicTree) ValidateMetrics(index int)
- func (tree DynamicTree) ValidateStructure(index int)
- func (tree DynamicTree) WasMoved(proxyId int) bool
- type EdgeAndCircleContact
- type EdgeAndPolygonContact
- type EdgeShape
- func (edge EdgeShape) Clone() IShape
- func (edge EdgeShape) ComputeAABB(aabb *AABB, xf Transform, childIndex int)
- func (edge EdgeShape) ComputeMass(massData *MassData, density float64)
- func (edge *EdgeShape) Destroy()
- func (edge EdgeShape) GetChildCount() int
- func (edge EdgeShape) RayCast(output *RayCastOutput, input RayCastInput, xf Transform, childIndex int) bool
- func (edge *EdgeShape) SetOneSided(v0 Vec2, v1 Vec2, v2 Vec2, v3 Vec2)
- func (edge *EdgeShape) SetTwoSided(v1 Vec2, v2 Vec2)
- func (edge EdgeShape) TestPoint(xf Transform, p Vec2) bool
- type Filter
- type Fixture
- func (fix Fixture) AABB(childIndex int) AABB
- func (fix Fixture) Body() *Body
- func (fix *Fixture) Create(body *Body, def *FixtureDef)
- func (fix *Fixture) CreateProxies(broadPhase *BroadPhase, xf Transform)
- func (fix Fixture) Density() float64
- func (fix *Fixture) Destroy()
- func (fix *Fixture) DestroyProxies(broadPhase *BroadPhase)
- func (fix *Fixture) Dump(bodyIndex int)
- func (fix Fixture) FilterData() Filter
- func (fix Fixture) Friction() float64
- func (fix Fixture) IsSensor() bool
- func (fix Fixture) MassData(massData *MassData)
- func (fix Fixture) Next() *Fixture
- func (fix Fixture) RayCast(output *RayCastOutput, input RayCastInput, childIndex int) bool
- func (fix *Fixture) Refilter()
- func (fix Fixture) Restitution() float64
- func (fix Fixture) RestitutionThreshold() float64
- func (fix *Fixture) SetDensity(density float64)
- func (fix *Fixture) SetFilterData(filter Filter)
- func (fix *Fixture) SetFriction(friction float64)
- func (fix *Fixture) SetRestitution(restitution float64)
- func (fix *Fixture) SetRestitutionThreshold(threshold float64)
- func (fix *Fixture) SetSensor(sensor bool)
- func (fix *Fixture) SetUserData(data any)
- func (fix Fixture) Shape() IShape
- func (fix *Fixture) Synchronize(broadPhase *BroadPhase, transform1 Transform, transform2 Transform)
- func (fix Fixture) TestPoint(p Vec2) bool
- func (fix Fixture) Type() ShapeType
- func (fix Fixture) UserData() any
- type FixtureDef
- type FixtureProxy
- type FrictionJoint
- func (joint *FrictionJoint) Dump()
- func (joint FrictionJoint) GetAnchorA() Vec2
- func (joint FrictionJoint) GetAnchorB() Vec2
- func (joint FrictionJoint) GetLocalAnchorA() Vec2
- func (joint FrictionJoint) GetLocalAnchorB() Vec2
- func (joint FrictionJoint) GetMaxForce() float64
- func (joint FrictionJoint) GetMaxTorque() float64
- func (joint FrictionJoint) GetReactionForce(inv_dt float64) Vec2
- func (joint FrictionJoint) GetReactionTorque(inv_dt float64) float64
- func (joint *FrictionJoint) InitVelocityConstraints(data SolverData)
- func (joint *FrictionJoint) SetMaxForce(force float64)
- func (joint *FrictionJoint) SetMaxTorque(torque float64)
- func (joint *FrictionJoint) SolvePositionConstraints(data SolverData) bool
- func (joint *FrictionJoint) SolveVelocityConstraints(data SolverData)
- type FrictionJointDef
- type GearJoint
- func (joint *GearJoint) Dump()
- func (joint GearJoint) GetAnchorA() Vec2
- func (joint GearJoint) GetAnchorB() Vec2
- func (joint GearJoint) GetJoint1() IJoint
- func (joint GearJoint) GetJoint2() IJoint
- func (joint GearJoint) GetRatio() float64
- func (joint GearJoint) GetReactionForce(inv_dt float64) Vec2
- func (joint GearJoint) GetReactionTorque(inv_dt float64) float64
- func (joint *GearJoint) InitVelocityConstraints(data SolverData)
- func (joint *GearJoint) SetRatio(ratio float64)
- func (joint *GearJoint) SolvePositionConstraints(data SolverData) bool
- func (joint *GearJoint) SolveVelocityConstraints(data SolverData)
- type GearJointDef
- type Hull
- type IContact
- func ChainAndCircleContact_Create(fixtureA *Fixture, indexA int, fixtureB *Fixture, indexB int) IContact
- func ChainAndPolygonContact_Create(fixtureA *Fixture, indexA int, fixtureB *Fixture, indexB int) IContact
- func CircleContact_Create(fixtureA *Fixture, indexA int, fixtureB *Fixture, indexB int) IContact
- func ContactFactory(fixtureA *Fixture, indexA int, fixtureB *Fixture, indexB int) IContact
- func EdgeAndCircleContact_Create(fixtureA *Fixture, indexA int, fixtureB *Fixture, indexB int) IContact
- func EdgeAndPolygonContact_Create(fixtureA *Fixture, indexA int, fixtureB *Fixture, indexB int) IContact
- func PolygonAndCircleContact_Create(fixtureA *Fixture, indexA int, fixtureB *Fixture, indexB int) IContact
- func PolygonContact_Create(fixtureA *Fixture, indexA int, fixtureB *Fixture, indexB int) IContact
- type IContactFilter
- type IContactListener
- type IDestructionListener
- type IJoint
- type IJointDef
- type IShape
- type Island
- func (island *Island) Add(joint IJoint)
- func (island *Island) AddBody(body *Body)
- func (island *Island) AddContact(contact IContact)
- func (island *Island) Clear()
- func (island *Island) Destroy()
- func (island *Island) Report(constraints []ContactVelocityConstraint)
- func (island *Island) Solve(profile *Profile, step TimeStep, gravity Vec2, allowSleep bool)
- func (island *Island) SolveTOI(subStep TimeStep, toiIndexA int, toiIndexB int)
- type Jacobian
- type Joint
- func (j *Joint) Destroy()
- func (j Joint) Dump()
- func (j Joint) GetBodyA() *Body
- func (j Joint) GetBodyB() *Body
- func (j Joint) GetEdgeA() *JointEdge
- func (j Joint) GetEdgeB() *JointEdge
- func (j Joint) GetIndex() int
- func (j Joint) GetIslandFlag() bool
- func (j Joint) GetNext() IJoint
- func (j Joint) GetPrev() IJoint
- func (j Joint) GetType() JointType
- func (j Joint) GetUserData() any
- func (j *Joint) InitVelocityConstraints(data SolverData)
- func (j Joint) IsCollideConnected() bool
- func (j Joint) IsEnabled() bool
- func (j *Joint) SetBodyA(body *Body)
- func (j *Joint) SetBodyB(body *Body)
- func (j *Joint) SetCollideConnected(flag bool)
- func (j *Joint) SetEdgeA(edge *JointEdge)
- func (j *Joint) SetEdgeB(edge *JointEdge)
- func (j *Joint) SetIndex(index int)
- func (j *Joint) SetIslandFlag(flag bool)
- func (j *Joint) SetNext(next IJoint)
- func (j *Joint) SetPrev(prev IJoint)
- func (j *Joint) SetType(t JointType)
- func (j *Joint) SetUserData(data any)
- func (j Joint) ShiftOrigin(newOrigin Vec2)
- func (j *Joint) SolvePositionConstraints(data SolverData) bool
- func (j *Joint) SolveVelocityConstraints(data SolverData)
- type JointDef
- func (def JointDef) GetBodyA() *Body
- func (def JointDef) GetBodyB() *Body
- func (def JointDef) GetType() JointType
- func (def JointDef) GetUserData() any
- func (def JointDef) IsCollideConnected() bool
- func (def *JointDef) SetBodyA(body *Body)
- func (def *JointDef) SetBodyB(body *Body)
- func (def *JointDef) SetCollideConnected(flag bool)
- func (def *JointDef) SetType(t JointType)
- func (def *JointDef) SetUserData(userdata any)
- type JointEdge
- type JointType
- type Manifold
- type ManifoldPoint
- type ManifoldType
- type MassData
- type Mat22
- func MakeMat22() Mat22
- func MakeMat22FromColumns(c1, c2 Vec2) Mat22
- func MakeMat22FromScalars(a11, a12, a21, a22 float64) Mat22
- func Mat22Abs(A Mat22) Mat22
- func Mat22Add(A, B Mat22) Mat22
- func Mat22Mul(A, B Mat22) Mat22
- func Mat22MulT(A, B Mat22) Mat22
- func NewMat22() *Mat22
- func NewMat22FromColumns(c1, c2 Vec2) *Mat22
- func NewMat22FromScalars(a11, a12, a21, a22 float64) *Mat22
- type Mat33
- type MotorJoint
- func (joint *MotorJoint) Dump()
- func (joint MotorJoint) GetAnchorA() Vec2
- func (joint MotorJoint) GetAnchorB() Vec2
- func (joint MotorJoint) GetAngularOffset() float64
- func (joint MotorJoint) GetCorrectionFactor() float64
- func (joint MotorJoint) GetLinearOffset() Vec2
- func (joint MotorJoint) GetMaxForce() float64
- func (joint MotorJoint) GetMaxTorque() float64
- func (joint MotorJoint) GetReactionForce(inv_dt float64) Vec2
- func (joint MotorJoint) GetReactionTorque(inv_dt float64) float64
- func (joint *MotorJoint) InitVelocityConstraints(data SolverData)
- func (joint *MotorJoint) SetAngularOffset(angularOffset float64)
- func (joint *MotorJoint) SetCorrectionFactor(factor float64)
- func (joint *MotorJoint) SetLinearOffset(linearOffset Vec2)
- func (joint *MotorJoint) SetMaxForce(force float64)
- func (joint *MotorJoint) SetMaxTorque(torque float64)
- func (joint *MotorJoint) SolvePositionConstraints(data SolverData) bool
- func (joint *MotorJoint) SolveVelocityConstraints(data SolverData)
- type MotorJointDef
- type MouseJoint
- func (def *MouseJoint) Dump()
- func (joint MouseJoint) GetAnchorA() Vec2
- func (joint MouseJoint) GetAnchorB() Vec2
- func (joint MouseJoint) GetDamping() float64
- func (joint MouseJoint) GetMaxForce() float64
- func (joint MouseJoint) GetReactionForce(inv_dt float64) Vec2
- func (joint MouseJoint) GetReactionTorque(inv_dt float64) float64
- func (joint MouseJoint) GetStiffness() float64
- func (joint MouseJoint) GetTarget() Vec2
- func (joint *MouseJoint) InitVelocityConstraints(data SolverData)
- func (joint *MouseJoint) SetDamping(damping float64)
- func (joint *MouseJoint) SetMaxForce(force float64)
- func (joint *MouseJoint) SetStiffness(stiffness float64)
- func (joint *MouseJoint) SetTarget(target Vec2)
- func (joint *MouseJoint) ShiftOrigin(newOrigin Vec2)
- func (joint *MouseJoint) SolvePositionConstraints(data SolverData) bool
- func (joint *MouseJoint) SolveVelocityConstraints(data SolverData)
- type MouseJointDef
- type Pair
- type PairByLessThan
- type PolygonAndCircleContact
- type PolygonContact
- type PolygonShape
- func (poly PolygonShape) Clone() IShape
- func (poly PolygonShape) ComputeAABB(aabb *AABB, xf Transform, childIndex int)
- func (poly PolygonShape) ComputeMass(massData *MassData, density float64)
- func (edge *PolygonShape) Destroy()
- func (poly PolygonShape) GetChildCount() int
- func (poly *PolygonShape) GetVertex(index int) *Vec2
- func (poly PolygonShape) RayCast(output *RayCastOutput, input RayCastInput, xf Transform, childIndex int) bool
- func (poly *PolygonShape) Set(vertices []Vec2, count int) bool
- func (poly *PolygonShape) SetAsBox(halfWidth float64, halfHeight float64)
- func (poly *PolygonShape) SetAsBoxFromCenterAndAngle(hx float64, hy float64, center Vec2, angle float64)
- func (poly *PolygonShape) SetAsHull(hull Hull)
- func (poly PolygonShape) TestPoint(xf Transform, p Vec2) bool
- func (poly PolygonShape) Validate() bool
- type PositionSolverManifold
- type PrismaticJoint
- func (joint *PrismaticJoint) Dump()
- func (joint *PrismaticJoint) EnableLimit(flag bool)
- func (joint *PrismaticJoint) EnableMotor(flag bool)
- func (joint PrismaticJoint) GetAnchorA() Vec2
- func (joint PrismaticJoint) GetAnchorB() Vec2
- func (joint PrismaticJoint) GetJointSpeed() float64
- func (joint PrismaticJoint) GetJointTranslation() float64
- func (joint PrismaticJoint) GetLocalAnchorA() Vec2
- func (joint PrismaticJoint) GetLocalAnchorB() Vec2
- func (joint PrismaticJoint) GetLocalAxisA() Vec2
- func (joint PrismaticJoint) GetLowerLimit() float64
- func (joint PrismaticJoint) GetMaxMotorForce() float64
- func (joint PrismaticJoint) GetMotorForce(inv_dt float64) float64
- func (joint PrismaticJoint) GetMotorSpeed() float64
- func (joint PrismaticJoint) GetReactionForce(inv_dt float64) Vec2
- func (joint PrismaticJoint) GetReactionTorque(inv_dt float64) float64
- func (joint PrismaticJoint) GetReferenceAngle() float64
- func (joint PrismaticJoint) GetUpperLimit() float64
- func (joint *PrismaticJoint) InitVelocityConstraints(data SolverData)
- func (joint PrismaticJoint) IsLimitEnabled() bool
- func (joint PrismaticJoint) IsMotorEnabled() bool
- func (joint *PrismaticJoint) SetLimits(lower float64, upper float64)
- func (joint *PrismaticJoint) SetMaxMotorForce(force float64)
- func (joint *PrismaticJoint) SetMotorSpeed(speed float64)
- func (joint *PrismaticJoint) SolvePositionConstraints(data SolverData) bool
- func (joint *PrismaticJoint) SolveVelocityConstraints(data SolverData)
- type PrismaticJointDef
- type Profile
- type PulleyJoint
- func (joint *PulleyJoint) Dump()
- func (joint PulleyJoint) GetAnchorA() Vec2
- func (joint PulleyJoint) GetAnchorB() Vec2
- func (joint PulleyJoint) GetCurrentLengthA() float64
- func (joint PulleyJoint) GetCurrentLengthB() float64
- func (joint PulleyJoint) GetGroundAnchorA() Vec2
- func (joint PulleyJoint) GetGroundAnchorB() Vec2
- func (joint PulleyJoint) GetLengthA() float64
- func (joint PulleyJoint) GetLengthB() float64
- func (joint PulleyJoint) GetRatio() float64
- func (joint PulleyJoint) GetReactionForce(inv_dt float64) Vec2
- func (joint PulleyJoint) GetReactionTorque(inv_dt float64) float64
- func (joint *PulleyJoint) InitVelocityConstraints(data SolverData)
- func (joint *PulleyJoint) ShiftOrigin(newOrigin Vec2)
- func (joint *PulleyJoint) SolvePositionConstraints(data SolverData) bool
- func (joint *PulleyJoint) SolveVelocityConstraints(data SolverData)
- type PulleyJointDef
- type RayCastInput
- type RayCastOutput
- type RaycastCallback
- type RevoluteJoint
- func (joint *RevoluteJoint) Dump()
- func (joint *RevoluteJoint) EnableLimit(flag bool)
- func (joint *RevoluteJoint) EnableMotor(flag bool)
- func (joint RevoluteJoint) GetAnchorA() Vec2
- func (joint RevoluteJoint) GetAnchorB() Vec2
- func (joint RevoluteJoint) GetJointAngle() float64
- func (joint *RevoluteJoint) GetJointSpeed() float64
- func (joint RevoluteJoint) GetLocalAnchorA() Vec2
- func (joint RevoluteJoint) GetLocalAnchorB() Vec2
- func (joint RevoluteJoint) GetLowerLimit() float64
- func (joint RevoluteJoint) GetMaxMotorTorque() float64
- func (joint RevoluteJoint) GetMotorSpeed() float64
- func (joint RevoluteJoint) GetMotorTorque(inv_dt float64) float64
- func (joint RevoluteJoint) GetReactionForce(inv_dt float64) Vec2
- func (joint RevoluteJoint) GetReactionTorque(inv_dt float64) float64
- func (joint RevoluteJoint) GetReferenceAngle() float64
- func (joint RevoluteJoint) GetUpperLimit() float64
- func (joint *RevoluteJoint) InitVelocityConstraints(data SolverData)
- func (joint RevoluteJoint) IsLimitEnabled() bool
- func (joint RevoluteJoint) IsMotorEnabled() bool
- func (joint *RevoluteJoint) SetLimits(lower float64, upper float64)
- func (joint *RevoluteJoint) SetMaxMotorTorque(torque float64)
- func (joint *RevoluteJoint) SetMotorSpeed(speed float64)
- func (joint *RevoluteJoint) SolvePositionConstraints(data SolverData) bool
- func (joint *RevoluteJoint) SolveVelocityConstraints(data SolverData)
- type RevoluteJointDef
- type Rope
- func (rope *Rope) ApplyBendForces(dt float64)
- func (rope *Rope) Create(def *RopeDef)
- func (rope *Rope) Destroy()
- func (rope Rope) GetVertexCount() int
- func (rope Rope) GetVertices() []Vec2
- func (rope *Rope) Reset(position Vec2)
- func (rope *Rope) SetTuning(tuning RopeTuning)
- func (rope *Rope) SolveBend_PBD_Angle()
- func (rope *Rope) SolveBend_PBD_Distance()
- func (rope *Rope) SolveBend_PBD_Height()
- func (rope *Rope) SolveBend_PBD_Triangle()
- func (rope *Rope) SolveBend_XPBD_Angle(dt float64)
- func (rope *Rope) SolveStretch_PBD()
- func (rope *Rope) SolveStretch_XPBD(dt float64)
- func (rope *Rope) Step(dt float64, iterations int, position Vec2)
- type RopeBend
- type RopeDef
- type RopeStretch
- type RopeTuning
- type Rot
- type SeparationFunction
- func (sepfunc *SeparationFunction) Evaluate(indexA int, indexB int, t float64) float64
- func (sepfunc *SeparationFunction) FindMinSeparation(indexA *int, indexB *int, t float64) float64
- func (sepfunc *SeparationFunction) Initialize(cache *simplexCache, proxyA *DistanceProxy, sweepA Sweep, ...) float64
- type Shape
- type ShapeCastInput
- type ShapeCastOutput
- type ShapeType
- type Simplex
- func (simplex Simplex) GetClosestPoint() Vec2
- func (simplex Simplex) GetMetric() float64
- func (simplex Simplex) GetSearchDirection() Vec2
- func (simplex Simplex) GetWitnessPoints(pA *Vec2, pB *Vec2)
- func (simplex *Simplex) ReadCache(cache *simplexCache, proxyA *DistanceProxy, transformA Transform, ...)
- func (simplex *Simplex) Solve2()
- func (simplex *Simplex) Solve3()
- func (simplex Simplex) WriteCache(cache *simplexCache)
- type SimplexVertex
- type SolverData
- type Sweep
- type TOIInput
- type TOIOutput
- type TimeStep
- type Timer
- type ToiOutputState
- type Transform
- func MakeTransform() Transform
- func MakeTransformByPositionAndRotation(position Vec2, rotation Rot) Transform
- func NewTransform() *Transform
- func NewTransformByPositionAndRotation(position Vec2, rotation Rot) *Transform
- func TransformMul(A, B Transform) Transform
- func TransformMulT(A, B Transform) Transform
- type TreeNode
- type TreeQueryCallback
- type TreeRayCastCallback
- type Vec2
- func ComputeCentroid(vs []Vec2, count int) Vec2
- func NewVec2(xIn, yIn float64) *Vec2
- func ProjectPointOnLine(v1 Vec2, v2 Vec2, p Vec2) Vec2
- func RotVec2Mul(q Rot, v Vec2) Vec2
- func RotVec2MulT(q Rot, v Vec2) Vec2
- func TransformVec2Mul(T Transform, v Vec2) Vec2
- func TransformVec2MulT(T Transform, v Vec2) Vec2
- func Vec2Abs(a Vec2) Vec2
- func Vec2Add(a, b Vec2) Vec2
- func Vec2Clamp(a, low, high Vec2) Vec2
- func Vec2CrossScalarVector(s float64, a Vec2) Vec2
- func Vec2CrossVectorScalar(a Vec2, s float64) Vec2
- func Vec2Mat22Mul(A Mat22, v Vec2) Vec2
- func Vec2Mat22MulT(A Mat22, v Vec2) Vec2
- func Vec2Max(a, b Vec2) Vec2
- func Vec2Min(a, b Vec2) Vec2
- func Vec2Mul22(A Mat33, v Vec2) Vec2
- func Vec2MulScalar(s float64, a Vec2) Vec2
- func Vec2Sub(a, b Vec2) Vec2
- func (v Vec2) IsValid() bool
- func (v Vec2) Length() float64
- func (v Vec2) LengthSquared() float64
- func (v *Vec2) Normalize() float64
- func (v Vec2) OperatorIndexGet(i int) float64
- func (v *Vec2) OperatorIndexSet(i int, value float64)
- func (v *Vec2) OperatorMinusInplace(other Vec2)
- func (v Vec2) OperatorNegate() Vec2
- func (v *Vec2) OperatorPlusInplace(other Vec2)
- func (v *Vec2) OperatorScalarMulInplace(a float64)
- func (v *Vec2) Set(x, y float64)
- func (v *Vec2) SetZero()
- func (v Vec2) Skew() Vec2
- type Vec3
- type VelocityConstraintPoint
- type WeldJoint
- func (joint *WeldJoint) Dump()
- func (joint WeldJoint) GetAnchorA() Vec2
- func (joint WeldJoint) GetAnchorB() Vec2
- func (joint WeldJoint) GetDamping() float64
- func (joint WeldJoint) GetLocalAnchorA() Vec2
- func (joint WeldJoint) GetLocalAnchorB() Vec2
- func (joint WeldJoint) GetReactionForce(inv_dt float64) Vec2
- func (joint WeldJoint) GetReactionTorque(inv_dt float64) float64
- func (joint WeldJoint) GetReferenceAngle() float64
- func (joint WeldJoint) GetStiffness() float64
- func (joint *WeldJoint) InitVelocityConstraints(data SolverData)
- func (joint *WeldJoint) SetDamping(damping float64)
- func (joint *WeldJoint) SetStiffness(stiffness float64)
- func (joint *WeldJoint) SolvePositionConstraints(data SolverData) bool
- func (joint *WeldJoint) SolveVelocityConstraints(data SolverData)
- type WeldJointDef
- type WheelJoint
- func (joint *WheelJoint) Dump()
- func (joint WheelJoint) EnableLimit(flag bool)
- func (joint *WheelJoint) EnableMotor(flag bool)
- func (joint WheelJoint) GetAnchorA() Vec2
- func (joint WheelJoint) GetAnchorB() Vec2
- func (joint WheelJoint) GetDamping() float64
- func (joint WheelJoint) GetJointAngle() float64
- func (joint WheelJoint) GetJointAngularSpeed() float64
- func (joint WheelJoint) GetJointLinearSpeed() float64
- func (joint WheelJoint) GetJointTranslation() float64
- func (joint WheelJoint) GetLocalAnchorA() Vec2
- func (joint WheelJoint) GetLocalAnchorB() Vec2
- func (joint WheelJoint) GetLocalAxisA() Vec2
- func (joint WheelJoint) GetLowerLimit() float64
- func (joint WheelJoint) GetMaxMotorTorque() float64
- func (joint WheelJoint) GetMotorSpeed() float64
- func (joint WheelJoint) GetMotorTorque(inv_dt float64) float64
- func (joint WheelJoint) GetReactionForce(inv_dt float64) Vec2
- func (joint WheelJoint) GetReactionTorque(inv_dt float64) float64
- func (joint WheelJoint) GetStiffness() float64
- func (joint WheelJoint) GetUpperLimit() float64
- func (joint *WheelJoint) InitVelocityConstraints(data SolverData)
- func (joint WheelJoint) IsLimitEnabled() bool
- func (joint WheelJoint) IsMotorEnabled() bool
- func (joint *WheelJoint) SetDamping(damping float64)
- func (joint WheelJoint) SetLimits(lower float64, upper float64)
- func (joint *WheelJoint) SetMaxMotorTorque(torque float64)
- func (joint *WheelJoint) SetMotorSpeed(speed float64)
- func (joint *WheelJoint) SetStiffness(stiffness float64)
- func (joint *WheelJoint) SolvePositionConstraints(data SolverData) bool
- func (joint *WheelJoint) SolveVelocityConstraints(data SolverData)
- type WheelJointDef
- type World
- func (world *World) ClearForces()
- func (world *World) CreateBody(def *BodyDef) *Body
- func (world *World) CreateJoint(def IJointDef) IJoint
- func (world *World) Destroy()
- func (world *World) DestroyBody(b *Body)
- func (world *World) DestroyJoint(j IJoint)
- func (world *World) Dump()
- func (world World) GetAutoClearForces() bool
- func (world World) GetBodyCount() int
- func (world World) GetBodyList() *Body
- func (world World) GetContactCount() int
- func (world World) GetContactList() IContact
- func (world World) GetContactManager() ContactManager
- func (world World) GetGravity() Vec2
- func (world World) GetJointCount() int
- func (world World) GetJointList() IJoint
- func (world World) GetProfile() Profile
- func (world World) GetProxyCount() int
- func (world World) GetTreeBalance() int
- func (world World) GetTreeHeight() int
- func (world World) GetTreeQuality() float64
- func (world World) IsLocked() bool
- func (world *World) QueryAABB(callback BroadPhaseQueryCallback, aabb AABB)
- func (world *World) RayCast(callback RaycastCallback, point1 Vec2, point2 Vec2)
- func (world *World) SetAllowSleeping(flag bool)
- func (world *World) SetAutoClearForces(flag bool)
- func (world *World) SetContactFilter(filter IContactFilter)
- func (world *World) SetContactListener(listener IContactListener)
- func (world *World) SetDestructionListener(listener IDestructionListener)
- func (world *World) SetGravity(gravity Vec2)
- func (world *World) ShiftOrigin(newOrigin Vec2)
- func (world *World) Solve(step TimeStep)
- func (world *World) SolveTOI(step TimeStep)
- func (world *World) Step(dt float64, velocityIterations int, positionIterations int)
- type WorldManifold
- type WorldQueryWrapper
Constants ¶
const ( BodyIslandFlag uint32 = 0x0001 BodyAwakeFlag uint32 = 0x0002 BodyAutoSleepFlag uint32 = 0x0004 BodyBulletFlag uint32 = 0x0008 BodyFixedRotationFlag uint32 = 0x0010 BodyEnabledFlag uint32 = 0x0020 BodyToiFlag uint32 = 0x0040 )
const ( ContactIslandFlag uint32 = 0x0001 ContactTouchingFlag uint32 = 0x0002 ContactEnabledFlag uint32 = 0x0004 ContactFilterFlag uint32 = 0x0008 ContactBulletHitFlag uint32 = 0x0010 ContactToiFlag uint32 = 0x0020 )
const Debug = false
@port(OK)
const DebugSolver = 0
Solver debugging is normally disabled because the block solver sometimes has to deal with a poorly conditioned effective mass matrix.
const E_nullProxy = -1
const LengthUnitsPerMeter float64 = 1.0
You can use this to change the length scale used by your game. For example for inches you could use 39.4
Default value 1.0
const MaxPolygonVertices int = 8
The maximum number of vertices on a convex polygon. You cannot increase this too much because b2BlockAllocator has a maximum object size.
Default value is 8
const ( // The radius of the polygon/edge shape skin. This should not be modified. Making // this smaller means polygons will have an insufficient buffer for continuous collision. // Making it larger may create artifacts for vertex collision. PolygonRadius = (2.0 * linearSlop) )
Global tuning constants based on meters-kilograms-seconds (MKS) units.
Collision
Variables ¶
var BendingModel = struct { SpringAngleBendingModel uint8 PbdAngleBendingModel uint8 XpbdAngleBendingModel uint8 PbdDistanceBendingModel uint8 PbdHeightBendingModel uint8 PbdTriangleBendingModel uint8 }{ SpringAngleBendingModel: 1, PbdAngleBendingModel: 2, XpbdAngleBendingModel: 3, PbdDistanceBendingModel: 4, PbdHeightBendingModel: 5, PbdTriangleBendingModel: 6, }
var ContactFeature_Type = struct { E_vertex uint8 E_face uint8 }{ E_vertex: 0, E_face: 1, }
var EPAxis_Type = struct { E_unknown uint8 E_edgeA uint8 E_edgeB uint8 }{ E_unknown: 0, E_edgeA: 1, E_edgeB: 2, }
This structure is used to keep track of the best separating axis.
var PointState = struct { NullState uint8 // point does not exist AddState uint8 // point was added in the update PersistState uint8 // point persisted across the update RemoveState uint8 // point was removed in the update }{ NullState: 0, AddState: 1, PersistState: 2, RemoveState: 3, }
var SeparationFunction_Type = struct { E_points uint8 E_faceA uint8 E_faceB uint8 }{ E_points: 0, E_faceA: 1, E_faceB: 2, }
var StretchingModel = struct { PbdStretchingModel uint8 XpbdStretchingModel uint8 }{ PbdStretchingModel: 1, XpbdStretchingModel: 2, }
Functions ¶
func AddType ¶
func AddType(createFcn ContactCreateFcn, destroyFcn ContactDestroyFcn, type1, type2 ShapeType)
func AngularStiffness ¶
func AngularStiffness(stiffness *float64, damping *float64, frequencyHertz float64, dampingRatio float64, bodyA *Body, bodyB *Body)
Utility to compute rotational stiffness values frequency and damping ratio
func ChainAndCircleContact_Destroy ¶
func ChainAndCircleContact_Destroy(contact IContact)
func ChainAndPolygonContact_Destroy ¶
func ChainAndPolygonContact_Destroy(contact IContact)
func CircleContact_Destroy ¶
func CircleContact_Destroy(contact IContact)
func ClipSegmentToLine ¶
func ClipSegmentToLine(vOut []ClipVertex, vIn []ClipVertex, normal Vec2, offset float64, vertexIndexA int) int
Sutherland-Hodgman clipping.
func CollideEdgeAndPolygon ¶
func CollideEdgeAndPolygon(manifold *Manifold, edgeA *EdgeShape, xfA Transform, polygonB *PolygonShape, xfB Transform)
Compute the collision manifold between an edge and a polygon.
func ComputeEdgeSeparation ¶
func ContactDestroy ¶
func ContactDestroy(contact IContact)
func ContactInitializeRegisters ¶
func ContactInitializeRegisters()
func ContactUpdate ¶
func ContactUpdate(contact IContact, listener IContactListener)
Update the contact manifold and touching status. Note: do not assume the fixture AABBs are overlapping or are valid.
func Distance ¶
func Distance(output *DistanceOutput, cache *simplexCache, input *DistanceInput)
func EdgeAndCircleContact_Destroy ¶
func EdgeAndCircleContact_Destroy(contact IContact)
func EdgeAndPolygonContact_Destroy ¶
func EdgeAndPolygonContact_Destroy(contact IContact)
func FloatClamp ¶
func GetPointStates ¶
func IsPowerOfTwo ¶
func IsProjectedPointOnLineSegment ¶
Check if the projected testpoint onto the line is on the line segment
func IsValid ¶
This function is used to ensure that a floating point number is not a NaN or infinity.
func JointDestroy ¶
func JointDestroy(joint IJoint)
func LinearStiffness ¶
func LinearStiffness(stiffness *float64, damping *float64, frequencyHertz float64, dampingRatio float64, bodyA *Body, bodyB *Body)
Utility to compute linear stiffness values from frequency and damping ratio
func MakeSimplexCache ¶
func MakeSimplexCache() simplexCache
func MixFriction ¶
Friction mixing law. The idea is to allow either fixture to drive the friction to zero. For example, anything slides on ice.
func MixRestitution ¶
Restitution mixing law. The idea is allow for anything to bounce off an inelastic surface. For example, a superball bounces on anything.
func MixRestitutionThreshold ¶
Restitution mixing law. This picks the lowest value.
func NextPowerOfTwo ¶
"Next Largest Power of 2 Given a binary integer value x, the next largest power of 2 can be computed by a SWAR algorithm that recursively "folds" the upper bits into the lower bits. This process yields a bit vector with the same most significant 1 as x, but all 1's below it. Adding 1 to that value yields the next largest power of 2. For a 32-bit value:"
func PolygonAndCircleContact_Destroy ¶
func PolygonAndCircleContact_Destroy(contact IContact)
func PolygonContact_Destroy ¶
func PolygonContact_Destroy(contact IContact)
func ShapeCast ¶
func ShapeCast(output *ShapeCastOutput, input *ShapeCastInput) bool
GJK-raycast Algorithm by Gino van den Bergen. "Smooth Mesh Contacts with GJK" in Game Physics Pearls. 2010
Perform a linear shape cast of shape B moving and shape A fixed. Determines the hit point, normal, and translation fraction. @returns true if hit, false if there is no hit or an initial overlap
func TestOverlapShapes ¶
func TimeOfImpact ¶
Compute the upper bound on time before two shapes penetrate. Time is represented as a fraction between [0,tMax]. This uses a swept separating axis and may miss some intermediate, non-tunneling collision. If you change the time interval, you should call this function again. Note: use b2Distance to compute the contact point and normal at the time of impact. CCD via the local separating axis method. This seeks progression by computing the largest time at which separation is maintained.
func ValidateHull ¶
This determines if a hull is valid. Checks for: - convexity - collinear points This is expensive and should not be called at runtime.
func Vec2Distance ¶
func Vec2DistanceSquared ¶
func Vec2Equals ¶
func Vec2NotEquals ¶
Types ¶
type AABB ¶
An axis aligned bounding box.
func (*AABB) CombineInPlace ¶
Combine an AABB into this one.
func (*AABB) CombineTwoInPlace ¶
Combine two AABBs into this one.
func (AABB) GetExtents ¶
Get the extents of the AABB (half-widths).
func (AABB) RayCast ¶
func (bb AABB) RayCast(output *RayCastOutput, input RayCastInput) bool
From Real-time Collision Detection, p179.
type Body ¶
type Body struct {
UserData any
// contains filtered or unexported fields
}
func (*Body) ApplyAngularImpulse ¶
func (*Body) ApplyForceToCenter ¶
func (*Body) ApplyLinearImpulse ¶
func (*Body) ApplyLinearImpulseToCenter ¶
func (*Body) ApplyTorque ¶
func (Body) ContactList ¶
func (body Body) ContactList() *ContactEdge
func (*Body) CreateFixture ¶
func (*Body) CreateFixtureFromDef ¶
func (body *Body) CreateFixtureFromDef(def *FixtureDef) *Fixture
func (*Body) DestroyFixture ¶
func (Body) FixtureList ¶
func (Body) GetAngularDamping ¶
func (Body) GetAngularVelocity ¶
func (Body) GravityScale ¶
func (Body) IsFixedRotation ¶
func (Body) IsKinematic ¶
func (Body) IsSleepingAllowed ¶
func (Body) LinearDamping ¶
func (Body) LinearVelocity ¶
func (Body) LinearVelocityFromLocalPoint ¶
func (Body) LinearVelocityFromWorldPoint ¶
func (Body) LocalCenter ¶
func (Body) LocalPoint ¶
Gets a local point relative to the body's origin given a world point.
func (Body) LocalVector ¶
func (*Body) ResetMassData ¶
func (body *Body) ResetMassData()
func (*Body) SetAngularDamping ¶
func (*Body) SetAngularVelocity ¶
func (*Body) SetFixedRotation ¶
func (*Body) SetGravityScale ¶
func (*Body) SetLinearDamping ¶
func (*Body) SetLinearVelocity ¶
func (*Body) SetMassData ¶
func (*Body) SetSleepingAllowed ¶
func (*Body) SetTransform ¶
func (Body) ShouldCollide ¶
func (*Body) SynchronizeFixtures ¶
func (body *Body) SynchronizeFixtures()
func (*Body) SynchronizeTransform ¶
func (body *Body) SynchronizeTransform()
func (Body) WorldCenter ¶
func (Body) WorldPoint ¶
func (Body) WorldVector ¶
type BodyDef ¶
type BodyDef struct {
// Note: if a dynamic body would have zero mass, the mass is set to one.
Type BodyType
// The world position of the body. Avoid creating bodies at the origin
// since this can lead to many overlapping shapes.
Position Vec2
// The linear velocity of the body's origin in world co-ordinates.
LinearVelocity Vec2
// The world angle of the body in radians.
Angle float64
// The angular velocity of the body.
AngularVelocity float64
// Linear damping is use to reduce the linear velocity. The damping parameter
// can be larger than 1.0 but the damping effect becomes sensitive to the
// time step when the damping parameter is large.
// Units are 1/time
LinearDamping float64
// Angular damping is use to reduce the angular velocity. The damping parameter
// can be larger than 1.0 but the damping effect becomes sensitive to the
// time step when the damping parameter is large.
// Units are 1/time
AngularDamping float64
// Set this flag to false if this body should never fall asleep. Note that
// this increases CPU usage.
AllowSleep bool
// Is this body initially awake or sleeping?
Awake bool
// Should this body be prevented from rotating? Useful for characters.
FixedRotation bool
// Is this a fast moving body that should be prevented from tunneling through
// other moving bodies? Note that all bodies are prevented from tunneling through
// kinematic and static bodies. This setting is only considered on dynamic bodies.
// @warning You should use this flag sparingly since it increases processing time.
Bullet bool
// Does this body start out enabled?
Enabled bool
// Scale the gravity applied to this body.
GravityScale float64
// Use this to store application specific body data.
UserData any
}
A body definition holds all the data needed to construct a rigid body. You can safely re-use body definitions. Shapes are added to a body after construction.
func DefaultBodyDef ¶
func DefaultBodyDef() BodyDef
This constructor sets the body definition default values.
func NewBodyDef ¶
func NewBodyDef() *BodyDef
type BroadPhase ¶
type BroadPhase struct {
M_tree DynamicTree
M_proxyCount int
M_moveBuffer []int
M_moveCapacity int
M_moveCount int
M_pairBuffer []Pair
M_pairCapacity int
M_pairCount int
M_queryProxyId int
}
func MakeBroadPhase ¶
func MakeBroadPhase() BroadPhase
func (*BroadPhase) BufferMove ¶
func (bp *BroadPhase) BufferMove(proxyId int)
func (*BroadPhase) CreateProxy ¶
func (bp *BroadPhase) CreateProxy(aabb AABB, userData any) int
func (*BroadPhase) DestroyProxy ¶
func (bp *BroadPhase) DestroyProxy(proxyId int)
func (BroadPhase) GetFatAABB ¶
func (bp BroadPhase) GetFatAABB(proxyId int) AABB
func (BroadPhase) GetProxyCount ¶
func (bp BroadPhase) GetProxyCount() int
func (BroadPhase) GetTreeBalance ¶
func (bp BroadPhase) GetTreeBalance() int
func (BroadPhase) GetTreeHeight ¶
func (bp BroadPhase) GetTreeHeight() int
func (BroadPhase) GetTreeQuality ¶
func (bp BroadPhase) GetTreeQuality() float64
func (BroadPhase) GetUserData ¶
func (bp BroadPhase) GetUserData(proxyId int) any
func (*BroadPhase) MoveProxy ¶
func (bp *BroadPhase) MoveProxy(proxyId int, aabb AABB, displacement Vec2)
func (*BroadPhase) Query ¶
func (bp *BroadPhase) Query(callback TreeQueryCallback, aabb AABB)
func (*BroadPhase) QueryCallback ¶
func (bp *BroadPhase) QueryCallback(proxyId int) bool
This is called from b2DynamicTree::Query when we are gathering pairs.
func (*BroadPhase) RayCast ¶
func (bp *BroadPhase) RayCast(callback TreeRayCastCallback, input RayCastInput)
func (*BroadPhase) ShiftOrigin ¶
func (bp *BroadPhase) ShiftOrigin(newOrigin Vec2)
func (BroadPhase) TestOverlap ¶
func (bp BroadPhase) TestOverlap(proxyIdA int, proxyIdB int) bool
func (*BroadPhase) TouchProxy ¶
func (bp *BroadPhase) TouchProxy(proxyId int)
func (*BroadPhase) UnBufferMove ¶
func (bp *BroadPhase) UnBufferMove(proxyId int)
func (*BroadPhase) UpdatePairs ¶
func (bp *BroadPhase) UpdatePairs(addPairCallback BroadPhaseAddPairCallback)
type BroadPhaseQueryCallback ¶
type ChainAndCircleContact ¶
type ChainAndCircleContact struct {
Contact
}
type ChainAndPolygonContact ¶
type ChainAndPolygonContact struct {
Contact
}
type ChainShape ¶
type ChainShape struct {
Shape
// The vertices. Owned by this class.
M_vertices []Vec2
// The vertex count.
M_count int
M_prevVertex Vec2
M_nextVertex Vec2
}
A circle shape.
func MakeChainShape ¶
func MakeChainShape() ChainShape
func (*ChainShape) Clear ¶
func (chain *ChainShape) Clear()
func (ChainShape) Clone ¶
func (chain ChainShape) Clone() IShape
func (ChainShape) ComputeAABB ¶
func (chain ChainShape) ComputeAABB(aabb *AABB, xf Transform, childIndex int)
func (ChainShape) ComputeMass ¶
func (chain ChainShape) ComputeMass(massData *MassData, density float64)
func (*ChainShape) CreateChain ¶
func (chain *ChainShape) CreateChain(vertices []Vec2, count int, prevVertex Vec2, nextVertex Vec2)
Create a chain with ghost vertices to connect multiple chains together. @param vertices an array of vertices, these are copied @param count the vertex count @param prevVertex previous vertex from chain that connects to the start @param nextVertex next vertex from chain that connects to the end
func (*ChainShape) CreateLoop ¶
func (chain *ChainShape) CreateLoop(vertices []Vec2, count int)
Create a loop. This automatically adjusts connectivity. @param vertices an array of vertices, these are copied @param count the vertex count
func (*ChainShape) Destroy ¶
func (chain *ChainShape) Destroy()
func (ChainShape) GetChildCount ¶
func (chain ChainShape) GetChildCount() int
func (ChainShape) GetChildEdge ¶
func (chain ChainShape) GetChildEdge(edge *EdgeShape, index int)
func (ChainShape) RayCast ¶
func (chain ChainShape) RayCast(output *RayCastOutput, input RayCastInput, xf Transform, childIndex int) bool
type CircleContact ¶
type CircleContact struct {
Contact
}
type CircleShape ¶
A solid circle shape
func MakeCircleShape ¶
func MakeCircleShape() CircleShape
func NewCircleShape ¶
func NewCircleShape() *CircleShape
func (CircleShape) Clone ¶
func (shape CircleShape) Clone() IShape
func (CircleShape) ComputeAABB ¶
func (shape CircleShape) ComputeAABB(aabb *AABB, transform Transform, childIndex int)
func (CircleShape) ComputeMass ¶
func (shape CircleShape) ComputeMass(massData *MassData, density float64)
func (CircleShape) Destroy ¶
func (shape CircleShape) Destroy()
func (CircleShape) GetChildCount ¶
func (shape CircleShape) GetChildCount() int
func (CircleShape) RayCast ¶
func (shape CircleShape) RayCast(output *RayCastOutput, input RayCastInput, transform Transform, childIndex int) bool
Collision Detection in Interactive 3D Environments by Gino van den Bergen From Section 3.1.2 x = s + a * r norm(x) = radius
@note because the circle is solid, rays that start inside do not hit because the normal is not defined.
type ClipVertex ¶
Used for computing contact manifolds.
type Contact ¶
type Contact struct {
M_flags uint32
// World pool and list pointers.
M_prev IContact //should be backed by a pointer
M_next IContact //should be backed by a pointer
// Nodes for connecting bodies.
M_nodeA *ContactEdge
M_nodeB *ContactEdge
M_fixtureA *Fixture
M_fixtureB *Fixture
M_indexA int
M_indexB int
M_manifold *Manifold
M_toiCount int
M_toi float64
M_friction float64
M_restitution float64
M_restitutionThreshold float64
M_tangentSpeed float64
}
func (*Contact) FlagForFiltering ¶
func (contact *Contact) FlagForFiltering()
func (Contact) GetChildIndexA ¶
func (Contact) GetChildIndexB ¶
func (Contact) GetFixtureA ¶
func (Contact) GetFixtureB ¶
func (Contact) GetManifold ¶
func (Contact) GetNodeA ¶
func (contact Contact) GetNodeA() *ContactEdge
func (Contact) GetNodeB ¶
func (contact Contact) GetNodeB() *ContactEdge
func (Contact) GetRestitution ¶
Get the restitution.
func (Contact) GetRestitutionThreshold ¶
Get the restitution threshold.
func (Contact) GetTOICount ¶
func (Contact) GetTangentSpeed ¶
Get the desired tangent speed. In meters per second.
func (Contact) GetWorldManifold ¶
func (contact Contact) GetWorldManifold(worldManifold *WorldManifold)
func (Contact) IsTouching ¶
func (*Contact) ResetFriction ¶
func (contact *Contact) ResetFriction()
Reset the friction mixture to the default value.
func (*Contact) ResetRestitution ¶
func (contact *Contact) ResetRestitution()
Reset the restitution to the default value.
func (*Contact) ResetRestitutionThreshold ¶
func (contact *Contact) ResetRestitutionThreshold()
Reset the restitution threshold to the default value.
func (*Contact) SetChildIndexA ¶
func (*Contact) SetChildIndexB ¶
func (*Contact) SetEnabled ¶
func (*Contact) SetFixtureA ¶
func (*Contact) SetFixtureB ¶
func (*Contact) SetFriction ¶
Override the default friction mixture. You can call this in b2ContactListener::PreSolve. This value persists until set or reset.
func (*Contact) SetManifold ¶
func (*Contact) SetNodeA ¶
func (contact *Contact) SetNodeA(node *ContactEdge)
func (*Contact) SetNodeB ¶
func (contact *Contact) SetNodeB(node *ContactEdge)
func (*Contact) SetRestitution ¶
Override the default restitution mixture. You can call this in b2ContactListener::PreSolve. The value persists until you set or reset.
func (*Contact) SetRestitutionThreshold ¶
Override the default restitution velocity threshold mixture. You can call this in b2ContactListener::PreSolve. The value persists until you set or reset.
func (*Contact) SetTOICount ¶
func (*Contact) SetTangentSpeed ¶
Set the desired tangent speed for a conveyor belt behavior. In meters per second.
type ContactCreateFcn ¶
type ContactDestroyFcn ¶
type ContactDestroyFcn func(contact IContact) // contact should be a pointer
type ContactEdge ¶
type ContactEdge struct {
Other *Body // provides quick access to the other body attached.
Contact IContact // the contact
Prev *ContactEdge // the previous contact edge in the body's contact list
Next *ContactEdge // the next contact edge in the body's contact list
}
A contact edge is used to connect bodies and contacts together in a contact graph where each body is a node and each contact is an edge. A contact edge belongs to a doubly linked list maintained in each attached body. Each contact has two contact nodes, one for each attached body.
func NewContactEdge ¶
func NewContactEdge() *ContactEdge
type ContactFeature ¶
type ContactFeature struct {
IndexA uint8 ///< Feature index on shapeA
IndexB uint8 ///< Feature index on shapeB
TypeA uint8 ///< The feature type on shapeA
TypeB uint8 ///< The feature type on shapeB
}
The features that intersect to form the contact point This must be 4 bytes or less.
type ContactFilter ¶
type ContactFilter struct {
}
func (*ContactFilter) ShouldCollide ¶
func (cf *ContactFilter) ShouldCollide(fixtureA *Fixture, fixtureB *Fixture) bool
Return true if contact calculations should be performed between these two shapes. If you implement your own collision filter you may want to build from this implementation.
type ContactID ¶
type ContactID ContactFeature
type ContactImpulse ¶
type ContactImpulse struct {
NormalImpulses [maxManifoldPoints]float64
TangentImpulses [maxManifoldPoints]float64
Count int
}
Contact impulses for reporting. Impulses are used instead of forces because sub-step forces may approach infinity for rigid body collisions. These match up one-to-one with the contact points in b2Manifold.
func MakeContactImpulse ¶
func MakeContactImpulse() ContactImpulse
type ContactManager ¶
type ContactManager struct {
// contains filtered or unexported fields
}
func MakeContactManager ¶
func MakeContactManager() ContactManager
func NewContactManager ¶
func NewContactManager() *ContactManager
func (*ContactManager) AddPair ¶
func (mgr *ContactManager) AddPair(proxyUserDataA any, proxyUserDataB any)
func (*ContactManager) Collide ¶
func (mgr *ContactManager) Collide()
This is the top level collision call for the time step. Here all the narrow phase collision is processed for the world contact list.
func (*ContactManager) Destroy ¶
func (mgr *ContactManager) Destroy(c IContact)
func (*ContactManager) FindNewContacts ¶
func (mgr *ContactManager) FindNewContacts()
type ContactRegister ¶
type ContactRegister struct {
CreateFcn ContactCreateFcn
DestroyFcn ContactDestroyFcn
Primary bool
}
type ContactSolver ¶
type ContactSolver struct {
M_step TimeStep
M_positions []position
M_velocities []velocity
M_positionConstraints []ContactPositionConstraint
M_velocityConstraints []ContactVelocityConstraint
M_contacts []IContact // has to be backed by pointers
M_count int
}
func MakeContactSolver ¶
func MakeContactSolver(def *ContactSolverDef) ContactSolver
func (*ContactSolver) Destroy ¶
func (solver *ContactSolver) Destroy()
func (*ContactSolver) InitializeVelocityConstraints ¶
func (solver *ContactSolver) InitializeVelocityConstraints()
Initialize position dependent portions of the velocity constraints.
func (*ContactSolver) SolvePositionConstraints ¶
func (solver *ContactSolver) SolvePositionConstraints() bool
Sequential solver.
func (*ContactSolver) SolveTOIPositionConstraints ¶
func (solver *ContactSolver) SolveTOIPositionConstraints(toiIndexA int, toiIndexB int) bool
Sequential position solver for position constraints.
func (*ContactSolver) SolveVelocityConstraints ¶
func (solver *ContactSolver) SolveVelocityConstraints()
func (*ContactSolver) StoreImpulses ¶
func (solver *ContactSolver) StoreImpulses()
func (*ContactSolver) WarmStart ¶
func (solver *ContactSolver) WarmStart()
type ContactSolverDef ¶
type ContactSolverDef struct {
Step TimeStep
Contacts []IContact // has to be backed by pointers
Count int
Positions []position
Velocities []velocity
}
func MakeContactSolverDef ¶
func MakeContactSolverDef() ContactSolverDef
type ContactVelocityConstraint ¶
type ContactVelocityConstraint struct {
Points [maxManifoldPoints]VelocityConstraintPoint
Normal Vec2
NormalMass Mat22
K Mat22
IndexA int
IndexB int
InvMassA, InvMassB float64
InvIA, InvIB float64
Friction float64
Restitution float64
Threshold float64
TangentSpeed float64
PointCount int
ContactIndex int
}
type DistanceInput ¶
type DistanceInput struct {
ProxyA DistanceProxy
ProxyB DistanceProxy
TransformA Transform
TransformB Transform
UseRadii bool
}
Input for b2Distance. You have to option to use the shape radii in the computation. Even
func MakeDistanceInput ¶
func MakeDistanceInput() DistanceInput
type DistanceJoint ¶
type DistanceJoint struct {
*Joint
M_stiffness float64
M_damping float64
M_bias float64
M_length float64
M_minLength float64
M_maxLength float64
// Solver shared
M_localAnchorA Vec2
M_localAnchorB Vec2
M_gamma float64
M_impulse float64
M_lowerImpulse float64
M_upperImpulse float64
// Solver temp
M_indexA int
M_indexB int
M_u Vec2
M_rA Vec2
M_rB Vec2
M_localCenterA Vec2
M_localCenterB Vec2
M_currentLength float64
M_invMassA float64
M_invMassB float64
M_invIA float64
M_invIB float64
M_softMass float64
M_mass float64
}
A distance joint constrains two points on two bodies to remain at a fixed distance from each other. You can view this as a massless, rigid rod.
func MakeDistanceJoint ¶
func MakeDistanceJoint(def *DistanceJointDef) *DistanceJoint
func (DistanceJoint) Dump ¶
func (joint DistanceJoint) Dump()
func (DistanceJoint) GetAnchorA ¶
func (joint DistanceJoint) GetAnchorA() Vec2
func (DistanceJoint) GetAnchorB ¶
func (joint DistanceJoint) GetAnchorB() Vec2
func (DistanceJoint) GetCurrentLength ¶
func (joint DistanceJoint) GetCurrentLength() float64
Get the current length
func (DistanceJoint) GetDamping ¶
func (joint DistanceJoint) GetDamping() float64
Get linear damping in N*s/m
func (DistanceJoint) GetLocalAnchorA ¶
func (joint DistanceJoint) GetLocalAnchorA() Vec2
The local anchor point relative to bodyA's origin.
func (DistanceJoint) GetLocalAnchorB ¶
func (joint DistanceJoint) GetLocalAnchorB() Vec2
The local anchor point relative to bodyB's origin.
func (DistanceJoint) GetMaxLength ¶
func (joint DistanceJoint) GetMaxLength() float64
Get the maximum length
func (DistanceJoint) GetMinLength ¶
func (joint DistanceJoint) GetMinLength() float64
Get the minimum length
func (DistanceJoint) GetReactionForce ¶
func (joint DistanceJoint) GetReactionForce(inv_dt float64) Vec2
func (DistanceJoint) GetReactionTorque ¶
func (joint DistanceJoint) GetReactionTorque(inv_dt float64) float64
func (DistanceJoint) GetStiffness ¶
func (joint DistanceJoint) GetStiffness() float64
Get the linear stiffness in N/m
func (*DistanceJoint) InitVelocityConstraints ¶
func (joint *DistanceJoint) InitVelocityConstraints(data SolverData)
func (*DistanceJoint) SetDamping ¶
func (joint *DistanceJoint) SetDamping(damping float64)
Set linear damping in N*s/m
func (*DistanceJoint) SetLength ¶
func (joint *DistanceJoint) SetLength(length float64) float64
Set the rest length @returns clamped rest length
func (*DistanceJoint) SetMaxLength ¶
func (joint *DistanceJoint) SetMaxLength(maxLength float64) float64
Set the maximum length @returns the clamped maximum length
func (*DistanceJoint) SetMinLength ¶
func (joint *DistanceJoint) SetMinLength(minLength float64) float64
Set the minimum length @returns the clamped minimum length
func (*DistanceJoint) SetStiffness ¶
func (joint *DistanceJoint) SetStiffness(stiffness float64)
Set the linear stiffness in N/m
func (*DistanceJoint) SolvePositionConstraints ¶
func (joint *DistanceJoint) SolvePositionConstraints(data SolverData) bool
func (*DistanceJoint) SolveVelocityConstraints ¶
func (joint *DistanceJoint) SolveVelocityConstraints(data SolverData)
type DistanceJointDef ¶
type DistanceJointDef struct {
JointDef
// The local anchor point relative to bodyA's origin.
LocalAnchorA Vec2
// The local anchor point relative to bodyB's origin.
LocalAnchorB Vec2
// The rest length of this joint. Clamped to a stable minimum value.
Length float64
// Minimum length. Clamped to a stable minimum value.
MinLength float64
// Maximum length. Must be greater than or equal to the minimum length.
MaxLength float64
// The linear stiffness in N/m.
Stiffness float64
// The linear damping in N*s/m.
Damping float64
}
Distance joint definition. This requires defining an anchor point on both bodies and the non-zero distance of the distance joint. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. This helps when saving and loading a game.
func MakeDistanceJointDef ¶
func MakeDistanceJointDef() DistanceJointDef
func (*DistanceJointDef) Initialize ¶
func (joint *DistanceJointDef) Initialize(b1 *Body, b2 *Body, anchor1 Vec2, anchor2 Vec2)
Initialize the bodies, anchors, and rest length using world space anchors. The minimum and maximum lengths are set to the rest length.
type DistanceOutput ¶
type DistanceOutput struct {
PointA Vec2 // closest point on shapeA
PointB Vec2 // closest point on shapeB
Distance float64
Iterations int // number of GJK iterations used
}
Output for b2Distance.
func MakeDistanceOutput ¶
func MakeDistanceOutput() DistanceOutput
type DistanceProxy ¶
type DistanceProxy struct {
M_buffer [2]Vec2
M_vertices []Vec2 // is a memory blob using pointer arithmetic in original implementation
M_count int
M_radius float64
}
A distance proxy is used by the GJK algorithm. It encapsulates any shape.
func MakeDistanceProxy ¶
func MakeDistanceProxy() DistanceProxy
func (DistanceProxy) GetSupport ¶
func (p DistanceProxy) GetSupport(d Vec2) int
func (DistanceProxy) GetSupportVertex ¶
func (p DistanceProxy) GetSupportVertex(d Vec2) Vec2
func (DistanceProxy) GetVertex ¶
func (p DistanceProxy) GetVertex(index int) Vec2
func (DistanceProxy) GetVertexCount ¶
func (p DistanceProxy) GetVertexCount() int
func (*DistanceProxy) Set ¶
func (p *DistanceProxy) Set(shape IShape, index int)
Initialize the proxy using the given shape. The shape must remain in scope while the proxy is in use.
type DynamicTree ¶
type DynamicTree struct {
// Private members:
M_root int
M_nodeCount int
M_nodeCapacity int
M_freeList int
M_insertionCount int
// contains filtered or unexported fields
}
A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt. A dynamic tree arranges data in a binary tree to accelerate queries such as volume queries and ray casts. Leafs are proxies with an AABB. In the tree we expand the proxy AABB by b2_fatAABBFactor so that the proxy AABB is bigger than the client object. This allows the client object to move by small amounts without triggering a tree update.
Nodes are pooled and relocatable, so we use node indices rather than pointers.
func MakeDynamicTree ¶
func MakeDynamicTree() DynamicTree
func (*DynamicTree) AllocateNode ¶
func (tree *DynamicTree) AllocateNode() int
Allocate a node from the pool. Grow the pool if necessary.
func (*DynamicTree) Balance ¶
func (tree *DynamicTree) Balance(iA int) int
Perform a left or right rotation if node A is imbalanced. Returns the new root index.
func (DynamicTree) ClearMoved ¶
func (tree DynamicTree) ClearMoved(proxyId int)
func (DynamicTree) ComputeHeight ¶
func (tree DynamicTree) ComputeHeight(nodeId int) int
Compute the height of a sub-tree.
func (DynamicTree) ComputeTotalHeight ¶
func (tree DynamicTree) ComputeTotalHeight() int
func (*DynamicTree) CreateProxy ¶
func (tree *DynamicTree) CreateProxy(aabb AABB, userData any) int
Create a proxy in the tree as a leaf node. We return the index of the node instead of a pointer so that we can grow the node pool.
func (*DynamicTree) DestroyProxy ¶
func (tree *DynamicTree) DestroyProxy(proxyId int)
func (*DynamicTree) FreeNode ¶
func (tree *DynamicTree) FreeNode(nodeId int)
Return a node to the pool.
func (DynamicTree) GetAreaRatio ¶
func (tree DynamicTree) GetAreaRatio() float64
func (DynamicTree) GetFatAABB ¶
func (tree DynamicTree) GetFatAABB(proxyId int) AABB
func (DynamicTree) GetHeight ¶
func (tree DynamicTree) GetHeight() int
func (DynamicTree) GetMaxBalance ¶
func (tree DynamicTree) GetMaxBalance() int
func (DynamicTree) GetUserData ¶
func (tree DynamicTree) GetUserData(proxyId int) any
func (*DynamicTree) InsertLeaf ¶
func (tree *DynamicTree) InsertLeaf(leaf int)
func (*DynamicTree) MoveProxy ¶
func (tree *DynamicTree) MoveProxy(proxyId int, aabb AABB, displacement Vec2) bool
func (*DynamicTree) Query ¶
func (tree *DynamicTree) Query(queryCallback TreeQueryCallback, aabb AABB)
func (DynamicTree) RayCast ¶
func (tree DynamicTree) RayCast(rayCastCallback TreeRayCastCallback, input RayCastInput)
func (*DynamicTree) RebuildBottomUp ¶
func (tree *DynamicTree) RebuildBottomUp()
func (*DynamicTree) RemoveLeaf ¶
func (tree *DynamicTree) RemoveLeaf(leaf int)
func (*DynamicTree) ShiftOrigin ¶
func (tree *DynamicTree) ShiftOrigin(newOrigin Vec2)
func (DynamicTree) Validate ¶
func (tree DynamicTree) Validate()
func (DynamicTree) ValidateMetrics ¶
func (tree DynamicTree) ValidateMetrics(index int)
func (DynamicTree) ValidateStructure ¶
func (tree DynamicTree) ValidateStructure(index int)
func (DynamicTree) WasMoved ¶
func (tree DynamicTree) WasMoved(proxyId int) bool
type EdgeAndCircleContact ¶
type EdgeAndCircleContact struct {
Contact
}
type EdgeAndPolygonContact ¶
type EdgeAndPolygonContact struct {
Contact
}
type EdgeShape ¶
type EdgeShape struct {
Shape
// These are the edge vertices
M_vertex1, M_vertex2 Vec2
// Optional adjacent vertices. These are used for smooth collision.
M_vertex0, M_vertex3 Vec2
// Uses m_vertex0 and m_vertex3 to create smooth collision.
M_oneSided bool
}
A line segment (edge) shape. These can be connected in chains or loops to other edge shapes. Edges created independently are two-sided and do no provide smooth movement across junctions.
func MakeEdgeShape ¶
func MakeEdgeShape() EdgeShape
func NewEdgeShape ¶
func NewEdgeShape() *EdgeShape
func (EdgeShape) ComputeAABB ¶
func (EdgeShape) ComputeMass ¶
func (EdgeShape) GetChildCount ¶
func (EdgeShape) RayCast ¶
func (edge EdgeShape) RayCast(output *RayCastOutput, input RayCastInput, xf Transform, childIndex int) bool
p = p1 + t * d v = v1 + s * e p1 + t * d = v1 + s * e s * e - t * d = p1 - v1
func (*EdgeShape) SetOneSided ¶
Set this as a part of a sequence. Vertex v0 precedes the edge and vertex v3 follows. These extra vertices are used to provide smooth movement across junctions. This also makes the collision one-sided. The edge normal points to the right looking from v1 to v2.
func (*EdgeShape) SetTwoSided ¶
Set this as an isolated edge. Collision is two-sided.
type Filter ¶
type Filter struct {
// The collision category bits. Normally you would just set one bit.
CategoryBits uint16
// The collision mask bits. This states the categories that this
// shape would accept for collision.
MaskBits uint16
// Collision groups allow a certain group of objects to never collide (negative)
// or always collide (positive). Zero means no collision group. Non-zero group
// filtering always wins against the mask bits.
GroupIndex int16
}
This holds contact filtering data.
func DefaultFilter ¶
func DefaultFilter() Filter
type Fixture ¶
type Fixture struct {
// contains filtered or unexported fields
}
A fixture is used to attach a shape to a body for collision detection. A fixture inherits its transform from its parent. Fixtures hold additional non-geometric data such as friction, collision filters, etc. Fixtures are created via b2Body::CreateFixture. @warning you cannot reuse fixtures.
func NewFixture ¶
func NewFixture() *Fixture
func (Fixture) AABB ¶
Get the fixture's AABB. This AABB may be enlarge and/or stale. If you need a more accurate AABB, compute it using the shape and the body transform.
func (*Fixture) Create ¶
func (fix *Fixture) Create(body *Body, def *FixtureDef)
func (*Fixture) CreateProxies ¶
func (fix *Fixture) CreateProxies(broadPhase *BroadPhase, xf Transform)
func (*Fixture) DestroyProxies ¶
func (fix *Fixture) DestroyProxies(broadPhase *BroadPhase)
func (Fixture) FilterData ¶
func (Fixture) RayCast ¶
func (fix Fixture) RayCast(output *RayCastOutput, input RayCastInput, childIndex int) bool
func (Fixture) Restitution ¶
Get the coefficient of restitution.
func (Fixture) RestitutionThreshold ¶
Get the restitution velocity threshold.
func (*Fixture) SetDensity ¶
Set the density of this fixture. This will _not_ automatically adjust the mass of the body. You must call b2Body::ResetMassData to update the body's mass.
func (*Fixture) SetFilterData ¶
func (*Fixture) SetFriction ¶
Set the coefficient of friction. This will _not_ change the friction of existing contacts.
func (*Fixture) SetRestitution ¶
Set the coefficient of restitution. This will _not_ change the restitution of existing contacts.
func (*Fixture) SetRestitutionThreshold ¶
Set the restitution threshold. This will _not_ change the restitution threshold of existing contacts.
func (*Fixture) SetUserData ¶
func (*Fixture) Synchronize ¶
func (fix *Fixture) Synchronize(broadPhase *BroadPhase, transform1 Transform, transform2 Transform)
type FixtureDef ¶
type FixtureDef struct {
// The shape, this must be set. The shape will be cloned, so you
// can create the shape on the stack.
Shape IShape
// Use this to store application specific fixture data.
UserData any
// The friction coefficient, usually in the range [0,1].
Friction float64
// The restitution (elasticity) usually in the range [0,1].
Restitution float64
// Restitution velocity threshold, usually in m/s. Collisions above this
// speed have restitution applied (will bounce).
RestitutionThreshold float64
// The density, usually in kg/m^2.
Density float64
// A sensor shape collects contact information but never generates a collision
// response.
IsSensor bool
// Contact filtering data.
Filter Filter
}
A fixture definition is used to create a fixture. This class defines an abstract fixture definition. You can reuse fixture definitions safely.
func DefaultFixtureDef ¶
func DefaultFixtureDef() FixtureDef
The constructor sets the default fixture definition values.
type FixtureProxy ¶
This proxy is used internally to connect fixtures to the broad-phase.
type FrictionJoint ¶
type FrictionJoint struct {
*Joint
M_localAnchorA Vec2
M_localAnchorB Vec2
// Solver shared
M_linearImpulse Vec2
M_angularImpulse float64
M_maxForce float64
M_maxTorque float64
// Solver temp
M_indexA int
M_indexB int
M_rA Vec2
M_rB Vec2
M_localCenterA Vec2
M_localCenterB Vec2
M_invMassA float64
M_invMassB float64
M_invIA float64
M_invIB float64
M_linearMass Mat22
M_angularMass float64
}
Friction joint. This is used for top-down friction. It provides 2D translational friction and angular friction.
func MakeFrictionJoint ¶
func MakeFrictionJoint(def *FrictionJointDef) *FrictionJoint
func (*FrictionJoint) Dump ¶
func (joint *FrictionJoint) Dump()
func (FrictionJoint) GetAnchorA ¶
func (joint FrictionJoint) GetAnchorA() Vec2
func (FrictionJoint) GetAnchorB ¶
func (joint FrictionJoint) GetAnchorB() Vec2
func (FrictionJoint) GetLocalAnchorA ¶
func (joint FrictionJoint) GetLocalAnchorA() Vec2
The local anchor point relative to bodyA's origin.
func (FrictionJoint) GetLocalAnchorB ¶
func (joint FrictionJoint) GetLocalAnchorB() Vec2
The local anchor point relative to bodyB's origin.
func (FrictionJoint) GetMaxForce ¶
func (joint FrictionJoint) GetMaxForce() float64
func (FrictionJoint) GetMaxTorque ¶
func (joint FrictionJoint) GetMaxTorque() float64
func (FrictionJoint) GetReactionForce ¶
func (joint FrictionJoint) GetReactionForce(inv_dt float64) Vec2
func (FrictionJoint) GetReactionTorque ¶
func (joint FrictionJoint) GetReactionTorque(inv_dt float64) float64
func (*FrictionJoint) InitVelocityConstraints ¶
func (joint *FrictionJoint) InitVelocityConstraints(data SolverData)
func (*FrictionJoint) SetMaxForce ¶
func (joint *FrictionJoint) SetMaxForce(force float64)
func (*FrictionJoint) SetMaxTorque ¶
func (joint *FrictionJoint) SetMaxTorque(torque float64)
func (*FrictionJoint) SolvePositionConstraints ¶
func (joint *FrictionJoint) SolvePositionConstraints(data SolverData) bool
func (*FrictionJoint) SolveVelocityConstraints ¶
func (joint *FrictionJoint) SolveVelocityConstraints(data SolverData)
type FrictionJointDef ¶
type FrictionJointDef struct {
JointDef
// The local anchor point relative to bodyA's origin.
LocalAnchorA Vec2
// The local anchor point relative to bodyB's origin.
LocalAnchorB Vec2
// The maximum friction force in N.
MaxForce float64
// The maximum friction torque in N-m.
MaxTorque float64
}
Friction joint definition.
func MakeFrictionJointDef ¶
func MakeFrictionJointDef() FrictionJointDef
func (*FrictionJointDef) Initialize ¶
func (joint *FrictionJointDef) Initialize(bA *Body, bB *Body, anchor Vec2)
type GearJoint ¶
type GearJoint struct {
*Joint
M_joint1 IJoint // backed by pointer
M_joint2 IJoint // backed by pointer
M_typeA JointType
M_typeB JointType
// Body A is connected to body C
// Body B is connected to body D
M_bodyC *Body
M_bodyD *Body
// Solver shared
M_localAnchorA Vec2
M_localAnchorB Vec2
M_localAnchorC Vec2
M_localAnchorD Vec2
M_localAxisC Vec2
M_localAxisD Vec2
M_referenceAngleA float64
M_referenceAngleB float64
M_constant float64
M_ratio float64
M_tolerance float64
M_impulse float64
// Solver temp
M_indexA, M_indexB, M_indexC, M_indexD int
M_lcA, M_lcB, M_lcC, M_lcD Vec2
M_mA, M_mB, M_mC, M_mD float64
M_iA, M_iB, M_iC, M_iD float64
M_JvAC, M_JvBD Vec2
M_JwA, M_JwB, M_JwC, M_JwD float64
M_mass float64
}
A gear joint is used to connect two joints together. Either joint can be a revolute or prismatic joint. You specify a gear ratio to bind the motions together: coordinate1 + ratio * coordinate2 = constant The ratio can be negative or positive. If one joint is a revolute joint and the other joint is a prismatic joint, then the ratio will have units of length or units of 1/length. @warning You have to manually destroy the gear joint if joint1 or joint2 is destroyed.
func MakeGearJoint ¶
func MakeGearJoint(def *GearJointDef) *GearJoint
func (GearJoint) GetAnchorA ¶
func (GearJoint) GetAnchorB ¶
func (GearJoint) GetReactionForce ¶
func (GearJoint) GetReactionTorque ¶
func (*GearJoint) InitVelocityConstraints ¶
func (joint *GearJoint) InitVelocityConstraints(data SolverData)
func (*GearJoint) SolvePositionConstraints ¶
func (joint *GearJoint) SolvePositionConstraints(data SolverData) bool
func (*GearJoint) SolveVelocityConstraints ¶
func (joint *GearJoint) SolveVelocityConstraints(data SolverData)
type GearJointDef ¶
type GearJointDef struct {
JointDef
// The first revolute/prismatic joint attached to the gear joint.
Joint1 IJoint // has to be backed by pointer
// The second revolute/prismatic joint attached to the gear joint.
Joint2 IJoint // has to be backed by pointer
// The gear ratio.
// @see b2GearJoint for explanation.
Ratio float64
}
Gear joint definition. This definition requires two existing revolute or prismatic joints (any combination will work). @warning bodyB on the input joints must both be dynamic
func MakeGearJointDef ¶
func MakeGearJointDef() GearJointDef
type Hull ¶
type Hull struct {
Points [MaxPolygonVertices]Vec2
Count int
}
Convex hull used for polygon collision
func ComputeHull ¶
Compute the convex hull of a set of points. Returns an empty hull if it fails. Some failure cases: - all points very close together - all points on a line - less than 3 points - more than b2_maxPolygonVertices points This welds close points and removes collinear points.
quickhull algorithm - merges vertices based on b2_linearSlop - removes collinear points using b2_linearSlop - returns an empty hull if it fails
type IContact ¶
type IContact interface {
GetFlags() uint32
SetFlags(flags uint32)
GetPrev() IContact
SetPrev(prev IContact)
GetNext() IContact
SetNext(prev IContact)
GetNodeA() *ContactEdge
SetNodeA(node *ContactEdge)
GetNodeB() *ContactEdge
SetNodeB(node *ContactEdge)
GetFixtureA() *Fixture
SetFixtureA(fixture *Fixture)
GetFixtureB() *Fixture
SetFixtureB(fixture *Fixture)
GetChildIndexA() int
SetChildIndexA(index int)
GetChildIndexB() int
SetChildIndexB(index int)
GetManifold() *Manifold
SetManifold(manifold *Manifold)
GetTOICount() int
SetTOICount(toiCount int)
GetTOI() float64
SetTOI(toiCount float64)
GetFriction() float64
SetFriction(friction float64)
ResetFriction()
GetRestitution() float64
SetRestitution(restitution float64)
ResetRestitution()
SetRestitutionThreshold(float64)
GetRestitutionThreshold() float64
ResetRestitutionThreshold()
GetTangentSpeed() float64
SetTangentSpeed(tangentSpeed float64)
IsTouching() bool
IsEnabled() bool
SetEnabled(bool)
Evaluate(manifold *Manifold, xfA Transform, xfB Transform)
FlagForFiltering()
GetWorldManifold(worldManifold *WorldManifold)
}
func CircleContact_Create ¶
func ContactFactory ¶
type IContactFilter ¶
type IContactListener ¶
type IContactListener interface {
// Called when two fixtures begin to touch.
BeginContact(contact IContact) // contact has to be backed by a pointer
// Called when two fixtures cease to touch.
EndContact(contact IContact) // contact has to be backed by a pointer
// This is called after a contact is updated. This allows you to inspect a
// contact before it goes to the solver. If you are careful, you can modify the
// contact manifold (e.g. disable contact).
// A copy of the old manifold is provided so that you can detect changes.
// Note: this is called only for awake bodies.
// Note: this is called even when the number of contact points is zero.
// Note: this is not called for sensors.
// Note: if you set the number of contact points to zero, you will not
// get an EndContact callback. However, you may get a BeginContact callback
// the next step.
PreSolve(contact IContact, oldManifold Manifold) // contact has to be backed by a pointer
// This lets you inspect a contact after the solver is finished. This is useful
// for inspecting impulses.
// Note: the contact manifold does not include time of impact impulses, which can be
// arbitrarily large if the sub-step is small. Hence the impulse is provided explicitly
// in a separate data structure.
// Note: this is only called for contacts that are touching, solid, and awake.
PostSolve(contact IContact, impulse *ContactImpulse) // contact has to be backed by a pointer
}
type IDestructionListener ¶
type IJoint ¶
type IJoint interface {
// Dump this joint to the log file.
Dump()
// Shift the origin for any points stored in world coordinates.
ShiftOrigin(newOrigin Vec2)
GetType() JointType
SetType(t JointType)
GetBodyA() *Body
SetBodyA(body *Body)
GetBodyB() *Body
SetBodyB(body *Body)
GetIndex() int
SetIndex(index int)
GetNext() IJoint // backed by pointer
SetNext(next IJoint) // backed by pointer
GetPrev() IJoint // backed by pointer
SetPrev(prev IJoint) // backed by pointer
GetEdgeA() *JointEdge
SetEdgeA(edge *JointEdge)
GetEdgeB() *JointEdge
SetEdgeB(edge *JointEdge)
GetUserData() any
SetUserData(data any)
IsCollideConnected() bool
SetCollideConnected(flag bool)
IsEnabled() bool
//@goadd
Destroy()
InitVelocityConstraints(data SolverData)
SolveVelocityConstraints(data SolverData)
SolvePositionConstraints(data SolverData) bool
GetIslandFlag() bool
SetIslandFlag(flag bool)
}
func JointCreate ¶
type IShape ¶
type IShape interface {
Destroy()
// Clone the concrete shape using the provided allocator.
Clone() IShape
// Get the type of this shape. You can use this to down cast to the concrete shape.
// @return the shape type.
GetType() ShapeType
// Get the type of this shape. You can use this to down cast to the concrete shape.
// @return the shape type.
GetRadius() float64
// Get the number of child primitives.
GetChildCount() int
// Test a point for containment in this shape. This only works for convex shapes.
// @param xf the shape world transform.
// @param p a point in world coordinates.
TestPoint(xf Transform, p Vec2) bool
// Cast a ray against a child shape.
// @param output the ray-cast results.
// @param input the ray-cast input parameters.
// @param transform the transform to be applied to the shape.
// @param childIndex the child shape index
RayCast(output *RayCastOutput, input RayCastInput, transform Transform, childIndex int) bool
// Given a transform, compute the associated axis aligned bounding box for a child shape.
// @param aabb returns the axis aligned box.
// @param xf the world transform of the shape.
// @param childIndex the child shape
ComputeAABB(aabb *AABB, xf Transform, childIndex int)
// Compute the mass properties of this shape using its dimensions and density.
// The inertia tensor is computed about the local origin.
// @param massData returns the mass data for this shape.
// @param density the density in kilograms per meter squared.
ComputeMass(massData *MassData, density float64)
}
type Island ¶
type Island struct {
M_listener IContactListener
M_bodies []*Body
M_contacts []IContact // has to be backed by pointers
M_joints []IJoint // has to be backed by pointers
M_positions []position
M_velocities []velocity
M_bodyCount int
M_jointCount int
M_contactCount int
M_bodyCapacity int
M_contactCapacity int
M_jointCapacity int
}
This is an internal class.
func MakeIsland ¶
func MakeIsland(bodyCapacity int, contactCapacity int, jointCapacity int, listener IContactListener) Island
func (*Island) AddContact ¶
func (*Island) Report ¶
func (island *Island) Report(constraints []ContactVelocityConstraint)
type Joint ¶
type Joint struct {
M_type JointType
M_prev IJoint // has to be backed by pointer
M_next IJoint // has to be backed by pointer
M_edgeA *JointEdge
M_edgeB *JointEdge
M_index int
M_islandFlag bool
M_collideConnected bool
UserData any
// contains filtered or unexported fields
}
The base joint class. Joints are used to constraint two bodies together in various fashions. Some joints also feature limits and motors.
func (Joint) GetIslandFlag ¶
func (Joint) GetUserData ¶
func (*Joint) InitVelocityConstraints ¶
func (j *Joint) InitVelocityConstraints(data SolverData)
func (Joint) IsCollideConnected ¶
func (*Joint) SetIslandFlag ¶
func (*Joint) SetUserData ¶
func (Joint) ShiftOrigin ¶
Shift the origin for any points stored in world coordinates.
func (*Joint) SolvePositionConstraints ¶
func (j *Joint) SolvePositionConstraints(data SolverData) bool
func (*Joint) SolveVelocityConstraints ¶
func (j *Joint) SolveVelocityConstraints(data SolverData)
type JointDef ¶
type JointDef struct {
// The joint type is set automatically for concrete joint types.
Type JointType
// Use this to attach application specific data to your joints.
UserData any
// The first attached body.
BodyA *Body
// The second attached body.
BodyB *Body
// Set this flag to true if the attached bodies should collide.
CollideConnected bool
}
Joint definitions are used to construct joints.
func DefaultJointDef ¶
func DefaultJointDef() JointDef
func (JointDef) GetUserData ¶
func (JointDef) IsCollideConnected ¶
func (*JointDef) SetCollideConnected ¶
func (*JointDef) SetUserData ¶
type JointEdge ¶
type JointEdge struct {
Other *Body // provides quick access to the other body attached.
Joint IJoint // the joint; backed by pointer
Prev *JointEdge // the previous joint edge in the body's joint list
Next *JointEdge // the next joint edge in the body's joint list
}
A joint edge is used to connect bodies and joints together in a joint graph where each body is a node and each joint is an edge. A joint edge belongs to a doubly linked list maintained in each attached body. Each joint has two joint nodes, one for each attached body.
type Manifold ¶
type Manifold struct {
Type ManifoldType
// the points of contact
Points [maxManifoldPoints]ManifoldPoint
// not use for Type::e_points
LocalNormal Vec2
// usage depends on manifold type
LocalPoint Vec2
// the number of manifold points
PointCount int
}
func NewManifold ¶
func NewManifold() *Manifold
type ManifoldPoint ¶
type ManifoldPoint struct {
LocalPoint Vec2 // usage depends on manifold type
NormalImpulse float64 // the non-penetration impulse
TangentImpulse float64 // the friction impulse
Id ContactID // uniquely identifies a contact point between two shapes
}
A manifold point is a contact point belonging to a contact manifold. It holds details related to the geometry and dynamics of the contact points. The local point usage depends on the manifold type: -e_circles: the local center of circleB -e_faceA: the local center of cirlceB or the clip point of polygonB -e_faceB: the clip point of polygonA This structure is stored across time steps, so we keep it small. Note: the impulses are used for internal caching and may not provide reliable contact forces, especially for high speed collisions.
type ManifoldType ¶
type ManifoldType uint8
const ( Circles ManifoldType = 0 FaceA ManifoldType = 1 FaceB ManifoldType = 2 )
type MassData ¶
type MassData struct {
// The mass of the shape, usually in kilograms.
Mass float64
// The position of the shape's centroid relative to the shape's origin.
Center Vec2
// The rotational inertia of the shape about the local origin.
I float64
}
This holds the mass data computed for a shape.
func MakeMassData ¶
func MakeMassData() MassData
func NewMassData ¶
func NewMassData() *MassData
type Mat22 ¶
type Mat22 struct {
Ex, Ey Vec2
}
A 2-by-2 matrix. Stored in column-major order.
func MakeMat22FromColumns ¶
Construct this matrix using columns.
func MakeMat22FromScalars ¶
Construct this matrix using scalars.
func NewMat22FromColumns ¶
func NewMat22FromScalars ¶
func (Mat22) GetInverse ¶
type Mat33 ¶
type Mat33 struct {
Ex, Ey, Ez Vec3
}
A 3-by-3 matrix. Stored in column-major order.
func MakeMat33FromColumns ¶
Construct this matrix using columns.
func NewMat33FromColumns ¶
func (Mat33) GetInverse22 ¶
func (Mat33) GetSymInverse33 ¶
Returns the zero matrix if singular.
type MotorJoint ¶
type MotorJoint struct {
*Joint
// Solver shared
M_linearOffset Vec2
M_angularOffset float64
M_linearImpulse Vec2
M_angularImpulse float64
M_maxForce float64
M_maxTorque float64
M_correctionFactor float64
// Solver temp
M_indexA int
M_indexB int
M_rA Vec2
M_rB Vec2
M_localCenterA Vec2
M_localCenterB Vec2
M_linearError Vec2
M_angularError float64
M_invMassA float64
M_invMassB float64
M_invIA float64
M_invIB float64
M_linearMass Mat22
M_angularMass float64
}
A motor joint is used to control the relative motion between two bodies. A typical usage is to control the movement of a dynamic body with respect to the ground.
func MakeMotorJoint ¶
func MakeMotorJoint(def *MotorJointDef) *MotorJoint
func (*MotorJoint) Dump ¶
func (joint *MotorJoint) Dump()
func (MotorJoint) GetAnchorA ¶
func (joint MotorJoint) GetAnchorA() Vec2
func (MotorJoint) GetAnchorB ¶
func (joint MotorJoint) GetAnchorB() Vec2
func (MotorJoint) GetAngularOffset ¶
func (joint MotorJoint) GetAngularOffset() float64
func (MotorJoint) GetCorrectionFactor ¶
func (joint MotorJoint) GetCorrectionFactor() float64
func (MotorJoint) GetLinearOffset ¶
func (joint MotorJoint) GetLinearOffset() Vec2
func (MotorJoint) GetMaxForce ¶
func (joint MotorJoint) GetMaxForce() float64
func (MotorJoint) GetMaxTorque ¶
func (joint MotorJoint) GetMaxTorque() float64
func (MotorJoint) GetReactionForce ¶
func (joint MotorJoint) GetReactionForce(inv_dt float64) Vec2
func (MotorJoint) GetReactionTorque ¶
func (joint MotorJoint) GetReactionTorque(inv_dt float64) float64
func (*MotorJoint) InitVelocityConstraints ¶
func (joint *MotorJoint) InitVelocityConstraints(data SolverData)
func (*MotorJoint) SetAngularOffset ¶
func (joint *MotorJoint) SetAngularOffset(angularOffset float64)
func (*MotorJoint) SetCorrectionFactor ¶
func (joint *MotorJoint) SetCorrectionFactor(factor float64)
func (*MotorJoint) SetLinearOffset ¶
func (joint *MotorJoint) SetLinearOffset(linearOffset Vec2)
func (*MotorJoint) SetMaxForce ¶
func (joint *MotorJoint) SetMaxForce(force float64)
func (*MotorJoint) SetMaxTorque ¶
func (joint *MotorJoint) SetMaxTorque(torque float64)
func (*MotorJoint) SolvePositionConstraints ¶
func (joint *MotorJoint) SolvePositionConstraints(data SolverData) bool
func (*MotorJoint) SolveVelocityConstraints ¶
func (joint *MotorJoint) SolveVelocityConstraints(data SolverData)
type MotorJointDef ¶
type MotorJointDef struct {
JointDef
// Position of bodyB minus the position of bodyA, in bodyA's frame, in meters.
LinearOffset Vec2
// The bodyB angle minus bodyA angle in radians.
AngularOffset float64
// The maximum motor force in N.
MaxForce float64
// The maximum motor torque in N-m.
MaxTorque float64
// Position correction factor in the range [0,1].
CorrectionFactor float64
}
Motor joint definition.
func MakeMotorJointDef ¶
func MakeMotorJointDef() MotorJointDef
func (*MotorJointDef) Initialize ¶
func (def *MotorJointDef) Initialize(bA *Body, bB *Body)
type MouseJoint ¶
type MouseJoint struct {
*Joint
M_localAnchorB Vec2
M_targetA Vec2
M_stiffness float64
M_damping float64
M_beta float64
// Solver shared
M_impulse Vec2
M_maxForce float64
M_gamma float64
// Solver temp
M_indexA int
M_indexB int
M_rB Vec2
M_localCenterB Vec2
M_invMassB float64
M_invIB float64
M_mass Mat22
M_C Vec2
}
A mouse joint is used to make a point on a body track a specified world point. This a soft constraint with a maximum force. This allows the constraint to stretch and without applying huge forces. NOTE: this joint is not documented in the manual because it was developed to be used in the testbed. If you want to learn how to use the mouse joint, look at the testbed.
func MakeMouseJoint ¶
func MakeMouseJoint(def *MouseJointDef) *MouseJoint
func (MouseJoint) GetAnchorA ¶
func (joint MouseJoint) GetAnchorA() Vec2
func (MouseJoint) GetAnchorB ¶
func (joint MouseJoint) GetAnchorB() Vec2
func (MouseJoint) GetDamping ¶
func (joint MouseJoint) GetDamping() float64
Get linear damping in N*s/m
func (MouseJoint) GetMaxForce ¶
func (joint MouseJoint) GetMaxForce() float64
Get the maximum force in Newtons.
func (MouseJoint) GetReactionForce ¶
func (joint MouseJoint) GetReactionForce(inv_dt float64) Vec2
func (MouseJoint) GetReactionTorque ¶
func (joint MouseJoint) GetReactionTorque(inv_dt float64) float64
func (MouseJoint) GetStiffness ¶
func (joint MouseJoint) GetStiffness() float64
Get the linear stiffness in N/m
func (MouseJoint) GetTarget ¶
func (joint MouseJoint) GetTarget() Vec2
Use this to update the target point.
func (*MouseJoint) InitVelocityConstraints ¶
func (joint *MouseJoint) InitVelocityConstraints(data SolverData)
func (*MouseJoint) SetDamping ¶
func (joint *MouseJoint) SetDamping(damping float64)
Set linear damping in N*s/m
func (*MouseJoint) SetMaxForce ¶
func (joint *MouseJoint) SetMaxForce(force float64)
Set the maximum force in Newtons.
func (*MouseJoint) SetStiffness ¶
func (joint *MouseJoint) SetStiffness(stiffness float64)
Set the linear stiffness in N/m
func (*MouseJoint) SetTarget ¶
func (joint *MouseJoint) SetTarget(target Vec2)
func (*MouseJoint) ShiftOrigin ¶
func (joint *MouseJoint) ShiftOrigin(newOrigin Vec2)
func (*MouseJoint) SolvePositionConstraints ¶
func (joint *MouseJoint) SolvePositionConstraints(data SolverData) bool
func (*MouseJoint) SolveVelocityConstraints ¶
func (joint *MouseJoint) SolveVelocityConstraints(data SolverData)
type MouseJointDef ¶
type MouseJointDef struct {
JointDef
// The initial world target point. This is assumed
// to coincide with the body anchor initially.
Target Vec2
// The maximum constraint force that can be exerted
// to move the candidate body. Usually you will express
// as some multiple of the weight (multiplier * mass * gravity).
MaxForce float64
// The linear stiffness in N/m
Stiffness float64
// The linear damping in N*s/m
Damping float64
}
Mouse joint definition. This requires a world target point, tuning parameters, and the time step.
func MakeMouseJointDef ¶
func MakeMouseJointDef() MouseJointDef
type PairByLessThan ¶
type PairByLessThan []Pair
Was used for sorting the pair buffer to expose duplicates: sort.Sort(PairByLessThan(bp.M_pairBuffer[:bp.M_pairCount]))
func (PairByLessThan) Len ¶
func (a PairByLessThan) Len() int
func (PairByLessThan) Less ¶
func (a PairByLessThan) Less(i, j int) bool
func (PairByLessThan) Swap ¶
func (a PairByLessThan) Swap(i, j int)
type PolygonAndCircleContact ¶
type PolygonAndCircleContact struct {
Contact
}
type PolygonContact ¶
type PolygonContact struct {
Contact
}
type PolygonShape ¶
type PolygonShape struct {
Shape
Centroid Vec2
Vertices [MaxPolygonVertices]Vec2
Normals [MaxPolygonVertices]Vec2
Count int
}
func MakePolygonShape ¶
func MakePolygonShape() PolygonShape
func NewPolygonShape ¶
func NewPolygonShape() *PolygonShape
func (PolygonShape) Clone ¶
func (poly PolygonShape) Clone() IShape
func (PolygonShape) ComputeAABB ¶
func (poly PolygonShape) ComputeAABB(aabb *AABB, xf Transform, childIndex int)
func (PolygonShape) ComputeMass ¶
func (poly PolygonShape) ComputeMass(massData *MassData, density float64)
func (*PolygonShape) Destroy ¶
func (edge *PolygonShape) Destroy()
func (PolygonShape) GetChildCount ¶
func (poly PolygonShape) GetChildCount() int
func (*PolygonShape) GetVertex ¶
func (poly *PolygonShape) GetVertex(index int) *Vec2
func (PolygonShape) RayCast ¶
func (poly PolygonShape) RayCast(output *RayCastOutput, input RayCastInput, xf Transform, childIndex int) bool
@note because the polygon is solid, rays that start inside do not hit because the normal is not defined.
func (*PolygonShape) Set ¶
func (poly *PolygonShape) Set(vertices []Vec2, count int) bool
Create a convex hull from the given array of local points. The count must be in the range [3, b2_maxPolygonVertices]. @warning the points may be re-ordered, even if they form a convex polygon @warning collinear points are handled but not removed. Collinear points may lead to poor stacking behavior.
func (*PolygonShape) SetAsBox ¶
func (poly *PolygonShape) SetAsBox(halfWidth float64, halfHeight float64)
SetAsBox builds vertices to represent an axis-aligned box centered on the local origin.
func (*PolygonShape) SetAsBoxFromCenterAndAngle ¶
func (poly *PolygonShape) SetAsBoxFromCenterAndAngle(hx float64, hy float64, center Vec2, angle float64)
func (*PolygonShape) SetAsHull ¶
func (poly *PolygonShape) SetAsHull(hull Hull)
Create a polygon from a given convex hull (see b2ComputeHull). @warning the hull must be valid or this will crash or have unexpected behavior
func (PolygonShape) Validate ¶
func (poly PolygonShape) Validate() bool
type PositionSolverManifold ¶
func MakePositionSolverManifold ¶
func MakePositionSolverManifold() PositionSolverManifold
func (*PositionSolverManifold) Initialize ¶
func (solvermanifold *PositionSolverManifold) Initialize(pc *ContactPositionConstraint, xfA Transform, xfB Transform, index int)
type PrismaticJoint ¶
type PrismaticJoint struct {
*Joint
M_localAnchorA Vec2
M_localAnchorB Vec2
M_localXAxisA Vec2
M_localYAxisA Vec2
M_referenceAngle float64
M_impulse Vec2
M_motorImpulse float64
M_lowerImpulse float64
M_upperImpulse float64
M_lowerTranslation float64
M_upperTranslation float64
M_maxMotorForce float64
M_motorSpeed float64
M_enableLimit bool
M_enableMotor bool
// Solver temp
M_indexA int
M_indexB int
M_localCenterA Vec2
M_localCenterB Vec2
M_invMassA float64
M_invMassB float64
M_invIA float64
M_invIB float64
M_axis, M_perp Vec2
M_s1, M_s2 float64
M_a1, M_a2 float64
M_K Mat22
M_translation float64
M_axialMass float64
}
A prismatic joint. This joint provides one degree of freedom: translation along an axis fixed in bodyA. Relative rotation is prevented. You can use a joint limit to restrict the range of motion and a joint motor to drive the motion or to model joint friction.
func MakePrismaticJoint ¶
func MakePrismaticJoint(def *PrismaticJointDef) *PrismaticJoint
func (*PrismaticJoint) Dump ¶
func (joint *PrismaticJoint) Dump()
func (*PrismaticJoint) EnableLimit ¶
func (joint *PrismaticJoint) EnableLimit(flag bool)
func (*PrismaticJoint) EnableMotor ¶
func (joint *PrismaticJoint) EnableMotor(flag bool)
func (PrismaticJoint) GetAnchorA ¶
func (joint PrismaticJoint) GetAnchorA() Vec2
func (PrismaticJoint) GetAnchorB ¶
func (joint PrismaticJoint) GetAnchorB() Vec2
func (PrismaticJoint) GetJointSpeed ¶
func (joint PrismaticJoint) GetJointSpeed() float64
func (PrismaticJoint) GetJointTranslation ¶
func (joint PrismaticJoint) GetJointTranslation() float64
func (PrismaticJoint) GetLocalAnchorA ¶
func (joint PrismaticJoint) GetLocalAnchorA() Vec2
The local anchor point relative to bodyA's origin.
func (PrismaticJoint) GetLocalAnchorB ¶
func (joint PrismaticJoint) GetLocalAnchorB() Vec2
The local anchor point relative to bodyB's origin.
func (PrismaticJoint) GetLocalAxisA ¶
func (joint PrismaticJoint) GetLocalAxisA() Vec2
The local joint axis relative to bodyA.
func (PrismaticJoint) GetLowerLimit ¶
func (joint PrismaticJoint) GetLowerLimit() float64
func (PrismaticJoint) GetMaxMotorForce ¶
func (joint PrismaticJoint) GetMaxMotorForce() float64
func (PrismaticJoint) GetMotorForce ¶
func (joint PrismaticJoint) GetMotorForce(inv_dt float64) float64
func (PrismaticJoint) GetMotorSpeed ¶
func (joint PrismaticJoint) GetMotorSpeed() float64
func (PrismaticJoint) GetReactionForce ¶
func (joint PrismaticJoint) GetReactionForce(inv_dt float64) Vec2
func (PrismaticJoint) GetReactionTorque ¶
func (joint PrismaticJoint) GetReactionTorque(inv_dt float64) float64
func (PrismaticJoint) GetReferenceAngle ¶
func (joint PrismaticJoint) GetReferenceAngle() float64
Get the reference angle.
func (PrismaticJoint) GetUpperLimit ¶
func (joint PrismaticJoint) GetUpperLimit() float64
func (*PrismaticJoint) InitVelocityConstraints ¶
func (joint *PrismaticJoint) InitVelocityConstraints(data SolverData)
func (PrismaticJoint) IsLimitEnabled ¶
func (joint PrismaticJoint) IsLimitEnabled() bool
func (PrismaticJoint) IsMotorEnabled ¶
func (joint PrismaticJoint) IsMotorEnabled() bool
func (*PrismaticJoint) SetLimits ¶
func (joint *PrismaticJoint) SetLimits(lower float64, upper float64)
func (*PrismaticJoint) SetMaxMotorForce ¶
func (joint *PrismaticJoint) SetMaxMotorForce(force float64)
func (*PrismaticJoint) SetMotorSpeed ¶
func (joint *PrismaticJoint) SetMotorSpeed(speed float64)
func (*PrismaticJoint) SolvePositionConstraints ¶
func (joint *PrismaticJoint) SolvePositionConstraints(data SolverData) bool
A velocity based solver computes reaction forces(impulses) using the velocity constraint solver.Under this context, the position solver is not there to resolve forces.It is only there to cope with integration error.
Therefore, the pseudo impulses in the position solver do not have any physical meaning.Thus it is okay if they suck.
We could take the active state from the velocity solver.However, the joint might push past the limit when the velocity solver indicates the limit is inactive.
func (*PrismaticJoint) SolveVelocityConstraints ¶
func (joint *PrismaticJoint) SolveVelocityConstraints(data SolverData)
type PrismaticJointDef ¶
type PrismaticJointDef struct {
JointDef
// The local anchor point relative to bodyA's origin.
LocalAnchorA Vec2
// The local anchor point relative to bodyB's origin.
LocalAnchorB Vec2
// The local translation unit axis in bodyA.
LocalAxisA Vec2
// The constrained angle between the bodies: bodyB_angle - bodyA_angle.
ReferenceAngle float64
// Enable/disable the joint limit.
EnableLimit bool
// The lower translation limit, usually in meters.
LowerTranslation float64
// The upper translation limit, usually in meters.
UpperTranslation float64
// Enable/disable the joint motor.
EnableMotor bool
// The maximum motor torque, usually in N-m.
MaxMotorForce float64
// The desired motor speed in radians per second.
MotorSpeed float64
}
Prismatic joint definition. This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game.
func MakePrismaticJointDef ¶
func MakePrismaticJointDef() PrismaticJointDef
func (*PrismaticJointDef) Initialize ¶
func (joint *PrismaticJointDef) Initialize(bA *Body, bB *Body, anchor Vec2, axis Vec2)
type Profile ¶
type Profile struct {
Step float64
Collide float64
Solve float64
SolveInit float64
SolveVelocity float64
SolvePosition float64
Broadphase float64
SolveTOI float64
}
Profiling data. Times are in milliseconds.
type PulleyJoint ¶
type PulleyJoint struct {
*Joint
M_groundAnchorA Vec2
M_groundAnchorB Vec2
M_lengthA float64
M_lengthB float64
// Solver shared
M_localAnchorA Vec2
M_localAnchorB Vec2
M_constant float64
M_ratio float64
M_impulse float64
// Solver temp
M_indexA int
M_indexB int
M_uA Vec2
M_uB Vec2
M_rA Vec2
M_rB Vec2
M_localCenterA Vec2
M_localCenterB Vec2
M_invMassA float64
M_invMassB float64
M_invIA float64
M_invIB float64
M_mass float64
}
The pulley joint is connected to two bodies and two fixed ground points. The pulley supports a ratio such that: length1 + ratio * length2 <= constant Yes, the force transmitted is scaled by the ratio. Warning: the pulley joint can get a bit squirrelly by itself. They often work better when combined with prismatic joints. You should also cover the the anchor points with static shapes to prevent one side from going to zero length.
func MakePulleyJoint ¶
func MakePulleyJoint(def *PulleyJointDef) *PulleyJoint
func (*PulleyJoint) Dump ¶
func (joint *PulleyJoint) Dump()
func (PulleyJoint) GetAnchorA ¶
func (joint PulleyJoint) GetAnchorA() Vec2
func (PulleyJoint) GetAnchorB ¶
func (joint PulleyJoint) GetAnchorB() Vec2
func (PulleyJoint) GetCurrentLengthA ¶
func (joint PulleyJoint) GetCurrentLengthA() float64
func (PulleyJoint) GetCurrentLengthB ¶
func (joint PulleyJoint) GetCurrentLengthB() float64
func (PulleyJoint) GetGroundAnchorA ¶
func (joint PulleyJoint) GetGroundAnchorA() Vec2
func (PulleyJoint) GetGroundAnchorB ¶
func (joint PulleyJoint) GetGroundAnchorB() Vec2
func (PulleyJoint) GetLengthA ¶
func (joint PulleyJoint) GetLengthA() float64
func (PulleyJoint) GetLengthB ¶
func (joint PulleyJoint) GetLengthB() float64
func (PulleyJoint) GetRatio ¶
func (joint PulleyJoint) GetRatio() float64
func (PulleyJoint) GetReactionForce ¶
func (joint PulleyJoint) GetReactionForce(inv_dt float64) Vec2
func (PulleyJoint) GetReactionTorque ¶
func (joint PulleyJoint) GetReactionTorque(inv_dt float64) float64
func (*PulleyJoint) InitVelocityConstraints ¶
func (joint *PulleyJoint) InitVelocityConstraints(data SolverData)
func (*PulleyJoint) ShiftOrigin ¶
func (joint *PulleyJoint) ShiftOrigin(newOrigin Vec2)
func (*PulleyJoint) SolvePositionConstraints ¶
func (joint *PulleyJoint) SolvePositionConstraints(data SolverData) bool
func (*PulleyJoint) SolveVelocityConstraints ¶
func (joint *PulleyJoint) SolveVelocityConstraints(data SolverData)
type PulleyJointDef ¶
type PulleyJointDef struct {
JointDef
// The first ground anchor in world coordinates. This point never moves.
GroundAnchorA Vec2
// The second ground anchor in world coordinates. This point never moves.
GroundAnchorB Vec2
// The local anchor point relative to bodyA's origin.
LocalAnchorA Vec2
// The local anchor point relative to bodyB's origin.
LocalAnchorB Vec2
// The a reference length for the segment attached to bodyA.
LengthA float64
// The a reference length for the segment attached to bodyB.
LengthB float64
// The pulley ratio, used to simulate a block-and-tackle.
Ratio float64
}
Pulley joint definition. This requires two ground anchors, two dynamic body anchor points, and a pulley ratio.
func MakePulleyJointDef ¶
func MakePulleyJointDef() PulleyJointDef
func (*PulleyJointDef) Initialize ¶
type RayCastInput ¶
Ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
type RayCastOutput ¶
Ray-cast output data. The ray hits at p1 + fraction * (p2 - p1), where p1 and p2 come from b2RayCastInput.
func MakeRayCastOutput ¶
func MakeRayCastOutput() RayCastOutput
type RaycastCallback ¶
Called for each fixture found in the query. You control how the ray cast proceeds by returning a float: return -1: ignore this fixture and continue return 0: terminate the ray cast return fraction: clip the ray to this point return 1: don't clip the ray and continue @param fixture the fixture hit by the ray @param point the point of initial intersection @param normal the normal vector at the point of intersection @return -1 to filter, 0 to terminate, fraction to clip the ray for closest hit, 1 to continue
type RevoluteJoint ¶
type RevoluteJoint struct {
*Joint
// Solver shared
M_localAnchorA Vec2
M_localAnchorB Vec2
M_motorImpulse float64
M_lowerImpulse float64
M_upperImpulse float64
M_enableMotor bool
M_maxMotorTorque float64
M_motorSpeed float64
M_enableLimit bool
M_referenceAngle float64
M_lowerAngle float64
M_upperAngle float64
// Solver temp
M_indexA int
M_indexB int
M_rA Vec2
M_rB Vec2
M_localCenterA Vec2
M_localCenterB Vec2
M_invMassA float64
M_invMassB float64
M_invIA float64
M_invIB float64
M_K Mat22
M_angle float64
M_axialMass float64
// contains filtered or unexported fields
}
A revolute joint constrains two bodies to share a common point while they are free to rotate about the point. The relative rotation about the shared point is the joint angle. You can limit the relative rotation with a joint limit that specifies a lower and upper angle. You can use a motor to drive the relative rotation about the shared point. A maximum motor torque is provided so that infinite forces are not generated.
func MakeRevoluteJoint ¶
func MakeRevoluteJoint(def *RevoluteJointDef) *RevoluteJoint
func (*RevoluteJoint) Dump ¶
func (joint *RevoluteJoint) Dump()
func (*RevoluteJoint) EnableLimit ¶
func (joint *RevoluteJoint) EnableLimit(flag bool)
func (*RevoluteJoint) EnableMotor ¶
func (joint *RevoluteJoint) EnableMotor(flag bool)
func (RevoluteJoint) GetAnchorA ¶
func (joint RevoluteJoint) GetAnchorA() Vec2
func (RevoluteJoint) GetAnchorB ¶
func (joint RevoluteJoint) GetAnchorB() Vec2
func (RevoluteJoint) GetJointAngle ¶
func (joint RevoluteJoint) GetJointAngle() float64
func (*RevoluteJoint) GetJointSpeed ¶
func (joint *RevoluteJoint) GetJointSpeed() float64
func (RevoluteJoint) GetLocalAnchorA ¶
func (joint RevoluteJoint) GetLocalAnchorA() Vec2
The local anchor point relative to bodyA's origin.
func (RevoluteJoint) GetLocalAnchorB ¶
func (joint RevoluteJoint) GetLocalAnchorB() Vec2
The local anchor point relative to bodyB's origin.
func (RevoluteJoint) GetLowerLimit ¶
func (joint RevoluteJoint) GetLowerLimit() float64
func (RevoluteJoint) GetMaxMotorTorque ¶
func (joint RevoluteJoint) GetMaxMotorTorque() float64
func (RevoluteJoint) GetMotorSpeed ¶
func (joint RevoluteJoint) GetMotorSpeed() float64
func (RevoluteJoint) GetMotorTorque ¶
func (joint RevoluteJoint) GetMotorTorque(inv_dt float64) float64
func (RevoluteJoint) GetReactionForce ¶
func (joint RevoluteJoint) GetReactionForce(inv_dt float64) Vec2
func (RevoluteJoint) GetReactionTorque ¶
func (joint RevoluteJoint) GetReactionTorque(inv_dt float64) float64
func (RevoluteJoint) GetReferenceAngle ¶
func (joint RevoluteJoint) GetReferenceAngle() float64
Get the reference angle.
func (RevoluteJoint) GetUpperLimit ¶
func (joint RevoluteJoint) GetUpperLimit() float64
func (*RevoluteJoint) InitVelocityConstraints ¶
func (joint *RevoluteJoint) InitVelocityConstraints(data SolverData)
func (RevoluteJoint) IsLimitEnabled ¶
func (joint RevoluteJoint) IsLimitEnabled() bool
func (RevoluteJoint) IsMotorEnabled ¶
func (joint RevoluteJoint) IsMotorEnabled() bool
func (*RevoluteJoint) SetLimits ¶
func (joint *RevoluteJoint) SetLimits(lower float64, upper float64)
func (*RevoluteJoint) SetMaxMotorTorque ¶
func (joint *RevoluteJoint) SetMaxMotorTorque(torque float64)
func (*RevoluteJoint) SetMotorSpeed ¶
func (joint *RevoluteJoint) SetMotorSpeed(speed float64)
func (*RevoluteJoint) SolvePositionConstraints ¶
func (joint *RevoluteJoint) SolvePositionConstraints(data SolverData) bool
func (*RevoluteJoint) SolveVelocityConstraints ¶
func (joint *RevoluteJoint) SolveVelocityConstraints(data SolverData)
type RevoluteJointDef ¶
type RevoluteJointDef struct {
JointDef
// The local anchor point relative to bodyA's origin.
LocalAnchorA Vec2
// The local anchor point relative to bodyB's origin.
LocalAnchorB Vec2
// The bodyB angle minus bodyA angle in the reference state (radians).
ReferenceAngle float64
// A flag to enable joint limits.
EnableLimit bool
// The lower angle for the joint limit (radians).
LowerAngle float64
// The upper angle for the joint limit (radians).
UpperAngle float64
// A flag to enable the joint motor.
EnableMotor bool
// The desired motor speed. Usually in radians per second.
MotorSpeed float64
// The maximum motor torque used to achieve the desired motor speed.
// Usually in N-m.
MaxMotorTorque float64
}
Revolute joint definition. This requires defining an anchor point where the bodies are joined. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. You also need to specify the initial relative angle for joint limits. This helps when saving and loading a game. The local anchor points are measured from the body's origin rather than the center of mass because:
- you might not know where the center of mass will be.
- if you add/remove shapes from a body and recompute the mass, the joints will be broken.
func MakeRevoluteJointDef ¶
func MakeRevoluteJointDef() RevoluteJointDef
func (*RevoluteJointDef) Initialize ¶
func (def *RevoluteJointDef) Initialize(bA *Body, bB *Body, anchor Vec2)
type Rope ¶
type Rope struct {
M_position Vec2
M_count int
M_stretchCount int
M_bendCount int
M_stretchConstraints []RopeStretch
M_bendConstraints []RopeBend
M_bindPositions []Vec2
M_ps []Vec2
M_p0s []Vec2
M_vs []Vec2
M_invMasses []float64
M_gravity Vec2
M_tuning RopeTuning
}
func (*Rope) ApplyBendForces ¶
func (Rope) GetVertexCount ¶
func (Rope) GetVertices ¶
func (*Rope) SetTuning ¶
func (rope *Rope) SetTuning(tuning RopeTuning)
func (*Rope) SolveBend_PBD_Angle ¶
func (rope *Rope) SolveBend_PBD_Angle()
func (*Rope) SolveBend_PBD_Distance ¶
func (rope *Rope) SolveBend_PBD_Distance()
func (*Rope) SolveBend_PBD_Height ¶
func (rope *Rope) SolveBend_PBD_Height()
Constraint based implementation of: P. Volino: Simple Linear Bending Stiffness in Particle Systems
func (*Rope) SolveBend_PBD_Triangle ¶
func (rope *Rope) SolveBend_PBD_Triangle()
M. Kelager: A Triangle Bending Constraint Model for PBD
func (*Rope) SolveBend_XPBD_Angle ¶
func (*Rope) SolveStretch_PBD ¶
func (rope *Rope) SolveStretch_PBD()
func (*Rope) SolveStretch_XPBD ¶
type RopeDef ¶
type RopeDef struct {
Position Vec2
Vertices []Vec2
Count int
Masses []float64
Gravity Vec2
Tuning RopeTuning
}
func MakeRopeDef ¶
func MakeRopeDef() RopeDef
type RopeStretch ¶
type RopeTuning ¶
type RopeTuning struct {
StretchingModel uint8
BendingModel uint8
Damping float64
StretchStiffness float64
StretchHertz float64
StretchDamping float64
BendStiffness float64
BendHertz float64
BendDamping float64
Isometric bool
FixedEffectiveMass bool
WarmStart bool
}
func MakeRopeTuning ¶
func MakeRopeTuning() RopeTuning
type Rot ¶
type Rot struct {
/// Sine and cosine
Sine, Cosine float64
}
Rotation
func MakeRotFromAngle ¶
Initialize from an angle in radians
func NewRotFromAngle ¶
type SeparationFunction ¶
type SeparationFunction struct {
M_proxyA *DistanceProxy
M_proxyB *DistanceProxy
M_sweepA, M_sweepB Sweep
M_type uint8
M_localPoint Vec2
M_axis Vec2
}
func (*SeparationFunction) Evaluate ¶
func (sepfunc *SeparationFunction) Evaluate(indexA int, indexB int, t float64) float64
func (*SeparationFunction) FindMinSeparation ¶
func (sepfunc *SeparationFunction) FindMinSeparation(indexA *int, indexB *int, t float64) float64
func (*SeparationFunction) Initialize ¶
func (sepfunc *SeparationFunction) Initialize(cache *simplexCache, proxyA *DistanceProxy, sweepA Sweep, proxyB *DistanceProxy, sweepB Sweep, t1 float64) float64
TODO_ERIN might not need to return the separation
type Shape ¶
type ShapeCastInput ¶
type ShapeCastInput struct {
ProxyA DistanceProxy
ProxyB DistanceProxy
TransformA Transform
TransformB Transform
TranslationB Vec2
}
Input parameters for b2ShapeCast
func MakeShapeCastInput ¶
func MakeShapeCastInput() ShapeCastInput
type ShapeCastOutput ¶
Output results for b2ShapeCast
type Simplex ¶
type Simplex struct {
M_vs [3]SimplexVertex
M_count int
}
func MakeSimplex ¶
func MakeSimplex() Simplex
func (Simplex) GetClosestPoint ¶
func (Simplex) GetSearchDirection ¶
func (Simplex) GetWitnessPoints ¶
func (*Simplex) ReadCache ¶
func (simplex *Simplex) ReadCache(cache *simplexCache, proxyA *DistanceProxy, transformA Transform, proxyB *DistanceProxy, transformB Transform)
func (*Simplex) Solve2 ¶
func (simplex *Simplex) Solve2()
Solve a line segment using barycentric coordinates.
func (*Simplex) Solve3 ¶
func (simplex *Simplex) Solve3()
Possible regions: - points[2] - edge points[0]-points[2] - edge points[1]-points[2] - inside the triangle
func (Simplex) WriteCache ¶
func (simplex Simplex) WriteCache(cache *simplexCache)
type SimplexVertex ¶
type SimplexVertex struct {
WA Vec2 // support point in proxyA
WB Vec2 // support point in proxyB
W Vec2 // wB - wA
A float64 // barycentric coordinate for closest point
IndexA int // wA index
IndexB int // wB index
}
func MakeSimplexVertex ¶
func MakeSimplexVertex() SimplexVertex
type SolverData ¶
type SolverData struct {
Step TimeStep
Positions []position
Velocities []velocity
}
Solver Data
type Sweep ¶
type Sweep struct {
LocalCenter Vec2 // local center of mass position
C0, C Vec2 // center world positions
A0, A float64 // world angles
// Fraction of the current time step in the range [0,1]
// c0 and a0 are the positions at alpha0.
Alpha0 float64
}
type TOIInput ¶
type TOIInput struct {
ProxyA DistanceProxy
ProxyB DistanceProxy
SweepA Sweep
SweepB Sweep
TMax float64 // defines sweep interval [0, tMax]
}
Input parameters for b2TimeOfImpact
func MakeTOIInput ¶
func MakeTOIInput() TOIInput
type TOIOutput ¶
type TOIOutput struct {
State ToiOutputState
T float64
}
func MakeTOIOutput ¶
func MakeTOIOutput() TOIOutput
type TimeStep ¶
type TimeStep struct {
Dt float64 // time step
Inv_dt float64 // inverse time step (0 if dt == 0).
DtRatio float64 // dt * inv_dt0
VelocityIterations int
PositionIterations int
WarmStarting bool
}
This is an internal structure.
func MakeTimeStep ¶
func MakeTimeStep() TimeStep
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer for profiling. This has platform specific code and may not work on every platform.
func (Timer) GetMilliseconds ¶
type ToiOutputState ¶
type ToiOutputState uint8
type Transform ¶
A transform contains translation and rotation. It is used to represent the position and orientation of rigid frames.
func MakeTransformByPositionAndRotation ¶
Initialize using a position vector and a rotation.
func NewTransform ¶
func NewTransform() *Transform
func TransformMul ¶
func TransformMulT ¶
func (*Transform) SetIdentity ¶
func (t *Transform) SetIdentity()
Set this to the identity transform.
type TreeNode ¶
type TreeQueryCallback ¶
type TreeRayCastCallback ¶
type TreeRayCastCallback func(input RayCastInput, nodeId int) float64
type Vec2 ¶
type Vec2 struct {
X, Y float64
}
A 2D column vector.
func ComputeCentroid ¶
func ProjectPointOnLine ¶
Get projected point p' of p on line v1,v2
func TransformVec2Mul ¶
func TransformVec2MulT ¶
func Vec2CrossScalarVector ¶
Perform the cross product on a scalar and a vector. In 2D this produces a vector.
func Vec2CrossVectorScalar ¶
Perform the cross product on a vector and a scalar. In 2D this produces a vector.
func Vec2Mat22Mul ¶
Multiply a matrix times a vector. If a rotation matrix is provided, then this transforms the vector from one frame to another.
func Vec2Mat22MulT ¶
Multiply a matrix transpose times a vector. If a rotation matrix is provided, then this transforms the vector from one frame to another (inverse transform).
func Vec2MulScalar ¶
func (Vec2) LengthSquared ¶
Get the length squared. For performance, use this instead of b2Vec2::Length (if possible).
func (Vec2) OperatorIndexGet ¶
Read from and indexed element.
func (*Vec2) OperatorIndexSet ¶
Write to an indexed element.
func (*Vec2) OperatorMinusInplace ¶
Subtract a vector from this vector.
func (*Vec2) OperatorPlusInplace ¶
Add a vector to this vector.
func (*Vec2) OperatorScalarMulInplace ¶
Multiply this vector by a scalar.
type Vec3 ¶
type Vec3 struct {
X, Y, Z float64
}
A 2D column vector with 3 elements.
func Vec3MultScalar ¶
func (*Vec3) OperatorMinusInplace ¶
Subtract a vector from this vector.
func (*Vec3) OperatorPlusInplace ¶
Add a vector to this vector.
func (*Vec3) OperatorScalarMulInplace ¶
Multiply this vector by a scalar.
type VelocityConstraintPoint ¶
type WeldJoint ¶
type WeldJoint struct {
*Joint
M_stiffness float64
M_damping float64
M_bias float64
// Solver shared
M_localAnchorA Vec2
M_localAnchorB Vec2
M_referenceAngle float64
M_gamma float64
M_impulse Vec3
// Solver temp
M_indexA int
M_indexB int
M_rA Vec2
M_rB Vec2
M_localCenterA Vec2
M_localCenterB Vec2
M_invMassA float64
M_invMassB float64
M_invIA float64
M_invIB float64
M_mass Mat33
}
A weld joint essentially glues two bodies together. A weld joint may distort somewhat because the island constraint solver is approximate.
func MakeWeldJoint ¶
func MakeWeldJoint(def *WeldJointDef) *WeldJoint
func (WeldJoint) GetAnchorA ¶
func (WeldJoint) GetAnchorB ¶
func (WeldJoint) GetLocalAnchorA ¶
The local anchor point relative to bodyA's origin.
func (WeldJoint) GetLocalAnchorB ¶
The local anchor point relative to bodyB's origin.
func (WeldJoint) GetReactionForce ¶
func (WeldJoint) GetReactionTorque ¶
func (WeldJoint) GetReferenceAngle ¶
Get the reference angle.
func (*WeldJoint) InitVelocityConstraints ¶
func (joint *WeldJoint) InitVelocityConstraints(data SolverData)
func (*WeldJoint) SetDamping ¶
Set damping in N*m*s
func (*WeldJoint) SetStiffness ¶
Set stiffness in N*m
func (*WeldJoint) SolvePositionConstraints ¶
func (joint *WeldJoint) SolvePositionConstraints(data SolverData) bool
func (*WeldJoint) SolveVelocityConstraints ¶
func (joint *WeldJoint) SolveVelocityConstraints(data SolverData)
type WeldJointDef ¶
type WeldJointDef struct {
JointDef
// The local anchor point relative to bodyA's origin.
LocalAnchorA Vec2
// The local anchor point relative to bodyB's origin.
LocalAnchorB Vec2
// The bodyB angle minus bodyA angle in the reference state (radians).
ReferenceAngle float64
// The rotational stiffness in N*m
// Disable softness with a value of 0
Stiffness float64
// The rotational damping in N*m*s
Damping float64
}
Weld joint definition. You need to specify local anchor points where they are attached and the relative body angle. The position of the anchor points is important for computing the reaction torque.
func MakeWeldJointDef ¶
func MakeWeldJointDef() WeldJointDef
func (*WeldJointDef) Initialize ¶
func (def *WeldJointDef) Initialize(bA *Body, bB *Body, anchor Vec2)
Initialize the bodies, anchors, reference angle, stiffness, and damping. @param bodyA the first body connected by this joint @param bodyB the second body connected by this joint @param anchor the point of connection in world coordinates
type WheelJoint ¶
type WheelJoint struct {
*Joint
M_localAnchorA Vec2
M_localAnchorB Vec2
M_localXAxisA Vec2
M_localYAxisA Vec2
M_impulse float64
M_motorImpulse float64
M_springImpulse float64
M_lowerImpulse float64
M_upperImpulse float64
M_translation float64
M_lowerTranslation float64
M_upperTranslation float64
M_maxMotorTorque float64
M_motorSpeed float64
M_enableLimit bool
M_enableMotor bool
M_stiffness float64
M_damping float64
// Solver temp
M_indexA int
M_indexB int
M_localCenterA Vec2
M_localCenterB Vec2
M_invMassA float64
M_invMassB float64
M_invIA float64
M_invIB float64
M_ax Vec2
M_ay Vec2
M_sAx float64
M_sBx float64
M_sAy float64
M_sBy float64
M_mass float64
M_motorMass float64
M_axialMass float64
M_springMass float64
M_bias float64
M_gamma float64
}
A wheel joint. This joint provides two degrees of freedom: translation along an axis fixed in bodyA and rotation in the plane. In other words, it is a point to line constraint with a rotational motor and a linear spring/damper. The spring/damper is initialized upon creation. This joint is designed for vehicle suspensions.
func MakeWheelJoint ¶
func MakeWheelJoint(def *WheelJointDef) *WheelJoint
func (*WheelJoint) Dump ¶
func (joint *WheelJoint) Dump()
func (WheelJoint) EnableLimit ¶
func (joint WheelJoint) EnableLimit(flag bool)
Enable/disable the joint translation limit.
func (*WheelJoint) EnableMotor ¶
func (joint *WheelJoint) EnableMotor(flag bool)
func (WheelJoint) GetAnchorA ¶
func (joint WheelJoint) GetAnchorA() Vec2
func (WheelJoint) GetAnchorB ¶
func (joint WheelJoint) GetAnchorB() Vec2
func (WheelJoint) GetJointAngle ¶
func (joint WheelJoint) GetJointAngle() float64
func (WheelJoint) GetJointAngularSpeed ¶
func (joint WheelJoint) GetJointAngularSpeed() float64
func (WheelJoint) GetJointLinearSpeed ¶
func (joint WheelJoint) GetJointLinearSpeed() float64
func (WheelJoint) GetJointTranslation ¶
func (joint WheelJoint) GetJointTranslation() float64
func (WheelJoint) GetLocalAnchorA ¶
func (joint WheelJoint) GetLocalAnchorA() Vec2
The local anchor point relative to bodyA's origin.
func (WheelJoint) GetLocalAnchorB ¶
func (joint WheelJoint) GetLocalAnchorB() Vec2
The local anchor point relative to bodyB's origin.
func (WheelJoint) GetLocalAxisA ¶
func (joint WheelJoint) GetLocalAxisA() Vec2
The local joint axis relative to bodyA.
func (WheelJoint) GetLowerLimit ¶
func (joint WheelJoint) GetLowerLimit() float64
Get the lower joint translation limit, usually in meters.
func (WheelJoint) GetMaxMotorTorque ¶
func (joint WheelJoint) GetMaxMotorTorque() float64
func (WheelJoint) GetMotorSpeed ¶
func (joint WheelJoint) GetMotorSpeed() float64
func (WheelJoint) GetMotorTorque ¶
func (joint WheelJoint) GetMotorTorque(inv_dt float64) float64
func (WheelJoint) GetReactionForce ¶
func (joint WheelJoint) GetReactionForce(inv_dt float64) Vec2
func (WheelJoint) GetReactionTorque ¶
func (joint WheelJoint) GetReactionTorque(inv_dt float64) float64
func (WheelJoint) GetStiffness ¶
func (joint WheelJoint) GetStiffness() float64
Access spring stiffness
func (WheelJoint) GetUpperLimit ¶
func (joint WheelJoint) GetUpperLimit() float64
Get the upper joint translation limit, usually in meters.
func (*WheelJoint) InitVelocityConstraints ¶
func (joint *WheelJoint) InitVelocityConstraints(data SolverData)
func (WheelJoint) IsLimitEnabled ¶
func (joint WheelJoint) IsLimitEnabled() bool
Is the joint limit enabled?
func (WheelJoint) IsMotorEnabled ¶
func (joint WheelJoint) IsMotorEnabled() bool
func (WheelJoint) SetLimits ¶
func (joint WheelJoint) SetLimits(lower float64, upper float64)
Set the joint translation limits, usually in meters.
func (*WheelJoint) SetMaxMotorTorque ¶
func (joint *WheelJoint) SetMaxMotorTorque(torque float64)
func (*WheelJoint) SetMotorSpeed ¶
func (joint *WheelJoint) SetMotorSpeed(speed float64)
func (*WheelJoint) SetStiffness ¶
func (joint *WheelJoint) SetStiffness(stiffness float64)
Access spring stiffness
func (*WheelJoint) SolvePositionConstraints ¶
func (joint *WheelJoint) SolvePositionConstraints(data SolverData) bool
func (*WheelJoint) SolveVelocityConstraints ¶
func (joint *WheelJoint) SolveVelocityConstraints(data SolverData)
type WheelJointDef ¶
type WheelJointDef struct {
JointDef
// The local anchor point relative to bodyA's origin.
LocalAnchorA Vec2
// The local anchor point relative to bodyB's origin.
LocalAnchorB Vec2
// The local translation axis in bodyA.
LocalAxisA Vec2
// Enable/disable the joint limit.
EnableLimit bool
// The lower translation limit, usually in meters.
LowerTranslation float64
// The upper translation limit, usually in meters.
UpperTranslation float64
// Enable/disable the joint motor.
EnableMotor bool
// The maximum motor torque, usually in N-m.
MaxMotorTorque float64
// The desired motor speed in radians per second.
MotorSpeed float64
// Suspension stiffness. Typically in units N/m.
Stiffness float64
// Suspension damping. Typically in units of N*s/m.
Damping float64
}
Wheel joint definition. This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game.
func MakeWheelJointDef ¶
func MakeWheelJointDef() WheelJointDef
func (*WheelJointDef) Initialize ¶
func (def *WheelJointDef) Initialize(bA *Body, bB *Body, anchor Vec2, axis Vec2)
type World ¶
type World struct {
// contains filtered or unexported fields
}
World struct manages all physics entities, dynamic simulation, and asynchronous queries. The world also contains efficient memory management facilities.
func (*World) ClearForces ¶
func (world *World) ClearForces()
func (*World) CreateBody ¶
func (*World) CreateJoint ¶
func (*World) DestroyBody ¶
func (*World) DestroyJoint ¶
func (World) GetAutoClearForces ¶
Get the flag that controls automatic clearing of forces after each time step.
func (World) GetBodyCount ¶
func (World) GetBodyList ¶
func (World) GetContactCount ¶
func (World) GetContactList ¶
Get the world contact list. With the returned contact, use Contact.GetNext() to get the next contact in the world list. A nullptr contact indicates the end of the list.
func (World) GetContactManager ¶
func (world World) GetContactManager() ContactManager
func (World) GetGravity ¶
func (World) GetJointCount ¶
func (World) GetJointList ¶
func (World) GetProfile ¶
func (World) GetProxyCount ¶
func (World) GetTreeBalance ¶
func (World) GetTreeHeight ¶
func (World) GetTreeQuality ¶
func (*World) QueryAABB ¶
func (world *World) QueryAABB(callback BroadPhaseQueryCallback, aabb AABB)
func (*World) RayCast ¶
func (world *World) RayCast(callback RaycastCallback, point1 Vec2, point2 Vec2)
func (*World) SetAllowSleeping ¶
func (*World) SetAutoClearForces ¶
func (*World) SetContactFilter ¶
func (world *World) SetContactFilter(filter IContactFilter)
func (*World) SetContactListener ¶
func (world *World) SetContactListener(listener IContactListener)
func (*World) SetDestructionListener ¶
func (world *World) SetDestructionListener(listener IDestructionListener)
func (*World) SetGravity ¶
func (*World) ShiftOrigin ¶
type WorldManifold ¶
type WorldManifold struct {
Normal Vec2 // world vector pointing from A to B
Points [maxManifoldPoints]Vec2 // world contact point (point of intersection)
Separations [maxManifoldPoints]float64 // a negative value indicates overlap, in meters
}
This is used to compute the current state of a contact manifold.
func (*WorldManifold) Initialize ¶
type WorldQueryWrapper ¶
type WorldQueryWrapper struct {
BroadPhase *BroadPhase
Callback BroadPhaseQueryCallback
}
func MakeWorldQueryWrapper ¶
func MakeWorldQueryWrapper() WorldQueryWrapper
func (*WorldQueryWrapper) QueryCallback ¶
func (query *WorldQueryWrapper) QueryCallback(proxyId int) bool
Source Files
¶
- coll_broadphase.go
- coll_collide_circle.go
- coll_collide_edge.go
- coll_collide_polygon.go
- coll_collision.go
- coll_distance.go
- coll_dynamic_tree.go
- coll_shape.go
- coll_shape_chain.go
- coll_shape_circle.go
- coll_shape_edge.go
- coll_shape_polygon.go
- coll_time_of_impact.go
- common.go
- common_growable_stack.go
- common_math.go
- common_settings.go
- common_timer.go
- dyn_Joint_pulley.go
- dyn_Joint_revolute.go
- dyn_body.go
- dyn_contact.go
- dyn_contact_chain_and_circle.go
- dyn_contact_chain_and_polygon.go
- dyn_contact_circle.go
- dyn_contact_edge_and_circle.go
- dyn_contact_edge_and_polygon.go
- dyn_contact_manager.go
- dyn_contact_polygon.go
- dyn_contact_polygon_and_circle.go
- dyn_contact_solver.go
- dyn_fixture.go
- dyn_island.go
- dyn_joint.go
- dyn_joint_distance.go
- dyn_joint_friction.go
- dyn_joint_gear.go
- dyn_joint_motor.go
- dyn_joint_mouse.go
- dyn_joint_prismatic.go
- dyn_joint_weld.go
- dyn_joint_wheel.go
- dyn_rope.go
- dyn_time_step.go
- dyn_world.go
- dyn_world_callbacks.go