Documentation
¶
Overview ¶
Package cbridge wraps Box2D v3 (C) via CGO for the physics2d plugin. All Box2D state lives on the C side; Go interacts through entity IDs.
Index ¶
- Constants
- func AddBoxShape(entityID uint32, shapeIndex int, offsetX, offsetY float64, ...) bool
- func AddCapsuleShape(entityID uint32, shapeIndex int, c1x, c1y, c2x, c2y, radius float64, ...) bool
- func AddChainShape(entityID uint32, shapeIndex int, points []Vec2, isLoop bool, ...) bool
- func AddCircleShape(entityID uint32, shapeIndex int, offsetX, offsetY, radius float64, ...) bool
- func AddPolygonShape(entityID uint32, shapeIndex int, verts []Vec2, ...) bool
- func AddSegmentShape(entityID uint32, shapeIndex int, v1x, v1y, v2x, v2y float64, isSensor bool, ...) bool
- func CreateBody(entityID uint32, bodyType uint8, px, py, angle float64, vx, vy, av float64, ...) bool
- func CreateWorld(gx, gy float64)
- func DestroyAllBodies()
- func DestroyAllShapes(entityID uint32)
- func DestroyBody(entityID uint32)
- func DestroyWorld()
- func GetWorldID() uint32
- func ResetMassData(entityID uint32)
- func SetAngularDamping(entityID uint32, damping float64)
- func SetAngularVelocity(entityID uint32, av float64)
- func SetAwake(entityID uint32, awake bool)
- func SetBodyEnabled(entityID uint32, enabled bool)
- func SetBodyType(entityID uint32, bodyType uint8)
- func SetBullet(entityID uint32, flag bool)
- func SetFixedRotation(entityID uint32, flag bool)
- func SetGravity(gx, gy float64)
- func SetGravityScale(entityID uint32, scale float64)
- func SetLinearDamping(entityID uint32, damping float64)
- func SetLinearVelocity(entityID uint32, vx, vy float64)
- func SetShapeDensity(entityID uint32, shapeIndex int, density float64)
- func SetShapeFilter(entityID uint32, shapeIndex int, cat, mask uint64, group int32)
- func SetShapeFriction(entityID uint32, shapeIndex int, friction float64)
- func SetShapeRestitution(entityID uint32, shapeIndex int, restitution float64)
- func SetSleepEnabled(entityID uint32, enabled bool)
- func SetTransform(entityID uint32, px, py, angle float64)
- func Step(dt float64, subStepCount int) ([]BodyState, []ContactEvent)
- func WorldExists() bool
- type BodyState
- type CircleSweepResult
- type ContactEvent
- type OverlapHit
- type RaycastResult
- type Vec2
Constants ¶
View Source
const ( ContactBegin uint8 = C.BRIDGE_CONTACT_BEGIN ContactEnd uint8 = C.BRIDGE_CONTACT_END )
Variables ¶
This section is empty.
Functions ¶
func AddBoxShape ¶
func AddCapsuleShape ¶
func AddChainShape ¶
func AddCircleShape ¶
func AddPolygonShape ¶
func AddSegmentShape ¶
func CreateBody ¶
func CreateWorld ¶
func CreateWorld(gx, gy float64)
func DestroyAllBodies ¶
func DestroyAllBodies()
func DestroyAllShapes ¶
func DestroyAllShapes(entityID uint32)
func DestroyBody ¶
func DestroyBody(entityID uint32)
func DestroyWorld ¶
func DestroyWorld()
func GetWorldID ¶
func GetWorldID() uint32
GetWorldID returns the Box2D world id packed as uint32 (0 = no world).
func ResetMassData ¶
func ResetMassData(entityID uint32)
func SetAngularDamping ¶
func SetAngularVelocity ¶
func SetBodyEnabled ¶
func SetBodyType ¶
func SetFixedRotation ¶
func SetGravity ¶
func SetGravity(gx, gy float64)
func SetGravityScale ¶
func SetLinearDamping ¶
func SetLinearVelocity ¶
func SetShapeDensity ¶
func SetShapeFilter ¶
func SetShapeFriction ¶
func SetShapeRestitution ¶
func SetSleepEnabled ¶
func SetTransform ¶
func Step ¶
func Step(dt float64, subStepCount int) ([]BodyState, []ContactEvent)
Step advances the active C-side world and returns body states and contact events. Not safe to call concurrently — cbridge owns single-world global state (the C-side world itself).
func WorldExists ¶
func WorldExists() bool
Types ¶
type CircleSweepResult ¶
type CircleSweepResult struct {
Hit bool
EntityID uint32
ShapeIndex int
PX, PY float64
NX, NY float64
Fraction float64
}
func CircleSweep ¶
func CircleSweep(sx, sy, ex, ey, radius float64, cat, mask uint64, includeSensors bool, maxFraction float64, ) CircleSweepResult
type ContactEvent ¶
type ContactEvent struct {
Kind uint8
EntityA, EntityB uint32
ShapeIndexA int
ShapeIndexB int
IsSensor bool
CatA, MaskA uint64
GroupA int32
CatB, MaskB uint64
GroupB int32
NormalX, NormalY float64
NormalValid bool
PointX, PointY float64
PointValid bool
ManifoldPointCount int
}
func GatherLiveContacts ¶
func GatherLiveContacts() []ContactEvent
type OverlapHit ¶
func OverlapAABB ¶
func OverlapAABB(minX, minY, maxX, maxY float64, cat, mask uint64, includeSensors bool) []OverlapHit
Click to show internal directories.
Click to hide internal directories.