B2Shape

From Box2D Wiki

b2Shape
Box2D/Collision/Shapes
Visibility Public
Definition Object b2ShapeDef
Children b2CircleShape
b2PolygonShape
Manual reference [1]
API reference [2]
Source reference H.png Cpp.png

b2Shape is the abstract class for representing shapes. Shapes are objected contained by a body to define that bodies form. They also contain density information, which can be used to set the mass of a body with b2Body.SetMassFromShapes.

Box2d contains only two shapes: circles and convex polygons. By using many of these, complicated bodies can be made. Future versions of box2d have plans for a further shape type, meshes.

Collision properties

All collision detection in box2d is done per shape, rather than per body. This has the consequence that it is relatively easy to determine which part of a body was hit, and box2d takes advantage of this to store several collision related properties in the shape object.

friction and restitution are physical properties of the shape. categoryBits, maskBits and groupIndex form part of Box2d's filtering system. Finally isSensor determines if a particular shape is a sensor.


TOOLBOX
LANGUAGES