Namespace Gym.Box2D
Classes
- Box2DConvert
The argument conversions of pybox2d's SWIG layer: a Python float passed where C++ takes a
float32rounds to the nearest float32, and values beyond its range are refused rather than becoming infinities.
- b2Body
A rigid body. Created by b2World, never directly; its fixtures, contacts and joints die with it.
- b2BodyDef
A body definition: everything a body is created from (pybox2d's
b2BodyDef). Reusable.
- b2CircleShape
A solid circle of radius
m_radiusaround the local pointm_p.
- b2Contact
The contact between two fixtures whose fat boxes overlap: its manifold, touching state, friction and restitution. The world creates and destroys contacts; a contact exists while the boxes overlap, touching or not.
- b2ContactEdge
A contact edge: connects a body to a contact in the body's contact list (pybox2d's
b2ContactEdge, whatbody.contactsholds). Each contact has two, one per body.
- b2ContactFilter
Decides whether two fixtures may collide; the default reads their b2Filters.
- b2ContactListener
Told about contacts as they begin and end touching (pybox2d's
contactListener, which Gymnasium's envs subclass asContactDetector). The callbacks run inside Step(double, int, int), while the world is locked.
- b2DestructionListener
Told when the world destroys joints and fixtures implicitly, because their body was destroyed.
- b2EdgeShape
A line segment from
m_vertex1tom_vertex2, with optional ghost neighbours (m_vertex0,m_vertex3) for smooth collision along connected edges. Edges have no mass and contain no point.
- b2Fixture
A shape attached to a body, with its density, friction, restitution and filter. Created by b2Body, never directly; destroying its body destroys it.
- b2FixtureDef
A fixture definition (pybox2d's
fixtureDef): the shape and material a b2Body creates a fixture from. The shape is cloned into the fixture, so one definition can create many fixtures.
- b2Joint
A constraint between two bodies, solved with the contacts in each island. Created by b2World; destroying either body destroys it.
- b2JointDef
The definition shared by every joint: the type, the two bodies, and whether they collide with each other.
- b2JointEdge
A joint edge: connects a body to a joint in the body's joint list. Each joint has two, one per body.
- b2PolygonShape
A solid convex polygon of 3 to 16 vertices in counter-clockwise order, with the polygon skin radius. Setting vertices builds their convex hull (gift wrapping), so collinear and interior points are dropped and the order may change.
- b2QueryCallback
Told about each fixture whose fat box overlaps a QueryAABB(b2QueryCallback, in b2AABB) box.
- b2RayCastCallback
Told about each fixture a RayCast(b2RayCastCallback, b2Vec2, b2Vec2) ray hits (pybox2d's
rayCastCallback, which BipedalWalker's lidar subclasses). Hits arrive in tree order, not by distance.
- b2RevoluteJoint
A revolute joint: a point-to-point constraint at the anchor, with an optional angle limit and an optional motor that drives the relative angular velocity up to a maximum torque. BipedalWalker's and LunarLander's legs are revolute joints.
- b2RevoluteJointDef
A revolute joint definition (pybox2d's
revoluteJointDef): two bodies share an anchor point, with an optional angle limit and an optional motor.
- b2Shape
A collision shape, the geometry a b2Fixture carries. Shapes hold no body: a fixture clones the shape it is created from, so changing a shape object afterwards changes nothing in the world.
- b2World
The physics world: bodies, joints and contacts, stepped with Step(float, int, int). Not thread-safe: one world belongs to one thread at a time (each env instance owns its own world).
Structs
- b2Filter
Collision filtering data: a fixture collides with another when each one's mask accepts the other's category, unless they share a non-zero group (positive: always collide, negative: never).
- b2Rot
A rotation as its sine and cosine, float32, computed once by
sinf/cosfwhen set from an angle.
- b2Transform
A rigid transform, a translation p and a rotation q: a body's frame in the world.
- b2Vec2
Box2D's 2-D column vector, float32, the type every position, velocity, force and vertex travels in, and the value pybox2d hands Python as
b2Vec2. Arithmetic on it is float32, as in pybox2d, whose vector operators run in C++:v * 2.5rounds 2.5 to float32 first and multiplies in float32.
Enums
- b2BodyType
The body type: static (zero mass, zero velocity, may be moved manually), kinematic, or dynamic.
- b2JointType
The joint types of Box2D 2.3 (C++
b2JointType); this port builds e_revoluteJoint.
- b2ShapeType
The kind of a b2Shape (C++
b2Shape::Type); the contact factory dispatches on the pair.